K
- The type of keys in the map.V
- The type of values in the map.public class SoftValueHashMap<K,V> extends AbstractMap<K,V>
This map implementation actually maintains some of the first entries as hard references. Only oldest entries are retained by soft references, in order to avoid too aggressive garbage collection. The amount of entries to retain by hard reference is specified at construction time.
This map is thread-safe. It accepts the null key; it does not accept the null value. Usage of value, key or entry collections are supported. The iterator on the ConcurrentHashMap is weakly consistent.
Modifier and Type | Class and Description |
---|---|
static interface |
SoftValueHashMap.ValueCleaner
A delegate that can be used to perform clean up operation, such as resource closing, before
the values cached in soft part of the cache gets disposed of
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
protected SoftValueHashMap.ValueCleaner |
cleaner
The eventual cleaner
|
Constructor and Description |
---|
SoftValueHashMap()
Creates a map with the default hard references count.
|
SoftValueHashMap(int hardReferencesCount)
Creates a map with the specified hard references count.
|
SoftValueHashMap(int hardReferencesCount,
SoftValueHashMap.ValueCleaner cleaner)
Creates a map with the specified hard references count.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all mappings from this map.
|
boolean |
containsKey(Object key)
Returns
true if this map contains a mapping for the specified key. |
boolean |
containsValue(Object value)
Returns
true if this map maps one or more keys to this value. |
Set<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this map.
|
boolean |
equals(Object object)
Compares the specified object with this map for equality.
|
V |
get(Object key)
Returns the value to which this map maps the specified key.
|
int |
getHardReferencesCount()
Returns the number of hard references kept in this cache
|
int |
hashCode()
Returns the hash code value for this map.
|
V |
put(K key,
V value)
Associates the specified value with the specified key in this map.
|
void |
putAll(Map<? extends K,? extends V> map)
Copies all of the mappings from the specified map to this map.
|
V |
remove(Object key)
Removes the mapping for this key from this map if present.
|
int |
size()
Returns the number of entries in this map.
|
String |
toString()
Returns a string representation of this map.
|
clone, isEmpty, keySet, values
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
protected SoftValueHashMap.ValueCleaner cleaner
public SoftValueHashMap()
public SoftValueHashMap(int hardReferencesCount)
hardReferencesCount
- The maximal number of hard references to keep.public SoftValueHashMap(int hardReferencesCount, SoftValueHashMap.ValueCleaner cleaner)
hardReferencesCount
- The maximal number of hard references to keep.public int getHardReferencesCount()
public int size()
public boolean containsKey(Object key)
true
if this map contains a mapping for the specified key.containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
public boolean containsValue(Object value)
true
if this map maps one or more keys to this value.containsValue
in interface Map<K,V>
containsValue
in class AbstractMap<K,V>
public V get(Object key)
null
if the map
contains no mapping for this key, or the value has been garbage collected.public V put(K key, V value)
put
in interface Map<K,V>
put
in class AbstractMap<K,V>
key
- Key with which the specified value is to be associated.value
- Value to be associated with the specified key. The value can't be null.null
if there was no mapping
for key.public void putAll(Map<? extends K,? extends V> map)
public void clear()
public Set<Map.Entry<K,V>> entrySet()
public boolean equals(Object object)
public int hashCode()
public String toString()
toString
in class AbstractMap<K,V>
Copyright © 1996–2019 Geotools. All rights reserved.