|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.epochx.representation.Node<TYPE>
public abstract class Node<TYPE>
Subclasses of Node should ensure they call the superclass
constructor with all child Nodes so information such as the arity of the
Node can be maintained. Concrete subclasses must also implement evaluate().
A Node is a vertex in a tree structure which represents a program. A Node
can be thought of as an expression in a computer programming language.
Evaluating a Node will involve evaluating any children and potentially
performing some operation and/or returning a value. A program
is maintained by the CandidateProgram class.
FunctionNode,
TerminalNode| Constructor Summary | |
|---|---|
Node(Node<TYPE>... children)
Node constructor. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Create a deep copy of this node tree. |
boolean |
equals(java.lang.Object obj)
Compare an object for equality. |
abstract TYPE |
evaluate()
Performs some operation and/or returns a value associated with this Node. |
int |
getArity()
Returns the number of immediate children this Node has. |
Node<TYPE> |
getChild(int index)
Returns a specific child by index. |
Node<TYPE>[] |
getChildren()
Returns an array of the children of this node. |
int |
getDepth()
Returns the depth of deepest node in the node tree, given that this node is at depth zero. |
java.util.List<FunctionNode<TYPE>> |
getFunctionNodes()
Returns a list of all the function nodes in the this node tree. |
int |
getLength()
Returns the number of nodes in the node tree. |
java.util.List<Node<TYPE>> |
getNodesAtDepth(int depth)
Retrieves all the nodes in the node tree at a specified depth from this current node. |
int |
getNoDistinctFunctions()
Returns a count of how many unique function nodes are in the node tree. |
int |
getNoDistinctTerminals()
Returns a count of how many unique terminal nodes are in the node tree. |
int |
getNoFunctions()
Returns a count of how many function nodes are in the node tree. |
int |
getNoTerminals()
Returns a count of how many terminal nodes are in the node tree. |
Node<TYPE> |
getNthNode(int n)
Returns the element at the specified position in the node tree, where this node is considered to be the root - that is the 0th node. |
java.util.List<TerminalNode<TYPE>> |
getTerminalNodes()
Returns a list of all the terminal nodes in the this node tree. |
int |
hashCode()
|
void |
setChild(int index,
Node<TYPE> child)
Replaces the child node at the specified index with the specified node. |
void |
setChildren(Node<TYPE>[] children)
Sets the children of this node. |
void |
setNthNode(int n,
Node<TYPE> newNode)
Replaces the node at the specified position in this node tree, where this node is considered to be the root node - that is, the 0th node. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Node(Node<TYPE>... children)
children - child nodes to this node.| Method Detail |
|---|
public abstract TYPE evaluate()
public Node<TYPE>[] getChildren()
public void setChildren(Node<TYPE>[] children)
children - the new children to be set.public Node<TYPE> getChild(int index)
index - the index (representing arity) of the child to be returned,
indexes are from zero.
public Node<TYPE> getNthNode(int n)
n - the index of the node to be returned.
public void setNthNode(int n,
Node<TYPE> newNode)
n - the index of the node to replace.newNode - the node to be stored at the specified position.public java.util.List<Node<TYPE>> getNodesAtDepth(int depth)
depth - the specified depth of the nodes.
public void setChild(int index,
Node<TYPE> child)
index - the index of the child to replace within the nodes arity.child - the child node to be stored at the specified position.public int getArity()
public int getNoTerminals()
public int getNoDistinctTerminals()
public java.util.List<TerminalNode<TYPE>> getTerminalNodes()
public int getNoFunctions()
public int getNoDistinctFunctions()
public java.util.List<FunctionNode<TYPE>> getFunctionNodes()
public int getDepth()
public int getLength()
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Object clone()
clone in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - an object to be compared for equivalence.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||