public interface FlatTree<V,T extends FlatTree<V,T>> extends Tree<V,T>
0
├── 1
│ ├── 4
│ └── 5
├── 2
│ └── 6
└── 3
├── 7
│ ├── 10
│ └── 11
├── 8
└── 9
will 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, childAt, childAtPath, childAtPath, childBefore, childCount, childIterator, childPath, childStream, depth, depthFirstIterator, depthFirstStream, equals, firstChild, firstLeaf, getParent, getPath, getRoot, getValue, hashCode, identical, indexOf, isAncestor, isChild, isDescendant, isLeaf, isRelated, isRoot, isSibling, iterator, lastChild, lastLeaf, leafCount, level, nextLeaf, nextNode, nextSibling, path, pathElements, pathFromAncestorIterator, postorderIterator, postorderStream, preorderIterator, preorderStream, previousLeaf, previousNode, previousSibling, sharedAncestor, siblingCount, size, stream, toParenthesesString, toParenthesesString, toStringforEach, spliteratorint 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-2019 Franz Wilhelmstötter (2019-11-18 20:30)