|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectsearchTree.NonEmptyTree<K,V>
public class NonEmptyTree<K extends java.lang.Comparable<K>,V>
This class represents a non-empty search tree. An instance of this class should contain:
| Constructor Summary | |
|---|---|
NonEmptyTree()
|
|
| Method Summary | |
|---|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NonEmptyTree()
| Method Detail |
|---|
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
@NonNull public K max()
Tree
max in interface Tree<K extends java.lang.Comparable<K>,V>@NonNull 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 addKeysToCollection(java.util.Collection<K> c)
Tree
addKeysToCollection in interface Tree<K extends java.lang.Comparable<K>,V>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.
public Tree<K,V> subTree(K fromKey,
K toKey)
Tree
subTree in interface Tree<K extends java.lang.Comparable<K>,V>fromKey - - Lower bound value for keys in subtreetoKey - - Upper bound value for keys in subtree
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||