DCT Lightfoot v3 API specification

java.util
Class Hashtable

java.lang.Object
  |
  +--java.util.Hashtable

public class Hashtable
extends Object

This implements a hashtable, which maps keys/value pairs.
Any non-null Objects may be used as keys or values.
This hashtable does not do any rehashing


Constructor Summary
Hashtable()
          Create a new hashtable with the default capacity.
Hashtable(int cap)
          Creates a new hashtable the given starting capacity
 
Method Summary
 void clear()
          Clears this hashtable.
 boolean contains(Object value)
          Tests if the given value exists in the Hashtable.
 boolean containsKey(Object key)
          Tests if the specified object is a key in this hashtable.
 Enumeration elements()
          Returns an enumeration of the values in this hashtable.
 Object get(Object key)
          Returns the value mapped to the given key
 boolean isEmpty()
          See if the table is empty
 Enumeration keys()
          Returns an enumeration of the keys in this hashtable.
 Object put(Object key, Object value)
          Maps a key to a value.
 Object remove(Object key)
          Removes the key (and its corresponding value) from this hashtable.
 int size()
          Returns the number of keys in the hashtable.
 java.lang.String toString()
          Returns a rather long string representation of this hashtable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hashtable

public Hashtable()
Create a new hashtable with the default capacity.


Hashtable

public Hashtable(int cap)
Creates a new hashtable the given starting capacity

Parameters:
cap - the initial capacity of the hashtable.
Throws:
IllegalArgumentException - if the initial capacity is less than zero
Method Detail

clear

public void clear()
Clears this hashtable.


contains

public boolean contains(Object value)
Tests if the given value exists in the Hashtable. This is an extremely expensive operation, so if you have access to the key you should always try to get the value using get() and test if the value is null.

Parameters:
value - a value to search for.
Returns:
true if the value exists in the table false otherwise.
Throws:
NullPointerException - if the value is null.

containsKey

public boolean containsKey(Object key)
Tests if the specified object is a key in this hashtable.

Parameters:
key - possible key.
Returns:
true if the specified object is a key in this hashtable; false otherwise.

elements

public Enumeration elements()
Returns an enumeration of the values in this hashtable. Use the Enumeration methods on the returned object to fetch the elements sequentially.

Returns:
an enumeration of the values in this hashtable.

get

public Object get(Object key)
Returns the value mapped to the given key

Parameters:
key - a key in the hashtable.
Returns:
the associated value or null if no mapping was found

isEmpty

public boolean isEmpty()
See if the table is empty

Returns:
true if this hashtable is empty, false otherwise

keys

public Enumeration keys()
Returns an enumeration of the keys in this hashtable.

Returns:
an enumeration of the keys in this hashtable.

put

public Object put(Object key,
                  Object value)
Maps a key to a value. Neither the key nor the value can be null. The value can be retrieved by calling the get(Object key) method with a key that is equal to the original key.

Parameters:
key - the hashtable key.
value - the value.
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one.
Throws:
NullPointerException - if the key or value is null.

remove

public Object remove(Object key)
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

size

public int size()
Returns the number of keys in the hashtable.

Returns:
the number of keys in the hashtable.

toString

public java.lang.String toString()
Returns a rather long string representation of this hashtable.
Don't call this method unless you absolutely have to, it will create tons of garbage, and how useful is it really

Overrides:
toString in class Object
Returns:
a string representation of this hashtable.

DCT Lightfoot v3 API specification

DCT Lightfoot v3 API specification