calypso.util
Class AtomHashtable

java.lang.Object
  |
  +--calypso.util.HashtableBase
        |
        +--calypso.util.AtomHashtable

public class AtomHashtable
extends calypso.util.HashtableBase

Special hashtable that uses Atoms as keys. This extends HashtableBase to expose a public Atom based api This hastable uses identity comparisons on keys

See Also:

Constructor Summary
AtomHashtable()
          Constructs an empty Hashtable.
AtomHashtable(int aInitialCapacity)
          Constructs a Hashtable capable of holding at least initialCapacity elements before needing to grow.
 
Method Summary
 boolean contains(java.lang.Object aElement)
          Returns true if the Hashtable contains the element.
 boolean containsKey(Atom aKey)
          Returns true if the Hashtable contains the key key.
 java.lang.Object[] elementsArray()
          Returns an Object array containing the Hashtable's elements.
 java.lang.Object get(Atom aKey)
          Returns the element associated with the key.
 Atom[] keysArray()
          Returns an Object array containing the Hashtable's keys.
 java.lang.Object put(Atom aKey, java.lang.Object aElement)
          Places the key/element pair in the Hashtable.
 java.lang.Object remove(Atom aKey)
          Removes key and the element associated with it from the Hashtable.
 
Methods inherited from class calypso.util.HashtableBase
clear, clone, count, elements, elementsVector, grow, isEmpty, keys, keysVector, size, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AtomHashtable

public AtomHashtable()
Constructs an empty Hashtable. The Hashtable will grow on demand as more elements are added.

AtomHashtable

public AtomHashtable(int aInitialCapacity)
Constructs a Hashtable capable of holding at least initialCapacity elements before needing to grow.
Method Detail

keysArray

public Atom[] keysArray()
Returns an Object array containing the Hashtable's keys.

elementsArray

public java.lang.Object[] elementsArray()
Returns an Object array containing the Hashtable's elements.

contains

public boolean contains(java.lang.Object aElement)
Returns true if the Hashtable contains the element. This method is slow -- O(n) -- because it must scan the table searching for the element.

containsKey

public boolean containsKey(Atom aKey)
Returns true if the Hashtable contains the key key.

get

public java.lang.Object get(Atom aKey)
Returns the element associated with the key. This method returns null if the Hashtable does not contain key. Hashtable hashes and compares key using hashCode() and equals().

remove

public java.lang.Object remove(Atom aKey)
Removes key and the element associated with it from the Hashtable. Returns the element associated with key, or null if key was not present.

put

public java.lang.Object put(Atom aKey,
                            java.lang.Object aElement)
Places the key/element pair in the Hashtable. Neither key nor element may be null. Returns the old element associated with key, or null if the key was not present.