You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



All Packages  This Package  Class Hierarchy  Class Search  Index

Class calypso.util.AtomHashtable

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

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:


public class  AtomHashtable
     extends calypso.util.HashtableBase
{
          // Constructors 2
     public AtomHashtable();
     public AtomHashtable(int);

          // Methods 10
     public boolean contains(Object);
     public boolean containsKey(Atom);
     public Object[] elementsArray();
     public Object get(Atom);
     int hash(Atom);
     int hash(Object);
     public Atom[] keysArray();
     public Object put(Atom, Object);
     public Object remove(Atom);
     int tableIndexFor(Object, int);
}



Constructors


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.




Methods


keysArray

   public Atom[] keysArray() 

Returns an Object array containing the Hashtable's keys.



elementsArray

   public Object[] elementsArray() 

Returns an Object array containing the Hashtable's elements.



contains

   public boolean contains(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 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 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 Object put(Atom aKey, 
                     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.



hash

   int hash(Object aKey) 
Overrides:
hash in class HashtableBase


hash

   int hash(Atom aKey) 


tableIndexFor

   int tableIndexFor(Object aKey, 
                     int aHash) 

Primitive method used internally to find slots in the table. If the key is present in the table, this method will return the index under which it is stored. If the key is not present, then this method will return the index under which it can be put. The caller must look at the hashCode at that index to differentiate between the two possibilities.

Overrides:
tableIndexFor in class HashtableBase


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4