From 7c12fd8fe169944152ca73f0da4e8fe8e280f648 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 18 Apr 2016 08:38:24 -0400 Subject: Added new option to top-down travers --- .../src/main/java/bjc/utils/funcdata/ITree.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java index 7f28682..bbcefd3 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/ITree.java @@ -155,4 +155,24 @@ public interface ITree { public ITree topDownTransform( Function transformPicker, UnaryOperator> transformer); + + /** + * Get the specified child of this tree + * + * @param childNo + * The number of the child to get + * @return The specified child of this tree + */ + default ITree getChild(int childNo) { + return transformChild(childNo, (child) -> child); + } + + /** + * Get the data stored in this node + * + * @return The data stored in this node + */ + default ContainedType getHead() { + return transformHead((head) -> head); + } } -- cgit v1.2.3