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.


Constructor Index

 o AVLTree(Comparer)
Construct empty tree.

Method Index

 o containsKey(Object)
Returns true if this map contains a key equal to this key.
 o get(Object)
Returns the object associated with the given key or null if no such key is stored.
 o isEmpty()
Returns true if this map contains no key-value mappings.
 o main(String[])
Test the tree.
 o put(Object, Object)
Insert the given key-value pair into the map.
 o size()
Return the number of keys currently stored.
 o toString()
Convert tree to string.

Constructors

 o AVLTree
 public AVLTree(Comparer comparer)
Construct empty tree. The comparer is used to mainting to search tree property.

Parameters:
comparer - a comparer

Methods

 o 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.
 o size
 public int size()
Return the number of keys currently stored.

Returns:
number of keys.
 o 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.
 o 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.
 o 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.
 o toString
 public String toString()
Convert tree to string.

Returns:
string.
Overrides:
toString in class Object
 o 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