util
Class DupHashtable

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--util.DupHashtable
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class DupHashtable
extends java.util.Dictionary
implements java.lang.Cloneable, java.io.Serializable

This class implements a Hashtable, which allows to store the same key several times. More see: java.util.Hashtable

See Also:
Serialized Form

Constructor Summary
DupHashtable()
          Constructs a new, empty DupHashtable with a default capacity and load factor.
DupHashtable(int initialCapacity)
          Constructs a new, empty DupHashtable with the specified initial capacity and default load factor.
DupHashtable(int initialCapacity, float loadFactor)
          Constructs a new, empty DupHashtable with the specified initial capacity and the specified load factor.
 
Method Summary
 void clear()
          Clears this DupHashtable so that it contains no keys.
 java.lang.Object clone()
          Creates a shallow copy of this DupHashtable.
 boolean contains(java.lang.Object value)
          Tests if some key maps into the specified value in this DupHashtable.
 boolean containsKey(java.lang.Object key)
          Tests if the specified object is a key in this DupHashtable.
 java.util.Enumeration elements()
          Returns an enumeration of the values in this DupHashtable.
 java.lang.Object get(java.lang.Object key)
          Returns the value to which the specified key is mapped in this DupHashtable.
 java.lang.Object getNext(java.lang.Object key)
          Returns the value to which the specified key is mapped in this DupHashtable.
 boolean isEmpty()
          Tests if this DupHashtable maps no keys to values.
 java.util.Enumeration keys()
          Returns an enumeration of the keys in this DupHashtable.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this DupHashtable.
protected  void rehash()
          Rehashes the contents of the DupHashtable into a DupHashtable with a larger capacity.
 java.lang.Object remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this DupHashtable.
 int size()
          Returns the number of keys in this DupHashtable.
 java.lang.String toString()
          Returns a rather long string representation of this DupHashtable.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DupHashtable

public DupHashtable()
Constructs a new, empty DupHashtable with a default capacity and load factor.


DupHashtable

public DupHashtable(int initialCapacity)
Constructs a new, empty DupHashtable with the specified initial capacity and default load factor.

Parameters:
initialCapacity - the initial capacity of the DupHashtable.

DupHashtable

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

Parameters:
initialCapacity - the initial capacity of the DupHashtable.
loadFactor - a number between 0.0 and 1.0.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than or equal to zero, or if the load factor is less than or equal to zero.
Method Detail

clear

public void clear()
Clears this DupHashtable so that it contains no keys.


clone

public java.lang.Object clone()
Creates a shallow copy of this DupHashtable. The keys and values themselves are not cloned. This is a relatively expensive operation.

Overrides:
clone in class java.lang.Object
Returns:
a clone of the DupHashtable.

contains

public boolean contains(java.lang.Object value)
Tests if some key maps into the specified value in this DupHashtable. This operation is more expensive than the containsKey method.

Parameters:
value - a value to search for.
Returns:
true if some key maps to the value argument in this DupHashtable; false otherwise.
Throws:
java.lang.NullPointerException - if the value is null.
See Also:
containsKey(java.lang.Object)

containsKey

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

Parameters:
key - possible key.
Returns:
true if the specified object is a key in this DupHashtable; false otherwise.
See Also:
contains(java.lang.Object)

elements

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

Specified by:
elements in class java.util.Dictionary
Returns:
an enumeration of the values in this DupHashtable.
See Also:
Enumeration, keys()

get

public java.lang.Object get(java.lang.Object key)
Returns the value to which the specified key is mapped in this DupHashtable.

Specified by:
get in class java.util.Dictionary
Parameters:
key - a key in the DupHashtable.
Returns:
the value to which the key is mapped in this DupHashtable; null if the key is not mapped to any value in this DupHashtable.

getNext

public java.lang.Object getNext(java.lang.Object key)
Returns the value to which the specified key is mapped in this DupHashtable.

Parameters:
key - a key in the DupHashtable.
Returns:
the value to which the key is mapped in this DupHashtable; null if the key is not mapped to any value in this DupHashtable.

isEmpty

public boolean isEmpty()
Tests if this DupHashtable maps no keys to values.

Specified by:
isEmpty in class java.util.Dictionary
Returns:
true if this DupHashtable maps no keys to values; false otherwise.

keys

public java.util.Enumeration keys()
Returns an enumeration of the keys in this DupHashtable.

Specified by:
keys in class java.util.Dictionary
Returns:
an enumeration of the keys in this DupHashtable.
See Also:
Enumeration, elements()

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Maps the specified key to the specified value in this DupHashtable. Neither the key nor the value can be null.

Specified by:
put in class java.util.Dictionary
Parameters:
key - the key.
value - the value.
Returns:
the previous value of the specified key in this DupHashtable, or null if it did not have one.
Throws:
java.lang.NullPointerException - if the key or value is null.

rehash

protected void rehash()
Rehashes the contents of the DupHashtable into a DupHashtable with a larger capacity. This method is called automatically when the number of keys in the DupHashtable exceeds this DupHashtable's capacity and load factor.


remove

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

Specified by:
remove in class java.util.Dictionary
Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this DupHashtable, or null if the key did not have a mapping.

size

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

Specified by:
size in class java.util.Dictionary
Returns:
the number of keys in this DupHashtable.

toString

public java.lang.String toString()
Returns a rather long string representation of this DupHashtable.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this DupHashtable.