org.apache.bsf.debug.util
Class IntHashtable

java.lang.Object
  extended byorg.apache.bsf.debug.util.IntHashtable
All Implemented Interfaces:
java.lang.Cloneable

public class IntHashtable
extends java.lang.Object
implements java.lang.Cloneable

Hashtable associates keys with values. Keys and values cannot be null. The size of the Hashtable is the number of key/value pairs it contains. The capacity is the number of key/value pairs the Hashtable can hold. The load factor is a float value which determines how full the Hashtable gets before expanding the capacity. If the load factor of the Hashtable is exceeded, the capacity is doubled.

Author:
OTI
See Also:
Enumeration, Serializable, Object.equals(java.lang.Object), Object.hashCode()

Constructor Summary
IntHashtable()
          Constructs a new Hashtable using the default capacity and load factor.
IntHashtable(int capacity)
          Constructs a new IntHashtable using the specified capacity and the default load factor.
IntHashtable(int capacity, float loadFactor)
          Constructs a new IntHashtable using the specified capacity and load factor.
 
Method Summary
 void clear()
          Removes all key/value pairs from this IntHashtable, leaving the size zero and the capacity unchanged.
 java.lang.Object clone()
          Answers a new IntHashtable with the same key/value pairs, capacity and load factor.
 boolean contains(java.lang.Object value)
          Answers if this Hashtable contains the specified object as the value of at least one of the key/value pairs.
 boolean containsKey(int key)
          Answers if this Hashtable contains the specified object as a key of one of the key/value pairs.
 java.util.Enumeration elements()
          Answers an Enumeration on the values of this Hashtable.
 java.lang.Object get(int key)
          Answers the value associated with the specified key in this Hashtable.
 boolean isEmpty()
          Answers if this Hashtable has no key/value pairs, a size of zero.
 java.lang.Object put(int key, java.lang.Object value)
          Associate the specified value with the specified key in this Hashtable.
protected  void rehash()
          Increases the capacity of this Hashtable.
 java.lang.Object remove(int key)
          Remove the key/value pair with the specified key from this Hashtable.
 int size()
          Answers the number of key/value pairs in this Hashtable.
 java.lang.String toString()
          Answers the string representation of this Hashtable.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntHashtable

public IntHashtable()
Constructs a new Hashtable using the default capacity and load factor.


IntHashtable

public IntHashtable(int capacity)
Constructs a new IntHashtable using the specified capacity and the default load factor.

Parameters:
capacity - the initial capacity

IntHashtable

public IntHashtable(int capacity,
                    float loadFactor)
Constructs a new IntHashtable using the specified capacity and load factor.

Parameters:
capacity - the initial capacity
loadFactor - the initial load factor
Method Detail

clear

public void clear()
Removes all key/value pairs from this IntHashtable, leaving the size zero and the capacity unchanged.

See Also:
isEmpty(), size()

clone

public java.lang.Object clone()
Answers a new IntHashtable with the same key/value pairs, capacity and load factor.

Returns:
a shallow copy of this IntHashtable
See Also:
Cloneable

contains

public boolean contains(java.lang.Object value)
Answers if this Hashtable contains the specified object as the value of at least one of the key/value pairs.

Parameters:
value - the object to look for as a value in this Hashtable
Returns:
true if object is a value in this Hashtable, false otherwise
See Also:
containsKey(int), Object.equals(java.lang.Object)

containsKey

public boolean containsKey(int key)
Answers if this Hashtable contains the specified object as a key of one of the key/value pairs.

Parameters:
key - the object to look for as a key in this Hashtable
Returns:
true if object is a key in this Hashtable, false otherwise
See Also:
contains(java.lang.Object), Object.equals(java.lang.Object)

elements

public java.util.Enumeration elements()
Answers an Enumeration on the values of this Hashtable. The results of the Enumeration may be affected if the contents of this Hashtable are modified.

Returns:
an Enumeration of the values of this Hashtable
See Also:
#keys, size(), Enumeration

get

public java.lang.Object get(int key)
Answers the value associated with the specified key in this Hashtable.

Parameters:
key - the key of the value returned
Returns:
the value associated with the specified key, null if the specified key does not exist
See Also:
put(int, java.lang.Object)

isEmpty

public boolean isEmpty()
Answers if this Hashtable has no key/value pairs, a size of zero.

Returns:
true if this Hashtable has no key/value pairs, false otherwise
See Also:
size()

put

public java.lang.Object put(int key,
                            java.lang.Object value)
Associate the specified value with the specified key in this Hashtable. If the key already exists, the old value is replaced. The key and value cannot be null.

Parameters:
key - the key to add
value - the value to add
Returns:
the old value associated with the specified key, null if the key did not exist
See Also:
elements(), get(int), #keys, Object.equals(java.lang.Object)

rehash

protected void rehash()
Increases the capacity of this Hashtable. This method is sent when the size of this Hashtable exceeds the load factor.


remove

public java.lang.Object remove(int key)
Remove the key/value pair with the specified key from this Hashtable.

Parameters:
key - the key to remove
Returns:
the value associated with the specified key, null if the specified key did not exist
See Also:
get(int), put(int, java.lang.Object)

size

public int size()
Answers the number of key/value pairs in this Hashtable.

Returns:
the number of key/value pairs in this Hashtable
See Also:
elements(), #keys

toString

public java.lang.String toString()
Answers the string representation of this Hashtable.

Returns:
the string representation of this Hashtable