Package com.sun.corba.se.impl.util
Class IdentityHashtable
java.lang.Object
java.util.Dictionary
com.sun.corba.se.impl.util.IdentityHashtable
IdentityHashtable is a modified copy of the 1.1.6 Hashtable class which
does not rely on the hashCode() and equals() methods of the key or value;
instead, it uses the System.identityHashcode() method and pointer comparison.
In addition, all synchronization has been removed.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty hashtable with a default capacity and load factor.IdentityHashtable(int initialCapacity) Constructs a new, empty hashtable with the specified initial capacity and default load factor.IdentityHashtable(int initialCapacity, float loadFactor) Constructs a new, empty hashtable with the specified initial capacity and the specified load factor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears this hashtable so that it contains no keys.booleanTests if some key maps into the specified value in this hashtable.booleancontainsKey(Object key) Tests if the specified object is a key in this hashtable.elements()Returns an enumeration of the values in this hashtable.Returns the value to which the specified key is mapped in this hashtable.booleanisEmpty()Tests if this hashtable maps no keys to values.keys()Returns an enumeration of the keys in this hashtable.Maps the specifiedkeyto the specifiedvaluein this hashtable.protected voidrehash()Rehashes the contents of the hashtable into a hashtable with a larger capacity.Removes the key (and its corresponding value) from this hashtable.intsize()Returns the number of keys in this hashtable.toString()Returns a rather long string representation of this hashtable.
-
Constructor Details
-
IdentityHashtable
public IdentityHashtable(int initialCapacity, float loadFactor) Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.- Parameters:
initialCapacity- the initial capacity of the hashtable.loadFactor- a number between 0.0 and 1.0.- Throws:
IllegalArgumentException- if the initial capacity is less than or equal to zero, or if the load factor is less than or equal to zero.- Since:
- JDK1.0
-
IdentityHashtable
public IdentityHashtable(int initialCapacity) Constructs a new, empty hashtable with the specified initial capacity and default load factor.- Parameters:
initialCapacity- the initial capacity of the hashtable.- Since:
- JDK1.0
-
IdentityHashtable
public IdentityHashtable()Constructs a new, empty hashtable with a default capacity and load factor.- Since:
- JDK1.0
-
-
Method Details
-
size
public int size()Returns the number of keys in this hashtable.- Specified by:
sizein classDictionary- Returns:
- the number of keys in this hashtable.
- Since:
- JDK1.0
-
isEmpty
public boolean isEmpty()Tests if this hashtable maps no keys to values.- Specified by:
isEmptyin classDictionary- Returns:
trueif this hashtable maps no keys to values;falseotherwise.- Since:
- JDK1.0
-
keys
Returns an enumeration of the keys in this hashtable.- Specified by:
keysin classDictionary- Returns:
- an enumeration of the keys in this hashtable.
- Since:
- JDK1.0
- See Also:
-
elements
Returns an enumeration of the values in this hashtable. Use the Enumeration methods on the returned object to fetch the elements sequentially.- Specified by:
elementsin classDictionary- Returns:
- an enumeration of the values in this hashtable.
- Since:
- JDK1.0
- See Also:
-
contains
Tests if some key maps into the specified value in this hashtable. This operation is more expensive than thecontainsKeymethod.- Parameters:
value- a value to search for.- Returns:
trueif some key maps to thevalueargument in this hashtable;falseotherwise.- Throws:
NullPointerException- if the value isnull.- Since:
- JDK1.0
- See Also:
-
containsKey
Tests if the specified object is a key in this hashtable.- Parameters:
key- possible key.- Returns:
trueif the specified object is a key in this hashtable;falseotherwise.- Since:
- JDK1.0
- See Also:
-
get
Returns the value to which the specified key is mapped in this hashtable.- Specified by:
getin classDictionary- Parameters:
key- a key in the hashtable.- Returns:
- the value to which the key is mapped in this hashtable;
nullif the key is not mapped to any value in this hashtable. - Since:
- JDK1.0
- See Also:
-
rehash
protected void rehash()Rehashes the contents of the hashtable into a hashtable with a larger capacity. This method is called automatically when the number of keys in the hashtable exceeds this hashtable's capacity and load factor.- Since:
- JDK1.0
-
put
Maps the specifiedkeyto the specifiedvaluein this hashtable. Neither the key nor the value can benull.The value can be retrieved by calling the
getmethod with a key that is equal to the original key.- Specified by:
putin classDictionary- Parameters:
key- the hashtable key.value- the value.- Returns:
- the previous value of the specified key in this hashtable,
or
nullif it did not have one. - Throws:
NullPointerException- if the key or value isnull.- Since:
- JDK1.0
- See Also:
-
remove
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.- Specified by:
removein classDictionary- Parameters:
key- the key that needs to be removed.- Returns:
- the value to which the key had been mapped in this hashtable,
or
nullif the key did not have a mapping. - Since:
- JDK1.0
-
clear
public void clear()Clears this hashtable so that it contains no keys.- Since:
- JDK1.0
-
toString
Returns a rather long string representation of this hashtable.
-