From 79cab78bf3d688bb8a359eedcfaf2575ef9d4092 Mon Sep 17 00:00:00 2001 From: bjculkin Date: Sat, 18 Mar 2017 14:20:21 -0400 Subject: Add revFind to trees --- BJC-Utils2/src/main/java/bjc/utils/data/ITree.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/ITree.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/ITree.java b/BJC-Utils2/src/main/java/bjc/utils/data/ITree.java index 63a82b8..63d16d4 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/ITree.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/ITree.java @@ -9,7 +9,7 @@ import java.util.function.Predicate; import java.util.function.UnaryOperator; /** - * A node in a homogenous tree with a unlimited amount of children + * A node in a homogeneous tree with a unlimited amount of children * * @author ben * @param @@ -176,4 +176,15 @@ public interface ITree { * The action to perform on each tree node */ public void traverse(TreeLinearizationMethod linearizationMethod, Consumer action); + + /** + * Find the farthest to right child that satisfies the given predicate. + * + * @param childPred + * The predicate to satisfy. + * + * @return The index of the right-most child that satisfies the + * predicate, or -1 if one doesn't exist. + */ + int revFind(Predicate childPred); } -- cgit v1.2.3