All Packages Class Hierarchy This Package Previous Next Index
Class util.AVLTree
java.lang.Object
|
+----util.AVLTree
- public class AVLTree
- extends Object
- implements SimpleMap
A map implemented using an AVL tree.
-
AVLTree(Comparer)
- Construct empty tree.
-
containsKey(Object)
- Returns true if this map contains a key equal to this key.
-
get(Object)
- Returns the object associated with the given key or null if no
such key is stored.
-
isEmpty()
- Returns true if this map contains no key-value mappings.
-
main(String[])
- Test the tree.
-
put(Object, Object)
- Insert the given key-value pair into the map.
-
size()
- Return the number of keys currently stored.
-
toString()
- Convert tree to string.
AVLTree
public AVLTree(Comparer comparer)
- Construct empty tree. The comparer is used
to mainting to search tree property.
- Parameters:
- comparer - a comparer
isEmpty
public boolean isEmpty()
- Returns true if this map contains no key-value mappings.
- Returns:
- true if and only if this map contains no key-value mappings.
size
public int size()
- Return the number of keys currently stored.
- Returns:
- number of keys.
containsKey
public boolean containsKey(Object key)
- Returns true if this map contains a key equal to this key.
- Parameters:
- key - whose associated value is to be returned.
- Returns:
- true if and only if this map contains a key equal to this key.
get
public Object get(Object key)
- Returns the object associated with the given key or null if no
such key is stored. The object is not removed from the map.
Note: A return value of null does not necessarily mean that there
is no mapping for this key; it is also possible that the value
associated with the key is meant to be null. Use
containsKey
if you need to distinguish these two cases.
- Parameters:
- key - whose associated value is to be returned.
- Returns:
- the value to which this map maps the specified key, or null if the map contains no mapping for this key.
put
public void put(Object key,
Object value)
- Insert the given key-value pair into the map. If the map previously contained
a mapping for this key, the old value is replaced.
The value is allowed to be null whereas the key is not.
- Parameters:
- key - key with which the specified value is to be associated.
- value - value to be associated with the specified key.
- Throws: NullPointerException
- if key is null.
toString
public String toString()
- Convert tree to string.
- Returns:
- string.
- Overrides:
- toString in class Object
main
public static void main(String argv[])
- Test the tree.
- Parameters:
- argv - Elements to store in the tree.
All Packages Class Hierarchy This Package Previous Next Index