|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstructure.Hashtable
public class Hashtable
Implements a dictionary as a table of hashed key-value pairs. Collisions are resolved through linear probing. Values used as keys in this structure must have a hashcode method that returns the same value when two keys are "equals". Initially, a table of suggested size is allocated. It will be expanded as the load factor (ratio of pairs to entries) grows.
ChainedHashtable
Field Summary | |
---|---|
protected int |
capacity
The size of the hashtable |
protected int |
count
The number of key-value pairs in table. |
protected Association[] |
data
The data associated with the hashtable. |
protected double |
loadFactor
Load factor that causes rehashing of the table. |
protected static Association |
reserved
A single key-value pair to be used as a token indicating a reserved location in the hashtable. |
Constructor Summary | |
---|---|
Hashtable()
Construct a hash table that is initially empty. |
|
Hashtable(int initialCapacity)
Construct a hash table that is capable of holding at least initialCapacity values. |
Method Summary | |
---|---|
void |
clear()
Remove all key-value pairs from hashtable. |
boolean |
containsKey(java.lang.Object key)
Returns true iff a specific key appears within the table. |
boolean |
containsValue(java.lang.Object value)
Returns true if a specific value appears within the table. |
Set |
entrySet()
|
protected void |
extend()
|
java.lang.Object |
get(java.lang.Object key)
Get the value associated with a key. |
boolean |
isEmpty()
Determine if table is empty. |
java.util.Iterator |
iterator()
Returns a traversal that traverses over the values of the hashtable. |
java.util.Iterator |
keys()
Get a traversal over the keys of the hashtable. |
Set |
keySet()
|
protected int |
locate(java.lang.Object key)
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Place a key-value pair within the table. |
void |
putAll(Map other)
Put all of the values found in another map into this map, overriding previous key-value associations. |
java.lang.Object |
remove(java.lang.Object key)
Remove a key-value pair from the table. |
int |
size()
Return the number of key-value pairs within the table. |
java.lang.String |
toString()
Generate a string representation of the hash table. |
Structure |
values()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface structure.Map |
---|
equals, hashCode |
Field Detail |
---|
protected static Association reserved
protected Association[] data
protected int count
protected int capacity
protected final double loadFactor
Constructor Detail |
---|
public Hashtable(int initialCapacity)
initialCapacity
- The initial capacity of the hash table.public Hashtable()
Method Detail |
---|
public void clear()
clear
in interface Map
public int size()
size
in interface Map
public boolean isEmpty()
isEmpty
in interface Map
public boolean containsValue(java.lang.Object value)
containsValue
in interface Map
value
- The value sought.
public boolean containsKey(java.lang.Object key)
containsKey
in interface Map
key
- The key sought.
public java.util.Iterator iterator()
public java.lang.Object get(java.lang.Object key)
get
in interface Map
key
- The key used to find the desired value.
public java.util.Iterator keys()
protected int locate(java.lang.Object key)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface Map
key
- The key to be added to table.value
- The value associated with key.
public void putAll(Map other)
putAll
in interface Map
other
- is the source mappingpublic java.lang.Object remove(java.lang.Object key)
remove
in interface Map
key
- The key of the key-value pair to be removed.
protected void extend()
public Set entrySet()
entrySet
in interface Map
public Set keySet()
keySet
in interface Map
public Structure values()
values
in interface Map
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |