All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Acme.IntHashtable

java.lang.Object
   |
   +----java.util.Dictionary
           |
           +----Acme.IntHashtable

public class IntHashtable
extends Dictionary
implements Cloneable
A Hashtable that uses ints as the keys.

Use just like java.util.Hashtable, except that the keys must be ints. This is much faster than creating a new Integer for each access.

Fetch the software.
Fetch the entire Acme package.

See Also:
Hashtable

Constructor Index

 o IntHashtable()
Constructs a new, empty hashtable.
 o IntHashtable(int)
Constructs a new, empty hashtable with the specified initial capacity.
 o IntHashtable(int, float)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.

Method Index

 o clear()
Clears the hash table so that it has no more elements in it.
 o clone()
Creates a clone of the hashtable.
 o contains(Object)
Returns true if the specified object is an element of the hashtable.
 o containsKey(int)
Returns true if the collection contains an element for the key.
 o elements()
Returns an enumeration of the elements.
 o get(int)
Gets the object associated with the specified key in the hashtable.
 o get(Object)
A get method that takes an Object, for compatibility with java.util.Dictionary.
 o isEmpty()
Returns true if the hashtable contains no elements.
 o keys()
Returns an enumeration of the hashtable's keys.
 o put(int, Object)
Puts the specified element into the hashtable, using the specified key.
 o put(Object, Object)
A put method that takes an Object, for compatibility with java.util.Dictionary.
 o rehash()
Rehashes the content of the table into a bigger table.
 o remove(int)
Removes the element corresponding to the key.
 o remove(Object)
A remove method that takes an Object, for compatibility with java.util.Dictionary.
 o size()
Returns the number of elements contained in the hashtable.
 o toString()
Converts to a rather lengthy String.

Constructors

 o IntHashtable
 public IntHashtable(int initialCapacity,
                     float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.

Parameters:
initialCapacity - the initial number of buckets
loadFactor - a number between 0.0 and 1.0, it defines the threshold for rehashing the hashtable into a bigger one.
Throws: IllegalArgumentException
If the initial capacity is less than or equal to zero.
Throws: IllegalArgumentException
If the load factor is less than or equal to zero.
 o IntHashtable
 public IntHashtable(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity.

Parameters:
initialCapacity - the initial number of buckets
 o IntHashtable
 public IntHashtable()
Constructs a new, empty hashtable. A default capacity and load factor is used. Note that the hashtable will automatically grow when it gets full.

Methods

 o size
 public int size()
Returns the number of elements contained in the hashtable.

Overrides:
size in class Dictionary
 o isEmpty
 public boolean isEmpty()
Returns true if the hashtable contains no elements.

Overrides:
isEmpty in class Dictionary
 o keys
 public synchronized Enumeration keys()
Returns an enumeration of the hashtable's keys.

Overrides:
keys in class Dictionary
See Also:
elements
 o elements
 public synchronized Enumeration elements()
Returns an enumeration of the elements. Use the Enumeration methods on the returned object to fetch the elements sequentially.

Overrides:
elements in class Dictionary
See Also:
keys
 o contains
 public synchronized boolean contains(Object value)
Returns true if the specified object is an element of the hashtable. This operation is more expensive than the containsKey() method.

Parameters:
value - the value that we are looking for
Throws: NullPointerException
If the value being searched for is equal to null.
See Also:
containsKey
 o containsKey
 public synchronized boolean containsKey(int key)
Returns true if the collection contains an element for the key.

Parameters:
key - the key that we are looking for
See Also:
contains
 o get
 public synchronized Object get(int key)
Gets the object associated with the specified key in the hashtable.

Parameters:
key - the specified key
Returns:
s the element for the key or null if the key is not defined in the hash table.
See Also:
put
 o get
 public Object get(Object okey)
A get method that takes an Object, for compatibility with java.util.Dictionary. The Object must be an Integer.

Overrides:
get in class Dictionary
 o rehash
 protected void rehash()
Rehashes the content of the table into a bigger table. This method is called automatically when the hashtable's size exceeds the threshold.

 o put
 public synchronized Object put(int key,
                                Object value)
Puts the specified element into the hashtable, using the specified key. The element may be retrieved by doing a get() with the same key. The key and the element cannot be null.

Parameters:
key - the specified key in the hashtable
value - the specified element
Returns:
the old value of the key, or null if it did not have one.
Throws: NullPointerException
If the value of the element is equal to null.
See Also:
get
 o put
 public Object put(Object okey,
                   Object value)
A put method that takes an Object, for compatibility with java.util.Dictionary. The Object must be an Integer.

Overrides:
put in class Dictionary
 o remove
 public synchronized Object remove(int key)
Removes the element corresponding to the key. Does nothing if the key is not present.

Parameters:
key - the key that needs to be removed
Returns:
the value of key, or null if the key was not found.
 o remove
 public Object remove(Object okey)
A remove method that takes an Object, for compatibility with java.util.Dictionary. The Object must be an Integer.

Overrides:
remove in class Dictionary
 o clear
 public synchronized void clear()
Clears the hash table so that it has no more elements in it.

 o clone
 public synchronized Object clone()
Creates a clone of the hashtable. A shallow copy is made, the keys and elements themselves are NOT cloned. This is a relatively expensive operation.

Overrides:
clone in class Object
 o toString
 public synchronized String toString()
Converts to a rather lengthy String.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index

ACME Java  ACME Labs