|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.moeaframework.util.tree.Node
public abstract class Node
A node in an expression tree. Expression trees are strongly typed, meaning nodes have defined return types and argument types. The return type of all nodes must match the argument type from its parent node.
| Constructor Summary | |
|---|---|
Node()
Constructs a new node. |
|
Node(Class<?> returnType,
Class<?>... argumentTypes)
Constructs a new node with the given return type and argument types. |
|
| Method Summary | |
|---|---|
abstract Node |
copyNode()
Returns a copy of this node, but without any children or parents assigned. |
Node |
copyTree()
Returns a copy of this node including copies of all its arguments (child nodes). |
abstract Object |
evaluate(Environment environment)
Evaluates this node in the context of the specified environment. |
Node |
getArgument(int index)
Returns the argument (child node) at the specified index. |
Class<?> |
getArgumentType(int index)
Returns the type of the argument (child node) at the specified index. |
int |
getDepth()
Returns the depth of this node, which is the number of branches between this node and the root. |
Node |
getFunctionAt(Class<?> type,
int index)
Returns the function (non-terminal) node at the specified index in the subtree rooted at this node, counting only nodes that match the given return type. |
Node |
getFunctionAt(int index)
Returns the function (non-terminal) node at the specified index in the subtree rooted at this node. |
int |
getMaximumHeight()
Returns the number of branches between this node and the furthest leaf. |
int |
getMinimumHeight()
Returns the number of branches between this node and the nearest leaf. |
protected Node |
getNodeAt(Class<?> type,
boolean includeFunctions,
boolean includeTerminals,
int index)
Returns the node at the specified index in the subtree rooted at this node. |
Node |
getNodeAt(Class<?> type,
int index)
Returns the node at the specified index in the subtree rooted at this node, counting only nodes that match the given return type. |
Node |
getNodeAt(int index)
Returns the node at the specified index in the subtree rooted at this node. |
int |
getNumberOfArguments()
Returns the number of arguments (child nodes) of this node. |
int |
getNumberOfFunctions()
Returns the number of function (non-terminal) nodes contained in the subtree rooted at this node. |
int |
getNumberOfFunctions(Class<?> type)
Returns the number of function (non-terminal) nodes contained in the subtree rooted at this node that match the given return type. |
int |
getNumberOfNodes()
Returns the number of nodes contained in the subtree rooted at this node. |
int |
getNumberOfNodes(Class<?> type)
Returns the number of nodes contained in the subtree rooted at this node that match the given return type. |
protected int |
getNumberOfNodes(Class<?> type,
boolean includeFunctions,
boolean includeTerminals)
Returns the number of nodes contained in the subtree rooted at this node. |
int |
getNumberOfTerminals()
Returns the number of terminal nodes contained in the subtree rooted at this node. |
int |
getNumberOfTerminals(Class<?> type)
Returns the number of terminal nodes contained in the subtree rooted at this node that match the given return type. |
Node |
getParent()
Returns the parent of this node; or null if this node has no
parent. |
Class<?> |
getReturnType()
Returns the return type of this node. |
Node |
getTerminalAt(Class<?> type,
int index)
Returns the terminal node at the specified index in the subtree rooted at this node, counting only nodes that match the given return type. |
Node |
getTerminalAt(int index)
Returns the terminal node at the specified index in the subtree rooted at this node. |
boolean |
isFixed()
Returns true if this node should not be modified, altered, or
replaced; false otherwise. |
boolean |
isTerminal()
Returns true if this is a terminal node (has no arguments);
false otherwise. |
boolean |
isValid()
Returns true if this node and its arguments are valid;
false otherwise. |
Node |
setArgument(int index,
Node expression)
Sets the argument (child node) at the specified index. |
void |
setFixed(boolean fixed)
Set to true if this node should not be modified, altered, or
replaced; false otherwise. |
void |
setFixedTree(boolean fixed)
Calls setFixed(boolean) on all nodes in the subtree rooted at
this node. |
int |
size()
Returns the number of nodes contained in the tree rooted at this node. |
String |
toString()
Returns a string representation of the object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Node()
public Node(Class<?> returnType,
Class<?>... argumentTypes)
returnType - the return type of the nodeargumentTypes - the type of the arguments, if any, for the node| Method Detail |
|---|
public void setFixedTree(boolean fixed)
setFixed(boolean) on all nodes in the subtree rooted at
this node.
fixed - true if all nodes in the subtree rooted at this
node should not be modified, altered, or replaced; false
otherwisepublic void setFixed(boolean fixed)
true if this node should not be modified, altered, or
replaced; false otherwise.
fixed - true if this node should not be modified, altered,
or replaced; false otherwisepublic boolean isFixed()
true if this node should not be modified, altered, or
replaced; false otherwise.
true if this node should not be modified, altered, or
replaced; false otherwisepublic int getNumberOfArguments()
public Node getArgument(int index)
index - the index of the argument to return
public Node getParent()
null if this node has no
parent.
null if this node has no
parentpublic Class<?> getReturnType()
public Class<?> getArgumentType(int index)
index - the index of the argument
public Node setArgument(int index,
Node expression)
index - the index of the new argumentexpression - the expression defining the argument
public int size()
public int getDepth()
public int getMinimumHeight()
public int getMaximumHeight()
public abstract Node copyNode()
public Node copyTree()
isFixed().
public abstract Object evaluate(Environment environment)
environment - the execution environment
public boolean isValid()
true if this node and its arguments are valid;
false otherwise. A valid node has all arguments defined,
all arguments are valid, and all arguments are the appropriate type.
true if this node and its arguments are valid;
false otherwisepublic String toString()
java.lang.ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString in class Objectpublic boolean isTerminal()
true if this is a terminal node (has no arguments);
false otherwise.
true if this is a terminal node (has no arguments);
false otherwisepublic int getNumberOfFunctions(Class<?> type)
type - the return type of the node
public Node getFunctionAt(Class<?> type,
int index)
type - the return type of the nodeindex - the index of the node to return
IndexOutOfBoundsException - if the index refers to a node not
within the subtree rooted at this nodepublic int getNumberOfFunctions()
public Node getFunctionAt(int index)
index - the index of the node to return
IndexOutOfBoundsException - if the index refers to a node not
within the subtree rooted at this nodepublic int getNumberOfTerminals(Class<?> type)
type - the return type of the node
public Node getTerminalAt(Class<?> type,
int index)
type - the return type of the nodeindex - the index of the node to return
IndexOutOfBoundsException - if the index refers to a node not
within the subtree rooted at this nodepublic int getNumberOfTerminals()
public Node getTerminalAt(int index)
index - the index of the node to return
IndexOutOfBoundsException - if the index refers to a node not
within the subtree rooted at this nodepublic int getNumberOfNodes(Class<?> type)
type - the return type of the node
public Node getNodeAt(Class<?> type,
int index)
type - the return type of the nodeindex - the index of the node to return
IndexOutOfBoundsException - if the index refers to a node not
within the subtree rooted at this nodepublic int getNumberOfNodes()
public Node getNodeAt(int index)
index - the index of the node to return
IndexOutOfBoundsException - if the index refers to a node not
within the subtree rooted at this node
protected int getNumberOfNodes(Class<?> type,
boolean includeFunctions,
boolean includeTerminals)
type - the return type of the nodeincludeFunctions - true if functions (non-terminals) are
counted; false otherwiseincludeTerminals - true if terminals are counted;
false otherwise
protected Node getNodeAt(Class<?> type,
boolean includeFunctions,
boolean includeTerminals,
int index)
type - the return type of the nodeincludeFunctions - true if functions (non-terminals) are
counted; false otherwiseincludeTerminals - true if terminals are counted;
false otherwiseindex - the index of the node to return
IndexOutOfBoundsException - if the index refers to a node not
within the subtree rooted at this node
|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||