File tree Expand file tree Collapse file tree
src/main/java/org/variantsync/diffdetective/variation/tree Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -419,6 +419,17 @@ public void forAllPreorder(Consumer<T> action) {
419419 }
420420 }
421421
422+ /**
423+ * Traverses all nodes in this subtree in postorder.
424+ */
425+ public void forAllPostorder (Consumer <T > action ) {
426+ for (var child : getChildren ()) {
427+ child .forAllPostorder (action );
428+ }
429+
430+ action .accept (this .upCast ());
431+ }
432+
422433 public void forMeAndMyAncestors (final Consumer <T > action ) {
423434 action .accept (this .upCast ());
424435 final T p = getParent ();
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ public VariationDiff<L> toCompletelyUnchangedVariationDiff() {
151151 }
152152
153153 /**
154- * Invokes the given callback for each node in this Variation Tree in depth-first order.
154+ * Invokes the given callback for each node in this Variation Tree in pre- order.
155155 * @param action callback
156156 * @return this
157157 */
@@ -160,6 +160,16 @@ public VariationTree<L> forAllPreorder(final Consumer<VariationTreeNode<L>> acti
160160 return this ;
161161 }
162162
163+ /**
164+ * Invokes the given callback for each node in this Variation Tree in post-order.
165+ * @param action callback
166+ * @return this
167+ */
168+ public VariationTree <L > forAllPostorder (final Consumer <VariationTreeNode <L >> action ) {
169+ root .forAllPostorder (action );
170+ return this ;
171+ }
172+
163173 /**
164174 * Checks whether any node in this tree satisfies the given condition.
165175 * The condition might not be invoked on every node in case a node is found.
You can’t perform that action at this time.
0 commit comments