public class BinarySearchTree<K,V> extends LinkedBinaryTree<Entry<K,V>> implements Dictionary<K,V>
| Constructor and Description |
|---|
BinarySearchTree()
Creates a BinarySearchTree with a default comparator.
|
BinarySearchTree(java.util.Comparator<K> c)
Creates a BinarySearchTree with the given comparator.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Iterable<Entry<K,V>> |
entries()
Returns an iterator containing all entries in the tree.
|
Entry<K,V> |
find(K key)
Returns an entry containing the given key.
|
java.lang.Iterable<Entry<K,V>> |
findAll(K key)
Returns an iterable collection of all the entries containing the
given key.
|
Entry<K,V> |
insert(K k,
V x)
Inserts an entry into the tree and returns the newly created entry.
|
boolean |
isEmpty()
Returns whether the tree is empty.
|
Entry<K,V> |
remove(Entry<K,V> ent)
Removes and returns a given entry.
|
int |
size()
Returns the number of entries in the tree.
|
addRoot, attach, children, expandExternal, hasLeft, hasRight, insertLeft, insertRight, isExternal, isInternal, isRoot, iterator, left, parent, positions, remove, removeAboveExternal, replace, right, root, sibling, swapElementspublic BinarySearchTree()
public BinarySearchTree(java.util.Comparator<K> c)
public java.lang.Iterable<Entry<K,V>> entries()
entries in interface Dictionary<K,V>public Entry<K,V> find(K key) throws InvalidKeyException
find in interface Dictionary<K,V>InvalidKeyExceptionpublic java.lang.Iterable<Entry<K,V>> findAll(K key) throws InvalidKeyException
findAll in interface Dictionary<K,V>InvalidKeyExceptionpublic Entry<K,V> insert(K k, V x) throws InvalidKeyException
insert in interface Dictionary<K,V>InvalidKeyExceptionpublic boolean isEmpty()
public Entry<K,V> remove(Entry<K,V> ent) throws InvalidEntryException
remove in interface Dictionary<K,V>InvalidEntryException