|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.WeakIdentityMap<K,V>
public final class WeakIdentityMap<K,V>
Implements a combination of 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.
This implementation was forked from Apache CXF
but modified to not implement the Map
interface and
without any set/iterator views on it, as those are error-prone
and inefficient, if not implemented carefully. Lucene's implementation also
supports null
keys, but those are never weak!
Method Summary | ||
---|---|---|
void |
clear()
|
|
boolean |
containsKey(Object key)
|
|
V |
get(Object key)
|
|
boolean |
isEmpty()
|
|
static
|
newConcurrentHashMap()
Creates a new WeakIdentityMap based on a ConcurrentHashMap . |
|
static
|
newHashMap()
Creates a new WeakIdentityMap based on a non-synchronized HashMap . |
|
V |
put(K key,
V value)
|
|
V |
remove(Object key)
|
|
int |
size()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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 V get(Object key)
public V put(K key, V value)
public boolean isEmpty()
public V remove(Object key)
public int size()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |