|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
edu.neu.ccs.quick.QuickHashtable
QuickHashtable extends Hashtable by
adding one constructor and three methods putPairs,
setPairs, and removeKeys that handle
an array of Object at once.
In addition, symmetric methods are added that will hash both a key to its value and a value to its key.
All constructors of the original Hashtable class
are provided as well.
The only inherited methods that are overridden are those that
will throw an exception on null arguments. In this
class, such methods will handle null in a sensible
fashion.
| Nested Class Summary |
| Nested classes inherited from class java.util.Hashtable |
|
| Field Summary |
| Fields inherited from class java.util.Hashtable |
|
| Constructor Summary | |
QuickHashtable()
A constructor that delegates to class Hashtable. |
|
QuickHashtable(int initialCapacity)
A constructor that delegates to class Hashtable. |
|
QuickHashtable(int initialCapacity,
float loadFactor)
A constructor that delegates to class Hashtable. |
|
QuickHashtable(Map m)
A constructor that delegates to class Hashtable. |
|
QuickHashtable(Object[][] pairs)
Constructor that adds the given 2-dimensional array of key-value pairs one-by-one to the hash table. |
|
| Method Summary | |
boolean |
contains(Object value)
Returns true if the hash table contains the value. |
boolean |
containsKey(Object key)
Returns true if the hash table contains the key. |
boolean |
containsValue(Object value)
Returns true if the hash table contains the value. |
Object |
get(Object key)
Returns the value to which the hash table maps the specified key. |
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this hash table. |
void |
putPairs(Object[][] pairs)
Method that adds the given 2-dimensional array of key-value pairs one-by-one to the hash table. |
void |
putPairsSymmetric(Object[][] pairs)
Method that adds the given 2-dimensional array of key-value pairs one-by-one symmetrically to the hash table. |
void |
putSymmetric(Object key,
Object value)
Method that adds the key-value pair symmetrically to the hash table, that is, the key maps to the value and the value maps to the key. |
Object |
remove(Object key)
Removes the mapping for this key from this hash table if present. |
void |
removeKeys(Object[] keys)
Method that removes the given array of keys one-by-one from the hash table. |
void |
setPairs(Object[][] pairs)
Method that first clears this hash table of any existing pairs and then adds the given array of pairs one-by-one to the hash table. |
void |
setPairsSymmetric(Object[][] pairs)
Method that first clears this hash table of any existing pairs and then adds the given array of pairs one-by-one symmetrically to the hash table. |
| Methods inherited from class java.util.Hashtable |
clear, clone, elements, entrySet, equals, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public QuickHashtable()
Hashtable.
public QuickHashtable(int initialCapacity)
Hashtable.
public QuickHashtable(int initialCapacity,
float loadFactor)
Hashtable.
public QuickHashtable(Map m)
Hashtable.
public QuickHashtable(Object[][] pairs)
Constructor that adds the given 2-dimensional array of key-value pairs one-by-one to the hash table.
Ignores key-value pairs in which either item is null.
The capacity is set either to 10 or to 1.5 times the length of the
array pairs whichever is larger.
The load factor is set to the default of 0.75.
pairs - the array of pairs to add to this hash tableputPairs(Object[][])| Method Detail |
public Object put(Object key,
Object value)
Associates the specified value with the specified key in this hash table. If the hash table previously contained a mapping for this key, the old value is replaced.
If the key or value is null, then simply returns
null.
key - the key associated with the specified valuevalue - the value to be associated with the specified key
Hashtable.put(Object, Object)public Object get(Object key)
Returns the value to which the hash table maps the specified key.
Returns null if the hash table contains no mapping for
the key.
If the key is null, then simply returns
null.
key - the key whose associated value is to be returned
Hashtable.get(Object)public Object remove(Object key)
Removes the mapping for this key from this hash table if present.
If the key is null, then simply returns
null.
key - the key whose mapping should be removed
Hashtable.remove(Object)public boolean containsKey(Object key)
Returns true if the hash table contains the key.
If the key is null, then simply returns
false.
key - the key whose presence in the hash table is to be tested
Hashtable.containsKey(Object)public boolean containsValue(Object value)
Returns true if the hash table contains the value.
If the value is null, then simply returns
false.
value - the value whose presence in the hash table is to be tested
Hashtable.containsValue(Object)public boolean contains(Object value)
Returns true if the hash table contains the value.
If the value is null, then simply returns
false.
value - the value whose presence in the hash table is to be tested
Hashtable.contains(Object)public void putPairs(Object[][] pairs)
Method that adds the given 2-dimensional array of key-value pairs one-by-one to the hash table.
If pairs is null, then does nothing.
Ignores any subarray pairs[i] that is null
or not of length 2.
Ignores key-value pairs in which either item is null.
pairs - the array of pairs to add to this hash tableQuickHashtable(Object[][]),
setPairs(Object[][]),
removeKeys(Object[]),
putSymmetric(Object, Object),
putPairsSymmetric(Object[][]),
setPairsSymmetric(Object[][])public void setPairs(Object[][] pairs)
Method that first clears this hash table of any existing pairs and then adds the given array of pairs one-by-one to the hash table.
If pairs is null, then this method
is equivalent to the inherited method clear.
Ignores any subarray pairs[i] that is null
or not of length 2.
Ignores key-value pairs in which either item is null.
pairs - the array of pairs to add to this hash table after clearanceputPairs(Object[][]),
removeKeys(Object[]),
putSymmetric(Object, Object),
putPairsSymmetric(Object[][]),
setPairsSymmetric(Object[][])public void removeKeys(Object[] keys)
Method that removes the given array of keys one-by-one from the hash table.
If keys is null, then does nothing.
Ignores key items that are null.
keys - the array of keys to remove from this hash tableputPairs(Object[][]),
setPairs(Object[][]),
putSymmetric(Object, Object),
putPairsSymmetric(Object[][]),
setPairsSymmetric(Object[][])
public void putSymmetric(Object key,
Object value)
Method that adds the key-value pair symmetrically to the hash table, that is, the key maps to the value and the value maps to the key.
Does nothing if the key or value is null.
key - the key in the key-value pairvalue - the value in the key-value pairputPairs(Object[][]),
setPairs(Object[][]),
removeKeys(Object[]),
putPairsSymmetric(Object[][]),
setPairsSymmetric(Object[][])public void putPairsSymmetric(Object[][] pairs)
Method that adds the given 2-dimensional array of key-value pairs one-by-one symmetrically to the hash table.
If pairs is null, then does nothing.
Ignores any subarray pairs[i] that is null
or not of length 2.
Ignores key-value pairs in which either item is null.
pairs - the array of pairs to add symmetrically to this hash tableputPairs(Object[][]),
setPairs(Object[][]),
removeKeys(Object[]),
putSymmetric(Object, Object),
setPairsSymmetric(Object[][])public void setPairsSymmetric(Object[][] pairs)
Method that first clears this hash table of any existing pairs and then adds the given array of pairs one-by-one symmetrically to the hash table.
If pairs is null, then this method
is equivalent to the inherited method clear.
Ignores any subarray pairs[i] that is null
or not of length 2.
Ignores key-value pairs in which either item is null.
pairs - the array of pairs to add symmetrically to this hash table
after clearanceputPairs(Object[][]),
setPairs(Object[][]),
removeKeys(Object[]),
putSymmetric(Object, Object),
putPairsSymmetric(Object[][])
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||