public interface FlatTree<V,T extends FlatTree<V,T>> extends Tree<V,T>
0 ├── 1 │ ├── 4 │ └── 5 ├── 2 │ └── 6 └── 3 ├── 7 │ ├── 10 │ └── 11 ├── 8 └── 9will be stored in breadth-first order and will look like this:
┌─┬───┐ ┌──────┬──┐ 0 1 2 3 4 5 6 7 8 9 10 11 └─│─│─┴─┘ │ │ │ └─│─────┘ │ │ └───────┴───┘The child nodes are always stored on the right side of the parent flattenedNodes. So you have to read the tree from left to right. All children of a parent node are stored continuously after the
childOffset
and are defined by the
sub-array [childOffset, childOffset + childCount)
.Modifier and Type | Method and Description |
---|---|
int |
childOffset()
Return the index of the first child node in the underlying node array.
|
default ISeq<T> |
flattenedNodes()
Return the whole flattened tree values in breadth-first order.
|
breadthFirstIterator, breadthFirstStream, childAfter, childBefore, childCount, childIterator, childStream, depth, depthFirstIterator, depthFirstStream, equals, firstChild, firstLeaf, getChild, getIndex, getParent, getPath, getRoot, getValue, hashCode, identical, isAncestor, isChild, isDescendant, isLeaf, isRelated, isRoot, isSibling, iterator, lastChild, lastLeaf, leafCount, level, nextLeaf, nextNode, nextSibling, pathFromAncestorIterator, postorderIterator, postorderStream, preorderIterator, preorderStream, previousLeaf, previousNode, previousSibling, sharedAncestor, siblingCount, size, stream, toCompactString, toDottyString, toString
forEach, spliterator
int childOffset()
-1
is returned if this
node is a leaf.-1
if this
node is a leafdefault ISeq<T> flattenedNodes()
final ISeq<T> seq = getRoot().breadthFirstStream()
.collect(ISeq.toISeq());
© 2007-2018 Franz Wilhelmstötter (2018-05-31 12:39)