java.lang.Object
org.eclipse.milo.opcua.stack.core.util.Tree<A>

public class Tree<A> extends Object
  • Constructor Details

    • Tree

      public Tree(@Nullable Tree<A> parent, A value)
  • Method Details

    • addChild

      public Tree<A> addChild(A value)
    • addChild

      public Tree<A> addChild(Tree<A> child)
    • getParent

      public @Nullable Tree<A> getParent()
    • getChildren

      public List<Tree<A>> getChildren()
    • getValue

      public A getValue()
    • traverse

      public void traverse(Consumer<A> c)
      Traverse this tree consuming the value at each node.
      Parameters:
      c - the value Consumer.
    • traverseNodes

      public void traverseNodes(Consumer<Tree<A>> c)
      Traverse this tree consuming each Tree node.
      Parameters:
      c - the node Consumer.
    • traverseWithDepth

      public void traverseWithDepth(BiConsumer<A,Integer> c)
      Traverse this tree consuming the value and current depth at each node.
      Parameters:
      c - the value and depth BiConsumer.
    • traverseWithDepth

      public void traverseWithDepth(BiConsumer<A,Integer> c, Comparator<Tree<A>> comparator)
      Traverse this tree consuming the value and current depth at each node.
      Parameters:
      c - the value and depth BiConsumer.
      comparator - a Comparator to sort the children of each node.
    • traverseWithParent

      public void traverseWithParent(BiConsumer<A,A> c)
      Traverse this tree consuming pairs of (value, parent.value).

      parent.value may be null if this node is the root.

      Parameters:
      c - the BiConsumer.
    • map

      public <B> Tree<B> map(Function<A,B> f)
      Map this tree into a new tree using the transformation f.
      Type Parameters:
      B - the new type.
      Parameters:
      f - a function that transforms from A to B.
      Returns:
      a new tree in which the values have been mapped from A to B using f.