public abstract class ReferenceValueMap2<K,V>
extends java.util.AbstractMap<K,V>
Map
implementation that uses KeyedReference
instances (KeyedStrongReference
,
KeyedSoftReference
, KeyedWeakReference
or KeyedPhantomReference
) as its values.
A ReferenceValueMap
can be used to cache mappings until the value of the mapping is no longer
reachable from outside of the map
Note: This map is not synchronized. If it is to be used by multiple threads concurrently the user is responsible for applying proper external synchronization!
Modifier and Type | Class and Description |
---|---|
static class |
ReferenceValueMap2.Soft<K,V> |
static class |
ReferenceValueMap2.Strong<K,V> |
static class |
ReferenceValueMap2.Weak<K,V> |
Constructor and Description |
---|
ReferenceValueMap2() |
ReferenceValueMap2(java.util.Map<K,KeyedReference<K,V>> map) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
protected java.lang.ref.ReferenceQueue<V> |
createQueue() |
protected abstract KeyedReference<K,V> |
createReference(K key,
V value,
java.lang.ref.ReferenceQueue<V> queue) |
protected V |
dereference(KeyedReference<K,V> ref) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key) |
protected int |
internalPurgeQueue() |
boolean |
isEmpty() |
protected void |
purged(K key) |
protected void |
purgeQueue() |
V |
put(K key,
V value) |
V |
remove(java.lang.Object key) |
int |
size() |
clone, equals, hashCode, keySet, putAll, toString, values
public ReferenceValueMap2()
public ReferenceValueMap2(java.util.Map<K,KeyedReference<K,V>> map)
public int size()
public boolean isEmpty()
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public V get(java.lang.Object key)
public V remove(java.lang.Object key)
public void clear()
protected java.lang.ref.ReferenceQueue<V> createQueue()
protected int internalPurgeQueue()
protected void purgeQueue()
protected void purged(K key)
protected V dereference(KeyedReference<K,V> ref)
Copyright (c) 2004-2019 Eike Stepper (Loehne, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html