Loading src/edu/bu/ec504/hw2/bst/BST.java +6 −4 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public class BST<keyType extends Comparable<keyType> > { */ public BST(keyType theKey) { this(); insert(theKey); add(theKey); } /** Loading @@ -112,7 +112,7 @@ public class BST<keyType extends Comparable<keyType> > { public BST(Iterable<keyType> keys) { this(); for (keyType key : keys) { insert(key); add(key); } } Loading Loading @@ -190,14 +190,15 @@ public class BST<keyType extends Comparable<keyType> > { * Inserts the new number as a key into the binary search tree * * @param newKey The new key to be inserted. * @return */ public void insert(keyType newKey) { public boolean add(keyType newKey) { searchRecord theRecord = searchHelper(newKey); if (theRecord == null) // insert here key = newKey; else if (theRecord.searchResult) // the item is already in the tree throw new IllegalStateException(newKey + " is already in this data structure"); return false; // newKey is already in this data structure else { // put into the appropriate child BST<keyType> lastSeen = theRecord.lastSeen; Loading @@ -206,6 +207,7 @@ public class BST<keyType extends Comparable<keyType> > { else lastSeen.leftChild = new BST<>(newKey); } return true; } // ... informational Loading src/edu/bu/ec504/hw2/bst/BSTSet.java +0 −8 Original line number Diff line number Diff line Loading @@ -50,14 +50,6 @@ public class BSTSet<keyType extends Comparable<keyType>> extends BST<keyType> im return null; } /** * @inheritDoc */ @Override public boolean add(keyType keyType) { return false; } /** * @inheritDoc */ Loading src/edu/bu/ec504/hw2/bst/ExtendedBSTSet.java +3 −2 Original line number Diff line number Diff line Loading @@ -30,10 +30,11 @@ public class ExtendedBSTSet<keyType extends Comparable<keyType>> extends BSTSet< /** * @inheritDoc * @return */ @Override public void insert(keyType newKey) { super.insert(newKey); public boolean add(keyType newKey) { return super.add(newKey); } /** Loading Loading
src/edu/bu/ec504/hw2/bst/BST.java +6 −4 Original line number Diff line number Diff line Loading @@ -100,7 +100,7 @@ public class BST<keyType extends Comparable<keyType> > { */ public BST(keyType theKey) { this(); insert(theKey); add(theKey); } /** Loading @@ -112,7 +112,7 @@ public class BST<keyType extends Comparable<keyType> > { public BST(Iterable<keyType> keys) { this(); for (keyType key : keys) { insert(key); add(key); } } Loading Loading @@ -190,14 +190,15 @@ public class BST<keyType extends Comparable<keyType> > { * Inserts the new number as a key into the binary search tree * * @param newKey The new key to be inserted. * @return */ public void insert(keyType newKey) { public boolean add(keyType newKey) { searchRecord theRecord = searchHelper(newKey); if (theRecord == null) // insert here key = newKey; else if (theRecord.searchResult) // the item is already in the tree throw new IllegalStateException(newKey + " is already in this data structure"); return false; // newKey is already in this data structure else { // put into the appropriate child BST<keyType> lastSeen = theRecord.lastSeen; Loading @@ -206,6 +207,7 @@ public class BST<keyType extends Comparable<keyType> > { else lastSeen.leftChild = new BST<>(newKey); } return true; } // ... informational Loading
src/edu/bu/ec504/hw2/bst/BSTSet.java +0 −8 Original line number Diff line number Diff line Loading @@ -50,14 +50,6 @@ public class BSTSet<keyType extends Comparable<keyType>> extends BST<keyType> im return null; } /** * @inheritDoc */ @Override public boolean add(keyType keyType) { return false; } /** * @inheritDoc */ Loading
src/edu/bu/ec504/hw2/bst/ExtendedBSTSet.java +3 −2 Original line number Diff line number Diff line Loading @@ -30,10 +30,11 @@ public class ExtendedBSTSet<keyType extends Comparable<keyType>> extends BSTSet< /** * @inheritDoc * @return */ @Override public void insert(keyType newKey) { super.insert(newKey); public boolean add(keyType newKey) { return super.add(newKey); } /** Loading