Package convex.core.util
Class Trees
java.lang.Object
convex.core.util.Trees
Utility class for tree handling functions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidvisitStack(List<T> stack, Consumer<T> visitor) Visits elements on a stack, popping one off from the end each time.static <T> voidvisitStackMaybePopping(List<T> stack, Predicate<T> visitor) Visits elements on a stack, the element if predicate returns true.
-
Constructor Details
-
Trees
public Trees()
-
-
Method Details
-
visitStack
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 Listvisitor- Visitor function to call for each stack element.
-
visitStackMaybePopping
Visits elements on a stack, the element if predicate returns true. Predicate function MAY add to 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 Listvisitor- Visitor function to call for each stack element.
-