Package com.io7m.jorchard.core
Interface JOTreeNodeReadableType<A>
- Type Parameters:
A- The type of values
- All Known Subinterfaces:
JOTreeNodeType<A>
- All Known Implementing Classes:
JOTreeNode
public interface JOTreeNodeReadableType<A>
The type of readable tree nodes.
-
Method Summary
Modifier and TypeMethodDescription<T> voidforEachBreadthFirst(T context, JOTreeNodeForEachFunctionType<A, T> f) Visit each node in the tree in breadth-first order.<T> voidforEachDepthFirst(T context, JOTreeNodeForEachFunctionType<A, T> f) Visit each node in the tree in depth-first order.booleanisDescendantOf(JOTreeNodeReadableType<A> other) booleandefault booleanisRoot()<T,B> JOTreeNodeType<B> mapBreadthFirst(T context, JOTreeNodeMapFunctionType<A, T, B> f) Visit each node in the tree in breadth-first order.<T,B> JOTreeNodeType<B> mapDepthFirst(T context, JOTreeNodeMapFunctionType<A, T, B> f) Visit each node in the tree in depth-first order.value()
-
Method Details
-
isDetachAllowed
boolean isDetachAllowed()- Returns:
trueiff this node may be detached from its parent
-
value
A value()- Returns:
- The value contained within the node
-
isRoot
default boolean isRoot()- Returns:
trueiff this node is a root node
-
parentReadable
Optional<JOTreeNodeReadableType<A>> parentReadable()- Returns:
- A readable reference to the parent node
-
childrenReadable
List<JOTreeNodeReadableType<A>> childrenReadable()- Returns:
- A read-only collection containing the children of this node
-
isDescendantOf
- Parameters:
other- A node- Returns:
trueiff this node is a descendant ofother
-
forEachDepthFirst
Visit each node in the tree in depth-first order.
The function allows for the use of a context value. This is useful for avoiding the use of capturing lambdas, reducing GC pressure.
- Type Parameters:
T- The type of context values- Parameters:
context- A context value passed to each application offf- A function used to receive each node
-
forEachBreadthFirst
Visit each node in the tree in breadth-first order.
The function allows for the use of a context value. This is useful for avoiding the use of capturing lambdas, reducing GC pressure.
- Type Parameters:
T- The type of context values- Parameters:
context- A context value passed to each application offf- A function used to receive each node
-
mapDepthFirst
Visit each node in the tree in depth-first order.
The function allows for the use of a context value. This is useful for avoiding the use of capturing lambdas, reducing GC pressure.
- Type Parameters:
T- The type of context valuesB- The type of values in the returned tree- Parameters:
context- A context value passed to each application offf- A function used to receive each node- Returns:
- A new structurally equal tree with nodes of type
B
-
mapBreadthFirst
Visit each node in the tree in breadth-first order.
The function allows for the use of a context value. This is useful for avoiding the use of capturing lambdas, reducing GC pressure.
- Type Parameters:
T- The type of context valuesB- The type of values in the returned tree- Parameters:
context- A context value passed to each application offf- A function used to receive each node- Returns:
- A new structurally equal tree with nodes of type
B
-