Package convex.core.util
Class Trees
java.lang.Object
convex.core.util.Trees
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
visitStack
(List<T> stack, Consumer<? super T> visitor) Visits elements on a stack, popping one off from the end each time.static <T> void
visitStackMaybePopping
(List<T> stack, Predicate<? super 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.
-