|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
rwth.i2.ltlrv.data.WeakValuesHashMap<K,V>
K
- type parameter for key typeV
- type parameter for value typepublic class WeakValuesHashMap<K,V>
HashMap with weak keys. Bugfixed by Eric Bodden to make equals/hashCode work
again. Eric Bodden also added locking.
The implementation is not very efficient, because an entrySet is generated
for almost any operation. This is quite expensive.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface rwth.i2.ltlrv.data.WeakValuesMap |
---|
WeakValuesMap.Util |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Field Summary | |
---|---|
private Map<K,WeakReference<V>> |
hash
The internal HashMap that will hold the WeakReference. |
protected int |
hashCode
|
protected boolean |
hashCodeDirty
|
private boolean |
locked
If true, this map may not be modified any more. |
private ReferenceQueue<V> |
queue
Reference queue for cleared WeakReference objects. |
private Map<WeakReference<V>,K> |
reverseLookup
|
private static long |
serialVersionUID
Generated SUID. |
protected int |
size
|
protected boolean |
sizeDirty
|
Constructor Summary | |
---|---|
WeakValuesHashMap()
|
Method Summary | |
---|---|
void |
clear()
|
protected void |
dirty()
Marks hashCode and size as dirty. |
Set<Map.Entry<K,V>> |
entrySet()
Returns a copy of the key/values in the map at the point of calling. |
private void |
expungeStaleEntries()
Removes stale entries from the map. |
V |
get(Object key)
|
int |
hashCode()
|
boolean |
isLocked()
Returns if this map is locked. |
void |
lock()
Locks the map, so that no modifications are allowed any more. |
V |
put(K key,
V value)
|
V |
remove(Object key)
|
int |
size()
|
String |
toString()
|
Methods inherited from class java.util.AbstractMap |
---|
clone, containsKey, containsValue, equals, isEmpty, keySet, putAll, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
containsKey, containsValue, equals, isEmpty, keySet, putAll, values |
Field Detail |
---|
private static final long serialVersionUID
private final Map<K,WeakReference<V>> hash
private final Map<WeakReference<V>,K> reverseLookup
private final ReferenceQueue<V> queue
private boolean locked
protected int size
protected boolean sizeDirty
protected int hashCode
protected boolean hashCodeDirty
Constructor Detail |
---|
public WeakValuesHashMap()
Method Detail |
---|
public V get(Object key)
get
in interface Map<K,V>
get
in class AbstractMap<K,V>
private void expungeStaleEntries()
public V put(K key, V value)
put
in interface Map<K,V>
put
in class AbstractMap<K,V>
public V remove(Object key)
remove
in interface Map<K,V>
remove
in class AbstractMap<K,V>
public void clear()
clear
in interface Map<K,V>
clear
in class AbstractMap<K,V>
public int size()
size
in interface Map<K,V>
size
in class AbstractMap<K,V>
public void lock()
lock
in interface WeakValuesMap<K,V>
public boolean isLocked()
isLocked
in interface WeakValuesMap<K,V>
true
if the map is lockedpublic Set<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
entrySet
in class AbstractMap<K,V>
public int hashCode()
hashCode
in interface Map<K,V>
hashCode
in class AbstractMap<K,V>
protected void dirty()
public String toString()
toString
in class AbstractMap<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |