public interface Tree<K extends java.lang.Comparable<K>,V>
Modifier and Type | Method and Description |
---|---|
void |
addKeysToCollection(java.util.Collection<K> c)
Add all keys bound in this tree to the collection c.
|
Tree<K,V> |
delete(K key)
Delete any binding the key has in this tree.
|
NonEmptyTree<K,V> |
insert(K key,
V value)
Insert/update the Tree with a new key:value pair.
|
K |
max()
Return the maximum key in the subtree
|
K |
min()
Return the minimum key in the subtree
|
V |
search(K key)
Find the value that this key is bound to in this tree.
|
int |
size()
Return number of keys that are bound in this tree.
|
Tree<K,V> |
subTree(K fromKey,
K toKey)
Returns a Tree containing all entries between fromKey and toKey, inclusive
|
V search(K key)
key
- --
Key to search forNonEmptyTree<K,V> insert(K key, V value)
key
- --
Keyvalue
- --
Value that the key maps toTree<K,V> delete(K key)
key
- --
KeyK max() throws searchTree.TreeIsEmptyException
TreeIsEmptyException
- if the tree is emptyK min() throws searchTree.TreeIsEmptyException
TreeIsEmptyException
- if the tree is emptyint size()
void addKeysToCollection(java.util.Collection<K> c)
c
- -
A list that acts as an accumulator for keys. Keys
are inserted in the list in increasing order. You may not
use any sorting method or Collections.sort to keep the
list sorted.Tree<K,V> subTree(K fromKey, K toKey)
fromKey
- - Lower bound value for keys in subtreetoKey
- - Upper bound value for keys in subtree