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 Details

    • isDetachAllowed

      boolean isDetachAllowed()
      Returns:
      true iff this node may be detached from its parent
    • value

      A value()
      Returns:
      The value contained within the node
    • isRoot

      default boolean isRoot()
      Returns:
      true iff 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

      boolean isDescendantOf(JOTreeNodeReadableType<A> other)
      Parameters:
      other - A node
      Returns:
      true iff this node is a descendant of other
    • forEachDepthFirst

      <T> void forEachDepthFirst(T context, JOTreeNodeForEachFunctionType<A,T> f)

      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 of f
      f - A function used to receive each node
    • forEachBreadthFirst

      <T> void forEachBreadthFirst(T context, JOTreeNodeForEachFunctionType<A,T> f)

      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 of f
      f - A function used to receive each node
    • mapDepthFirst

      <T, B> JOTreeNodeType<B> mapDepthFirst(T context, JOTreeNodeMapFunctionType<A,T,B> f)

      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
      B - The type of values in the returned tree
      Parameters:
      context - A context value passed to each application of f
      f - A function used to receive each node
      Returns:
      A new structurally equal tree with nodes of type B
    • mapBreadthFirst

      <T, B> JOTreeNodeType<B> mapBreadthFirst(T context, JOTreeNodeMapFunctionType<A,T,B> f)

      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
      B - The type of values in the returned tree
      Parameters:
      context - A context value passed to each application of f
      f - A function used to receive each node
      Returns:
      A new structurally equal tree with nodes of type B