diff options
3 files changed, 57 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/configuration/ConfigFile.java b/BJC-Utils2/src/main/java/bjc/utils/configuration/ConfigFile.java index 458aece..9358419 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/configuration/ConfigFile.java +++ b/BJC-Utils2/src/main/java/bjc/utils/configuration/ConfigFile.java @@ -78,6 +78,8 @@ public class ConfigFile { } } + scn.close(); + return returnedFile; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java index d2f9013..8ceb554 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTreeLeaf.java @@ -112,6 +112,10 @@ public class BinarySearchTreeLeaf<T> implements ITreePart<T> { switch (treeWalker.walk(data)) { case SUCCESS: return true; + // We don't have any children to care about + case FAILURE: + case LEFT: + case RIGHT: default: return false; } diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java index c4450f8..4b00b63 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java +++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/AST.java @@ -302,4 +302,55 @@ public class AST<T> { action.accept(token); } } + + /** + * Apply an action to the head node of this AST + * + * @param <E> + * The type of the returned value + * @param headAction + * The action to apply to the head node + * @return The result of applying the action + */ + public <E> E applyToHead(Function<T, E> headAction) { + if (headAction == null) { + throw new NullPointerException("Action must not be null"); + } + + return headAction.apply(token); + } + + /** + * Apply an action to the left side of this AST + * + * @param <E> + * The type of the returned value + * @param leftAction + * The action to apply to the left side + * @return The result of applying the action + */ + public <E> E applyToLeft(Function<AST<T>, E> leftAction) { + if (leftAction == null) { + throw new NullPointerException("Action must not be null"); + } + + return leftAction.apply(left); + } + + /** + * Apply an action to the right side of this AST + * + * @param <E> + * The type of the returned value + * @param rightAction + * The action to apply to the right side + * @return The result of applying the action + */ + public <E> E applyToRight(Function<AST<T>, E> rightAction) { + if (rightAction == null) { + throw new NullPointerException("Action must not be null"); + } + + return rightAction.apply(right); + } } |
