Class Trees

java.lang.Object
convex.core.util.Trees

public class Trees extends Object
Utility class for tree handling functions
  • Constructor Details

    • Trees

      public Trees()
  • Method Details

    • visitStack

      public static <T> void visitStack(List<T> stack, Consumer<T> visitor)
      Visits elements on a stack, popping one off from the end each time. Visitor function MAY edit the stack. Will terminate when stack is empty. IMPORTANT: O(1) usage of JVM stack, may be necessary to use a function like this when visiting deeply nested trees in CVM code.
      Type Parameters:
      T - Type of element to visit
      Parameters:
      stack - Stack of values to visit, must be a mutable List
      visitor - Visitor function to call for each stack element.