- All Known Subinterfaces:
TreeGene<A,
G>
- All Known Implementing Classes:
AbstractTreeGene
,FlatTreeNode
,ProgramGene
Tree specification, where the nodes of the whole tree are stored in an array.
The tree
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 flattened Nodes. 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)
.- Since:
- 3.9
- Version:
- 3.9
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Return the index of the first child node in the underlying node array.Return the whole flattened tree values in breadth-first order.Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface io.jenetics.ext.util.Tree
breadthFirstIterator, breadthFirstStream, childAfter, childAt, childAtPath, childAtPath, childBefore, childCount, childIterator, childPath, childStream, depth, depthFirstIterator, depthFirstStream, firstChild, firstLeaf, identical, indexOf, isAncestor, isChild, isDescendant, isEmpty, isLeaf, isRelated, isRoot, isSibling, iterator, lastChild, lastLeaf, leafCount, leaves, level, nextLeaf, nextNode, nextSibling, parent, path, pathElements, pathFromAncestorIterator, postorderIterator, postorderStream, preorderIterator, preorderStream, previousLeaf, previousNode, previousSibling, reduce, root, sharedAncestor, siblingCount, size, stream, toParenthesesString, toParenthesesString, value
-
Method Details
-
childOffset
int childOffset()Return the index of the first child node in the underlying node array.-1
is returned ifthis
node is a leaf.- Returns:
- Return the index of the first child node in the underlying node
array, or
-1
ifthis
node is a leaf
-
flattenedNodes
Return the whole flattened tree values in breadth-first order. This is equivalent tofinal ISeq<T> seq = getRoot().breadthFirstStream() .collect(ISeq.toISeq());
- Returns:
- the flattened tree values in breadth-first order
-