Class AbstractTreeNode<T>

    • Method Detail

      • walk

        public static <T,​R> R walk​(AbstractTreeNode<T> tree,
                                         Function<TreeLeaf<T>,​R> leafFunction,
                                         BiFunction<Stream<R>,​Query.LogicalOperator,​R> internalNodeFunction)
        Generic helper method to walk a tree (i.e. traverse a tree) for visiting each node and doing a recursive treatment
        This is a post-order walk (the children are traversed before their respective parents are traversed)
        See also this link
        Type Parameters:
        T - the type of the values of the leaves of the given tree
        R - the type of the object returned by this method.
        Parameters:
        tree - The tree to walk
        leafFunction - The operation to perform for a leaf
        internalNodeFunction - The operation to perform for an internal node.
        This function takes two arguments:
        • the results for each child as a stream;
        • the logical operator of the internal node
        Returns:
        a result