public abstract class ReferenceValueMap2<K,V> extends 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> |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
ReferenceValueMap2() |
ReferenceValueMap2(Map<K,KeyedReference<K,V>> map) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
protected ReferenceQueue<V> |
createQueue() |
protected abstract KeyedReference<K,V> |
createReference(K key,
V value,
ReferenceQueue<V> queue) |
protected V |
dereference(KeyedReference<K,V> ref) |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
boolean |
isEmpty() |
protected void |
purged(K key) |
protected void |
purgeQueue() |
V |
put(K key,
V value) |
V |
remove(Object key) |
int |
size() |
clone, equals, hashCode, keySet, putAll, toString, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic ReferenceValueMap2()
public ReferenceValueMap2(Map<K,KeyedReference<K,V>> map)
public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>containsValue in class AbstractMap<K,V>public void clear()
protected ReferenceQueue<V> createQueue()
protected void purgeQueue()
protected void purged(K key)
protected V dereference(KeyedReference<K,V> ref)
protected abstract KeyedReference<K,V> createReference(K key, V value, ReferenceQueue<V> queue)
Copyright (c) 2014 Eike Stepper (Berlin, 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