Class Hashtable
All Packages Class Hierarchy This Package Previous Next Index
Class Hashtable
public class netscape.util.Hashtable
extends java.lang.Object
implements java.lang.Cloneable,
netscape.util.Codable
{
/* Constructors
*/
public Hashtable();
public Hashtable(int);
/* Methods
*/
public void clear();
public Object clone();
public boolean contains(Object);
public boolean containsKey(Object);
public int count();
public void decode(Decoder);
public void describeClassInfo(ClassInfo);
public Enumeration elements();
public Object[] elementsArray();
public Vector elementsVector();
public void encode(Encoder);
public void finishDecoding();
public Object get(Object);
public boolean isEmpty();
public Enumeration keys();
public Object[] keysArray();
public Vector keysVector();
public Object put(Object, Object);
public Object remove(Object);
public int size();
public String toString();
}
Object subclass that implements a hash table.
Constructors
.Hashtable
public Hashtable()
- Constructs an empty Hashtable. The Hashtable will grow on demand
as more elements are added.
.Hashtable
public Hashtable(int initialCapacity)
- Constructs a Hashtable capable of holding at least
initialCapacity elements before needing to grow.
Methods
public Object clone()
- Creates a shallow copy of the Hashtable. The table itself is cloned,
but none of the keys or elements are copied.
- Overrides:
- clone in class Object
public int count()
- Returns the number of elements in the Hashtable.
public int size()
- Returns the number of elements in the Hashtable.
public boolean isEmpty()
- Returns true if there are no elements in the Hashtable.
public Enumeration keys()
- Returns an Enumeration of the Hashtable's keys.
- See Also:
- elements
public Enumeration elements()
- Returns an Enumeration of the Hashtable's elements.
- See Also:
- keys
public Vector keysVector()
- Returns a Vector containing the Hashtable's keys.
public Vector elementsVector()
- Returns a Vector containing the Hashtable's elements.
public Object[] keysArray()
- Returns an Object array containing the Hashtable's keys.
public Object[] elementsArray()
- Returns an Object array containing the Hashtable's elements.
public boolean contains(Object element)
- Returns true if the Hashtable contains the element. This method
is slow -- O(n) -- because it must scan the table searching for the
element.
public boolean containsKey(Object key)
- Returns true if the Hashtable contains the key key.
public Object get(Object key)
- 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().
public Object remove(Object key)
- Removes key and the element associated with it from the
Hashtable. Returns the element associated with key, or
null if key was not present.
public Object put(Object key,
Object element)
- 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.
public void clear()
- Removes all keys and elements from the Hashtable.
public String toString()
- Returns a string serialization of the Hashtable using the
Serializer.
- Overrides:
- toString in class Object
- See Also:
- Serializer
public void describeClassInfo(ClassInfo info)
- Describes the Hashtable class' information.
- See Also:
- describeClassInfo
public void encode(Encoder encoder) throws CodingException
- Encodes the Hashtable instance. All the keys and elements must be
Codable.
- See Also:
- encode
public void decode(Decoder decoder) throws CodingException
- Decodes the Hashtable instance.
- See Also:
- decode
public void finishDecoding() throws CodingException
- Finishes the Hashtable's decoding.
- See Also:
- finishDecoding
All Packages Class Hierarchy This Package Previous Next Index
Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Oct 1997