Skip to content

io7m-com/jorchard

Repository files navigation

jorchard

Maven Central Maven Central (snapshot) Codecov

com.io7m.jorchard

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

jorchard

A generic unbalanced rose tree implementation.

Features

Usage

Assuming an arbitrary type T, create a tree with a root value of x of type T:

var t = JOTreeNode.create(x);

Add nodes to the tree:

var t0 = JOTreeNode.create(y0);
var t1 = JOTreeNode.create(y1);
var t2 = JOTreeNode.create(y2);

t0.setParent(t);
t1.setParent(t);
t2.setParent(t);

Iterate over the tree:

t.forEachDepthFirst(order, (input, depth, node) -> {
  // ...
});

t.forEachBreadthFirst(order, (input, depth, node) -> {
  // ...
});

Detach nodes from the tree:

t2.detach();