public class WeakIdentityMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable
The documentation for WeakHashMap states that it is intended primarily for use with key objects whose equals methods test for object identity using the == operator. Because WeakIdentityMap strictly follows this behavior, it is better suited for this purpose.
Note: Weakly referenced entries may be automatically removed during either accessor or mutator operations, possibly causing a concurrent modification to be detected. Therefore, even if multiple threads are only accessing this map, be sure to synchronize this map first. Also, do not rely on the value returned by size() when using an iterator from this map. The iterators may return less entries than the amount reported by size().
WeakIdentityCache
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
WeakIdentityMap() |
WeakIdentityMap(int initialCapacity) |
WeakIdentityMap(int initialCapacity,
float loadFactor) |
WeakIdentityMap(Map<? extends K,? extends V> t) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
Object |
clone() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> t) |
V |
remove(Object key) |
int |
size() |
String |
toString()
Gets the map as a String.
|
Collection<V> |
values() |
equals, hashCode
public WeakIdentityMap(int initialCapacity, float loadFactor)
public WeakIdentityMap(int initialCapacity)
public WeakIdentityMap()
public int size()
public boolean isEmpty()
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
containsValue
in class AbstractMap<K,V>
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
public void clear()
public Object clone()
clone
in class AbstractMap<K,V>
public Collection<V> values()
public String toString()
toString
in class AbstractMap<K,V>
Copyright © 2004-2015 Cojen. All Rights Reserved.