Package org.jboss.util.collection
Class ReferenceValueMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.jboss.util.collection.ReferenceValueMap<K,V>
-
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
java.util.Map<K,V>
- Direct Known Subclasses:
ReferenceValueHashMap,ReferenceValueTreeMap
public abstract class ReferenceValueMap<K,V> extends java.util.AbstractMap<K,V>This Map will remove entries when the value in the map has been cleaned from garbage collection
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classReferenceValueMap.EntrySetEntrySet.private classReferenceValueMap.EntrySetIteratorEntrySet iterator
-
Constructor Summary
Constructors Modifier Constructor Description protectedReferenceValueMap()protectedReferenceValueMap(int initialCapacity)protectedReferenceValueMap(int initialCapacity, float loadFactor)protectedReferenceValueMap(java.util.Comparator<K> comparator)protectedReferenceValueMap(java.util.Map<K,V> t)protectedReferenceValueMap(java.util.SortedMap<K,ValueRef<K,V>> sorted)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(java.lang.Object key)protected abstract ValueRef<K,V>create(K key, V value, java.lang.ref.ReferenceQueue<V> q)Create new value ref instance.protected abstract java.util.Map<K,ValueRef<K,V>>createMap()Create map.protected abstract java.util.Map<K,ValueRef<K,V>>createMap(int initialCapacity)Create map.protected abstract java.util.Map<K,ValueRef<K,V>>createMap(int initialCapacity, float loadFactor)Create map.protected abstract java.util.Map<K,ValueRef<K,V>>createMap(java.util.Comparator<K> comparator)Create map.protected abstract java.util.Map<K,ValueRef<K,V>>createMap(java.util.SortedMap<K,ValueRef<K,V>> map)Create map.java.util.Set<java.util.Map.Entry<K,V>>entrySet()Vget(java.lang.Object key)private voidprocessQueue()Remove all entries whose values have been discarded.Vput(K key, V value)Vremove(java.lang.Object key)intsize()java.lang.StringtoString()-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, values
-
-
-
-
Constructor Detail
-
ReferenceValueMap
protected ReferenceValueMap()
-
ReferenceValueMap
protected ReferenceValueMap(int initialCapacity)
-
ReferenceValueMap
protected ReferenceValueMap(int initialCapacity, float loadFactor)
-
ReferenceValueMap
protected ReferenceValueMap(java.util.Comparator<K> comparator)
-
-
Method Detail
-
createMap
protected abstract java.util.Map<K,ValueRef<K,V>> createMap()
Create map.- Returns:
- new map instance
-
createMap
protected abstract java.util.Map<K,ValueRef<K,V>> createMap(int initialCapacity)
Create map.- Parameters:
initialCapacity- the initial capacity- Returns:
- new map instance
-
createMap
protected abstract java.util.Map<K,ValueRef<K,V>> createMap(int initialCapacity, float loadFactor)
Create map.- Parameters:
initialCapacity- the initial capacityloadFactor- the load factor- Returns:
- new map instance
-
createMap
protected abstract java.util.Map<K,ValueRef<K,V>> createMap(java.util.Comparator<K> comparator)
Create map.- Parameters:
comparator- the comparator- Returns:
- new map instance
-
createMap
protected abstract java.util.Map<K,ValueRef<K,V>> createMap(java.util.SortedMap<K,ValueRef<K,V>> map)
Create map.- Parameters:
map- the sorted map- Returns:
- new map instance
-
size
public int size()
-
containsKey
public boolean containsKey(java.lang.Object key)
-
get
public V get(java.lang.Object key)
-
remove
public V remove(java.lang.Object key)
-
clear
public void clear()
-
processQueue
private void processQueue()
Remove all entries whose values have been discarded.
-
create
protected abstract ValueRef<K,V> create(K key, V value, java.lang.ref.ReferenceQueue<V> q)
Create new value ref instance.- Parameters:
key- the keyvalue- the valueq- the ref queue- Returns:
- new value ref instance
-
-