thomasmueller commented on code in PR #2447:
URL: https://github.com/apache/jackrabbit-oak/pull/2447#discussion_r2273326473


##########
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/Traverser.java:
##########
@@ -169,5 +167,107 @@ public T next() {
             return current;
         }
     }
+
+    /**
+     * Returns an iterator that traverses a tree structure in post-order. Null 
nodes are strictly forbidden.
+     * <p>
+     * In post-order traversal, all children of a node are visited from left 
to right, followed by
+     * the node itself. This creates a bottom-up traversal pattern where leaf 
nodes are visited first,
+     * then their parents, and finally the root.
+     *
+     * @param <T> the type of value in the tree nodes
+     * @param root the root node of the tree, may be null
+     * @param childExtractor function to extract children from a node, must 
not be null
+     * @return an iterator that traverses the tree in post-order
+     * @throws NullPointerException if childExtractor or any child is null
+     */
+    public static <T> FluentIterable<T> postOrderTraversal(final T root, final 
@NotNull Function<T, Iterable<? extends T>> childExtractor) {
+        Objects.requireNonNull(childExtractor, "Children extractor function 
must not be null");
+        if (root == null) {
+            return FluentIterable.empty();
+        }

Review Comment:
   The randomized tests are _specially_ useful to test edge cases. Specially 
randomized tests that compare the old with the new implementation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to