public class LinkedHashtable<K,V> extends Hashtable<K,V>
This is not a general purpose class but has been written because
the protected members of Copy
prohibited later revisions from using a more predictable
collection.
Methods are synchronized to keep Hashtable's contract.
Constructor and Description |
---|
LinkedHashtable() |
LinkedHashtable(int initialCapacity) |
LinkedHashtable(int initialCapacity,
float loadFactor) |
LinkedHashtable(Map<K,V> m) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this hashtable so that it contains no keys.
|
boolean |
contains(Object value)
Tests if some key maps into the specified value in this hashtable.
|
boolean |
containsKey(Object value)
Tests if the specified object is a key in this hashtable.
|
boolean |
containsValue(Object value)
Returns true if this hashtable maps one or more keys to this value.
|
Enumeration<V> |
elements()
Returns an enumeration of the values in this hashtable.
|
Set<Map.Entry<K,V>> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
boolean |
equals(Object o)
Compares the specified Object with this Map for equality, as per the definition in the Map
interface.
|
V |
get(Object k)
Returns the value to which the specified key is mapped, or
null if this map contains no
mapping for the key. |
int |
hashCode()
Returns the hash code value for this Map as per the definition in the Map interface.
|
boolean |
isEmpty()
Tests if this hashtable maps no keys to values.
|
Enumeration<K> |
keys()
Returns an enumeration of the keys in this hashtable.
|
Set<K> |
keySet()
Returns a
Set view of the keys contained in this map. |
V |
put(K k,
V v)
Maps the specified
key to the specified value in this hashtable. |
void |
putAll(Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to this hashtable.
|
V |
remove(Object k)
Removes the key (and its corresponding value) from this hashtable.
|
int |
size()
Returns the number of keys in this hashtable.
|
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<V> |
values()
Returns a
Collection view of the values contained in this map. |
public LinkedHashtable()
public LinkedHashtable(int initialCapacity)
public LinkedHashtable(int initialCapacity, float loadFactor)
public void clear()
Hashtable
public boolean contains(Object value)
Hashtable
containsKey
method.
Note that this method is identical in functionality to containsValue
,
(which is part of the Map
interface in the collections framework).
public boolean containsKey(Object value)
Hashtable
containsKey
in interface Map<K,V>
containsKey
in class Hashtable<K,V>
value
- possible keytrue
if and only if the specified object is a key in this hashtable, as
determined by the equals method; false
otherwise.Hashtable.contains(Object)
public boolean containsValue(Object value)
Hashtable
Note that this method is identical in functionality to contains
(which predates
the Map
interface).
containsValue
in interface Map<K,V>
containsValue
in class Hashtable<K,V>
value
- value whose presence in this hashtable is to be testedpublic Enumeration<V> elements()
Hashtable
elements
in class Hashtable<K,V>
Enumeration
,
Hashtable.keys()
,
Hashtable.values()
,
Map
public Set<Map.Entry<K,V>> entrySet()
Hashtable
Set
view of the mappings contained in this map. The set is backed by the map,
so changes to the map are reflected in the set, and vice-versa. If the map is modified while an
iteration over the set is in progress (except through the iterator's own remove
operation, or through the setValue operation on a map entry returned by the iterator)
the results of the iteration are undefined. The set supports element removal, which removes the
corresponding mapping from the map, via the Iterator.remove, Set.remove,
removeAll, retainAll and clear operations. It does not support the
add or addAll operations.public boolean equals(Object o)
Hashtable
public V get(Object k)
Hashtable
null
if this map contains no
mapping for the key.
More formally, if this map contains a mapping from a key k
to a value v
such that
(key.equals(k))
, then this method returns v
; otherwise it returns null
.
(There can be at most one such mapping.)
public int hashCode()
Hashtable
public boolean isEmpty()
Hashtable
public Enumeration<K> keys()
Hashtable
keys
in class Hashtable<K,V>
Enumeration
,
Hashtable.elements()
,
Hashtable.keySet()
,
Map
public Set<K> keySet()
Hashtable
Set
view of the keys contained in this map. The set is backed by the map, so
changes to the map are reflected in the set, and vice-versa. If the map is modified while an
iteration over the set is in progress (except through the iterator's own remove
operation), the results of the iteration are undefined. The set supports element removal, which
removes the corresponding mapping from the map, via the Iterator.remove,
Set.remove, removeAll, retainAll, and clear operations. It
does not support the add or addAll operations.public V put(K k, V v)
Hashtable
key
to the specified value
in this hashtable.
Neither the key nor the value can be null
.
The value can be retrieved by calling the get
method with a key that is equal to the
original key.
put
in interface Map<K,V>
put
in class Hashtable<K,V>
k
- the hashtable keyv
- the valuenull
if it did
not have oneObject.equals(Object)
,
Hashtable.get(Object)
public void putAll(Map<? extends K,? extends V> m)
Hashtable
public V remove(Object k)
Hashtable
public int size()
Hashtable
public String toString()
Hashtable
public Collection<V> values()
Hashtable
Collection
view of the values contained in this map. The collection is backed
by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is
modified while an iteration over the collection is in progress (except through the iterator's own
remove operation), the results of the iteration are undefined. The collection supports
element removal, which removes the corresponding mapping from the map, via the
Iterator.remove, Collection.remove, removeAll, retainAll and
clear operations. It does not support the add or addAll operations.