diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-04 14:16:48 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-04 14:16:48 -0400 |
| commit | 4355418164c44170cfb329fcbb7e6f1358c0e314 (patch) | |
| tree | 0a980e4a821b2f69ea7cee35f75d5fa52ff53490 /BJC-Utils2/src/main/java/bjc/utils | |
| parent | 73d1ba7a3a4c3c1df4863861cbf71ddf85ccb7d3 (diff) | |
Minor changes
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils')
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); + } } |
