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 class
ReferenceValueMap.EntrySet
EntrySet.private class
ReferenceValueMap.EntrySetIterator
EntrySet iterator
-
Constructor Summary
Constructors Modifier Constructor Description protected
ReferenceValueMap()
protected
ReferenceValueMap(int initialCapacity)
protected
ReferenceValueMap(int initialCapacity, float loadFactor)
protected
ReferenceValueMap(java.util.Comparator<K> comparator)
protected
ReferenceValueMap(java.util.Map<K,V> t)
protected
ReferenceValueMap(java.util.SortedMap<K,ValueRef<K,V>> sorted)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(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()
V
get(java.lang.Object key)
private void
processQueue()
Remove all entries whose values have been discarded.V
put(K key, V value)
V
remove(java.lang.Object key)
int
size()
java.lang.String
toString()
-
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
-
-