public class PolymorphicBST<K extends java.lang.Comparable<K>,V>
extends java.lang.Object
Constructor and Description |
---|
PolymorphicBST() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the tree by setting the root to EmptyTree
|
V |
get(K k)
Find the value the key is mapped to
|
K |
getMax()
Return the maximum key value in the map
|
K |
getMin()
Return the minimum key value in the map
|
int |
height()
Returns height of the tree.
|
void |
inorderTraversal(TraversalTask<K,V> p)
Performs an inorder traversal applying the task to eat tree key,value pair.
|
java.util.Set<K> |
keySet()
Return a Set of all the keys in the map
|
void |
put(K k,
V v)
Update the mapping for the key
|
void |
remove(K k)
Remove any existing binding for a key
|
void |
rightRootLeftTraversal(TraversalTask<K,V> p)
Performs the specified task on the tree using a right tree, root, left tree
traversal.
|
int |
size()
Return number of keys bound by this map
|
PolymorphicBST<K,V> |
subMap(K fromKey,
K toKey)
Return subset of TreeMap between the values fromKey-toKey.
|
java.lang.String |
toString()
Return a string representation of the tree.
|
public V get(K k)
k
- -
Search keypublic void put(K k, V v)
k
- -
key valuev
- -
value the key should be bound topublic int size()
public void remove(K k)
k
- -
key to be removed from the mappublic java.util.Set<K> keySet()
public K getMin()
java.util.NoSuchElementException
- if the map is emptypublic K getMax()
java.util.NoSuchElementException
- if the map is emptypublic java.lang.String toString()
toString
in class java.lang.Object
public PolymorphicBST<K,V> subMap(K fromKey, K toKey)
public void clear()
public int height()
public void inorderTraversal(TraversalTask<K,V> p)
p
- public void rightRootLeftTraversal(TraversalTask<K,V> p)
p
- object defining task