public final class WeakIdentityMap<K,V> extends Object
WeakHashMap
and
IdentityHashMap
.
Useful for caches that need to key off of a ==
comparison
instead of a .equals
.
This class is not a general-purpose Map
implementation! It intentionally violates
Map's general contract, which mandates the use of the equals method
when comparing objects. This class is designed for use only in the
rare cases wherein reference-equality semantics are required.
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
V |
get(Object key) |
boolean |
isEmpty() |
static <K,V> WeakIdentityMap<K,V> |
newConcurrentHashMap()
Creates a new
WeakIdentityMap based on a ConcurrentHashMap . |
static <K,V> WeakIdentityMap<K,V> |
newHashMap()
Creates a new
WeakIdentityMap based on a non-synchronized HashMap . |
V |
put(K key,
V value) |
V |
remove(Object key) |
int |
size() |
public static final <K,V> WeakIdentityMap<K,V> newHashMap()
WeakIdentityMap
based on a non-synchronized HashMap
.public static final <K,V> WeakIdentityMap<K,V> newConcurrentHashMap()
WeakIdentityMap
based on a ConcurrentHashMap
.public void clear()
public boolean containsKey(Object key)
public boolean isEmpty()
public int size()
Copyright © 2012–2015 Hippo B.V. (http://www.onehippo.com). All rights reserved.