public final class NodeWalk extends Object
Modifier and Type | Method and Description |
---|---|
static Node |
getAt(Node node,
int index)
Returns a
Node from the tree structure represented by the given Node . |
static Node |
replaceAll(Node node,
Predicate<Node> criteria,
Function<Node,Node> replacement)
Returns a new
Node resulting from replacing any components that match the specified predicate with the result of applying the specified function. |
static Node |
replaceAt(Node node,
int index,
Function<Node,Node> replacement)
Returns a new
Node resulting from replacing the Node at position index of the given Node with the result of
replacement . |
public static Node getAt(Node node, int index)
Node
from the tree structure represented by the given Node
.index
- the index of the Node
, in the tree structure represented by node
, that needs to be returnedNode
at index
of the tree structure represented by node
public static Node replaceAt(Node node, int index, Function<Node,Node> replacement)
Node
resulting from replacing the Node
at position index
of the given Node
with the result of
replacement
.index
- the index of the Node
, in the tree structure represented by node
, that needs to be replacedreplacement
- the function to apply to the Node
at index
to determine the Node
that should replace itNode
derived from replacing the Node
at index
with the result of replacement
public static Node replaceAll(Node node, Predicate<Node> criteria, Function<Node,Node> replacement)
Node
resulting from replacing any components that match the specified predicate with the result of applying the specified function.criteria
- the predicate used to determine if a node should be replacedreplacement
- the function used to determine what a node should be replaced withOakGP Genetic Programming Framework