public abstract class AbstractTreeGene<A,G extends AbstractTreeGene<A,G>> extends Object implements TreeGene<A,G>, Serializable
TreeGene interface..| Modifier | Constructor and Description |
|---|---|
protected |
AbstractTreeGene(A allele,
int childOffset,
int childCount)
Creates a new tree-gene from the given data.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
bind(ISeq<G> genes)
This method is used by the
AbstractTreeChromosome to attach
itself to this gene. |
protected void |
checkTreeState() |
G |
childAt(int index)
Return the child gene with the given index.
|
int |
childCount()
Return the number of children this tree node consists of.
|
int |
childOffset()
Return the index of the first child node in the underlying node array.
|
boolean |
equals(Object obj) |
ISeq<G> |
flattenedNodes()
Return the whole flattened tree values in breadth-first order.
|
A |
getAllele() |
Optional<G> |
getParent()
Return the parent node of this tree node.
|
G |
getRoot()
Returns the root of the tree that contains this node.
|
int |
hashCode() |
boolean |
isRoot()
Returns
true if this node is the root of the tree. |
boolean |
isValid() |
int |
size()
Return the number of nodes of
this node (sub-tree). |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetValue, newInstancenewInstance, newInstancebreadthFirstIterator, breadthFirstStream, childAfter, childAtPath, childAtPath, childBefore, childIterator, childPath, childStream, depth, depthFirstIterator, depthFirstStream, equals, firstChild, firstLeaf, getPath, hashCode, identical, indexOf, isAncestor, isChild, isDescendant, isLeaf, isRelated, isSibling, iterator, lastChild, lastLeaf, leafCount, level, nextLeaf, nextNode, nextSibling, path, pathElements, pathFromAncestorIterator, postorderIterator, postorderStream, preorderIterator, preorderStream, previousLeaf, previousNode, previousSibling, sharedAncestor, siblingCount, stream, toParenthesesString, toParenthesesString, toStringforEach, spliteratorprotected AbstractTreeGene(A allele, int childOffset, int childCount)
allele - the actual value (allele) of the tree-genechildOffset - the offset index of the child in the containing
chromosome. If this node has no child, the value should be set
to zero.childCount - the number of children of this geneIllegalArgumentException - if the childCount is smaller
than zeropublic ISeq<G> flattenedNodes()
ISeq instance.flattenedNodes in interface FlatTree<A,G extends AbstractTreeGene<A,G>>public G getRoot()
Treepublic boolean isRoot()
Treetrue if this node is the root of the tree.public int size()
Treethis node (sub-tree).protected void checkTreeState()
protected void bind(ISeq<G> genes)
AbstractTreeChromosome to attach
itself to this gene.genes - the genes of the attached chromosomepublic int childOffset()
FlatTree-1 is returned if this node is a leaf.childOffset in interface FlatTree<A,G extends AbstractTreeGene<A,G>>-1 if this node is a leafpublic Optional<G> getParent()
getParent in interface Tree<A,G extends AbstractTreeGene<A,G>>Optional.empty() if this node is the
root of the treeIllegalStateException - if this gene is not part of a chromosomepublic G childAt(int index)
childAt in interface Tree<A,G extends AbstractTreeGene<A,G>>index - the child indexIndexOutOfBoundsException - if the index is out of
bounds ([0, childCount()))IllegalStateException - if this gene is not part of a chromosomepublic int childCount()
TreechildCount in interface Tree<A,G extends AbstractTreeGene<A,G>>public boolean isValid()
isValid in interface Verifiable© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)