Module io.jenetics.ext
Package io.jenetics.ext
Class AbstractTreeGene<A,G extends AbstractTreeGene<A,G>>
java.lang.Object
io.jenetics.ext.AbstractTreeGene<A,G>
- All Implemented Interfaces:
TreeGene<A,,G> FlatTree<A,,G> Tree<A,,G> Gene<A,,G> Factory<G>,Self<G>,Verifiable,Serializable,Iterable<G>
- Direct Known Subclasses:
ProgramGene
public abstract class AbstractTreeGene<A,G extends AbstractTreeGene<A,G>>
extends Object
implements TreeGene<A,G>, Serializable
Abstract implementation of the
TreeGene interface..- Since:
- 3.9
- Version:
- 6.0
- See Also:
-
Nested Class Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractTreeGene(A allele, int childOffset, int childCount) Creates a new tree-gene from the given data. -
Method Summary
Modifier and TypeMethodDescriptionallele()Return the allele of this gene.protected voidThis method is used by theAbstractTreeChromosometo attach itself to this gene.protected voidchildAt(int index) Return the child gene with the given index.intReturn the number of children this tree node consists of.intReturn the index of the first child node in the underlying node array.booleanReturn the whole flattened tree values in breadth-first order.inthashCode()booleanisRoot()Returnstrueif this node is the root of the tree.booleanisValid()Check if this object is valid.parent()Return the parent node of this tree node.root()Returns the root of the tree that contains this node.intsize()Return the number of nodes ofthisnode (subtree).toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.jenetics.Gene
newInstance, newInstanceMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface io.jenetics.ext.util.Tree
breadthFirstIterator, breadthFirstStream, childAfter, childAtPath, childAtPath, childBefore, childIterator, childPath, childStream, depth, depthFirstIterator, depthFirstStream, firstChild, firstLeaf, identical, indexOf, isAncestor, isChild, isDescendant, isEmpty, isLeaf, isRelated, isSibling, iterator, lastChild, lastLeaf, leafCount, leaves, level, nextLeaf, nextNode, nextSibling, path, pathElements, pathFromAncestorIterator, postorderIterator, postorderStream, preorderIterator, preorderStream, previousLeaf, previousNode, previousSibling, reduce, sharedAncestor, siblingCount, stream, toParenthesesString, toParenthesesStringMethods inherited from interface io.jenetics.ext.TreeGene
newInstance, newInstance, value
-
Constructor Details
-
AbstractTreeGene
Creates a new tree-gene from the given data.- Parameters:
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 gene- Throws:
IllegalArgumentException- if thechildCountis smaller than zero
-
-
Method Details
-
flattenedNodes
Return the whole flattened tree values in breadth-first order. This method will always return the sameISeqinstance.- Specified by:
flattenedNodesin interfaceFlatTree<A,G extends AbstractTreeGene<A, G>> - Returns:
- the whole flattened tree values
-
root
Description copied from interface:TreeReturns the root of the tree that contains this node. The root is the ancestor with no parent. -
isRoot
Description copied from interface:TreeReturnstrueif this node is the root of the tree. -
size
Description copied from interface:TreeReturn the number of nodes ofthisnode (subtree). -
checkTreeState
-
bind
This method is used by theAbstractTreeChromosometo attach itself to this gene.- Parameters:
genes- the genes of the attached chromosome
-
childOffset
Description copied from interface:FlatTreeReturn the index of the first child node in the underlying node array.-1is returned ifthisnode is a leaf.- Specified by:
childOffsetin interfaceFlatTree<A,G extends AbstractTreeGene<A, G>> - Returns:
- Return the index of the first child node in the underlying node
array, or
-1ifthisnode is a leaf
-
allele
Description copied from interface:GeneReturn the allele of this gene. -
parent
Return the parent node of this tree node.- Specified by:
parentin interfaceTree<A,G extends AbstractTreeGene<A, G>> - Returns:
- the parent node, or
Optional.empty()if this node is the root of the tree - Throws:
IllegalStateException- if this gene is not part of a chromosome
-
childAt
Return the child gene with the given index.- Specified by:
childAtin interfaceTree<A,G extends AbstractTreeGene<A, G>> - Parameters:
index- the child index- Returns:
- the child node with the given index
- Throws:
IndexOutOfBoundsException- if theindexis out of bounds ([0, childCount()))IllegalStateException- if this gene is not part of a chromosome
-
childCount
Description copied from interface:TreeReturn the number of children this tree node consists of.- Specified by:
childCountin interfaceTree<A,G extends AbstractTreeGene<A, G>> - Returns:
- the number of children this tree node consists of
-
isValid
Description copied from interface:VerifiableCheck if this object is valid.- Specified by:
isValidin interfaceVerifiable- Returns:
- true if this object is valid, false otherwise.
-
hashCode
-
equals
-
toString
-