diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-03 19:22:48 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-03 19:22:48 -0400 |
| commit | 1c8bc7132d980c1ff2dbd6b9af579c3b2fd8c63e (patch) | |
| tree | a29777f07ebd81fbef61b5ae02f13f1a9d8f65a2 /BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java | |
| parent | a023de85aa08c8f2b8b2441c6b14064eabee2775 (diff) | |
General code refactoring and maintenance
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java index ec0e4df..fa92f85 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java +++ b/BJC-Utils2/src/main/java/bjc/utils/funcdata/bst/BinarySearchTree.java @@ -39,6 +39,10 @@ public class BinarySearchTree<T> { * The thing to use for comparing elements */ public BinarySearchTree(Comparator<T> cmp) { + if (cmp == null) { + throw new NullPointerException("Comparator must not be null"); + } + elementCount = 0; comparator = cmp; } @@ -169,6 +173,13 @@ public class BinarySearchTree<T> { */ public void traverse(TreeLinearizationMethod linearizationMethod, Predicate<T> traversalPredicate) { + if (linearizationMethod == null) { + throw new NullPointerException( + "Linearization method must not be null"); + } else if (traversalPredicate == null) { + throw new NullPointerException("Predicate must not be nulls"); + } + rootElement.forEach(linearizationMethod, traversalPredicate); } |
