Interface FlatTree<V,T extends FlatTree<V,T>>

All Superinterfaces:
Iterable<T>, Self<T>, Tree<V,T>
All Known Subinterfaces:
TreeGene<A,G>
All Known Implementing Classes:
AbstractTreeGene, FlatTreeNode, ProgramGene

public interface FlatTree<V,T extends FlatTree<V,T>> extends Tree<V,T>
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
     └── 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 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
  • Method Details

    • childOffset

      Return the index of the first child node in the underlying node array. -1 is returned if this node is a leaf.
      Returns:
      Return the index of the first child node in the underlying node array, or -1 if this node is a leaf
    • flattenedNodes

      default ISeq<T> flattenedNodes()
      Return the whole flattened tree values in breadth-first order. This is equivalent to
      final ISeq<T> seq = getRoot().breadthFirstStream() .collect(ISeq.toISeq());
      Returns:
      the flattened tree values in breadth-first order