public abstract class AbstractTreeGene<A,G extends AbstractTreeGene<A,G>> extends Object implements TreeGene<A,G>
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() |
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() |
G |
getChild(int index)
Return the child gene with the given index.
|
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 |
identical(Tree<?,?> other)
Tests whether
this node is the same as the other node. |
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, wait
getValue, newInstance
newInstance, newInstance
breadthFirstIterator, breadthFirstStream, childAfter, childBefore, childIterator, childStream, depth, depthFirstIterator, depthFirstStream, equals, firstChild, firstLeaf, getIndex, getPath, hashCode, isAncestor, isChild, isDescendant, isLeaf, isRelated, isSibling, iterator, lastChild, lastLeaf, leafCount, level, nextLeaf, nextNode, nextSibling, pathFromAncestorIterator, postorderIterator, postorderStream, preorderIterator, preorderStream, previousLeaf, previousNode, previousSibling, sharedAncestor, siblingCount, stream, toCompactString, toDottyString, toString
forEach, spliterator
protected 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()
Tree
public boolean isRoot()
Tree
true
if this node is the root of the tree.public int size()
Tree
this
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 getChild(int index)
getChild
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()
Tree
childCount
in interface Tree<A,G extends AbstractTreeGene<A,G>>
public boolean isValid()
isValid
in interface Verifiable
public boolean identical(Tree<?,?> other)
Tree
this
node is the same as the other
node.
The default implementation returns the object identity,
this == other
, of the two objects, but other implementations may
use different criteria for checking the identity.© 2007-2017 Franz Wilhelmstötter (2017-11-16 20:01)