public class Hashtable extends Dictionary implements Cloneable, Serializable, Map
serialVersionUID
Constructor and Description |
---|
Hashtable()
Constructs a new hashtable with the default initial capacity
and a default load factor of 0.75
|
Hashtable(int initialCapacity)
Constructs a new hashtable with the specified initial capacity
and a default load factor of 0.75
|
Hashtable(int initialCapacity,
float loadFactor)
Constructs a hashtable with the specified initial
capacity and the specified load factor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all entries from this Map (optional operation).
|
Object |
clone()
Create a field for field copy of this Object if this Object
implements the Cloneable interface.
|
boolean |
contains(Object value) |
boolean |
containsKey(Object key)
Returns true if this contains a mapping for the given key.
|
boolean |
containsValue(Object value)
Returns true if this contains at least one mapping with the given value.
|
Enumeration |
elements()
Returns an Enumeration of the values in this Dictionary.
|
Set |
entrySet()
Returns a set view of the mappings in this Map.
|
Object |
get(Object key)
Returns the value associated with the supplied key, or null
if no such value exists.
|
boolean |
isEmpty()
Returns true when there are no elements in this Dictionary.
|
Enumeration |
keys()
Returns an Enumeration of the keys in this Dictionary
|
Set |
keySet()
Returns a set view of the keys in this Map.
|
Object |
put(Object key,
Object value)
Inserts a new value into this Dictionary, located by the
supplied key.
|
void |
putAll(Map m)
Copies all entries of the given map to this one (optional operation).
|
protected void |
rehash() |
Object |
remove(Object key)
Removes from the Dictionary the value located by the given key.
|
int |
size()
Returns the number of values currently in this Dictionary.
|
String |
toString()
Returns a string representation of this Hashtable object
in the form of a set of entries, enclosed in braces and separated
by the ASCII characters ", " (comma and space).
|
Collection |
values()
Returns a collection (or bag) view of the values in this Map.
|
public Hashtable(int initialCapacity, float loadFactor)
public Hashtable(int initialCapacity)
public Hashtable()
public Object clone()
Object
public int size()
Dictionary
size
in interface Map
size
in class Dictionary
public boolean isEmpty()
Dictionary
isEmpty
in interface Map
isEmpty
in class Dictionary
size() == 0
public boolean contains(Object value)
public boolean containsKey(Object key)
Map
containsKey
in interface Map
key
- the key to search forpublic Object remove(Object key)
Dictionary
remove
in interface Map
remove
in class Dictionary
key
- the key used to locate the value to be removedpublic Object put(Object key, Object value)
Dictionary
put
in interface Map
put
in class Dictionary
key
- the key which locates the valuevalue
- the value to put into the DictionaryDictionary.get(Object)
public void clear()
Map
public Object get(Object key)
Dictionary
get
in interface Map
get
in class Dictionary
key
- the key to use to fetch the valueDictionary.put(Object, Object)
protected void rehash()
public Enumeration elements()
Dictionary
elements
in class Dictionary
Dictionary.keys()
public Enumeration keys()
Dictionary
keys
in class Dictionary
Dictionary.elements()
public String toString()
public boolean containsValue(Object value)
Map
(value == null ? v == null : value.equals(v))
. This usually
requires linear time.containsValue
in interface Map
value
- the value to search forpublic Set entrySet()
Map
Iterator.remove
, Set.remove
,
removeAll
, retainAll
, and clear
.
Element addition, via add
or addAll
, is
not supported via this set.public Set keySet()
Map
Iterator.remove
, Set.remove
,
removeAll
, retainAll
, and clear
.
Element addition, via add
or addAll
, is
not supported via this set.public void putAll(Map m)
Map
putAll
in interface Map
m
- the mapping to load into this mapMap.put(Object, Object)
public Collection values()
Map
Iterator.remove
,
Collection.remove
, removeAll
,
retainAll
, and clear
. Element addition, via
add
or addAll
, is not supported via this
collection.