|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectsearchTree.EmptyTree<K,V>
public class EmptyTree<K extends java.lang.Comparable<K>,V>
This class is used to represent the empty search tree: a search tree that contains no entries. This class is a singleton class: since all empty search trees are the same, there is no need for multiple instances of this class. Instead, a single instance of the class is created and made available through the static field SINGLETON. The constructor is private, preventing other code from mistakenly creating addditional instances of the class.
| Method Summary | |
|---|---|
void |
addKeysToList(java.util.List<K> s)
Add all keys bound in this tree to the list l |
void |
addKeysToSet(java.util.Set<K> s)
Add all keys bound in this tree to the set S |
Tree<K,V> |
delete(K key)
Delete any binding the key has in this tree. |
static EmptyTree |
getInstance()
|
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, or null if the subtree contains no key-value mappings |
K |
min()
Return the minmum key in the subtree, or null if the subtree contains no key-value mappings |
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. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static EmptyTree getInstance()
public V search(K key)
Tree
search in interface Tree<K extends java.lang.Comparable<K>,V>key - --
Key to search for
public NonEmptyTree<K,V> insert(K key,
V value)
Tree
insert in interface Tree<K extends java.lang.Comparable<K>,V>key - --
Keyvalue - --
Value that the key maps to
public Tree<K,V> delete(K key)
Tree
delete in interface Tree<K extends java.lang.Comparable<K>,V>key - --
Key
public K max()
Tree
max in interface Tree<K extends java.lang.Comparable<K>,V>public K min()
Tree
min in interface Tree<K extends java.lang.Comparable<K>,V>public int size()
Tree
size in interface Tree<K extends java.lang.Comparable<K>,V>public void addKeysToSet(java.util.Set<K> s)
Tree
addKeysToSet in interface Tree<K extends java.lang.Comparable<K>,V>s - -
A set that acts as an accumulator for keyspublic void addKeysToList(java.util.List<K> s)
Tree
addKeysToList in interface Tree<K extends java.lang.Comparable<K>,V>s - -
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||