Top Description Inners Fields Constructors Methods
org.h2.util

public Class SoftValuesHashMap<K, V>

extends AbstractMap<K, V>
Class Inheritance
Type Parameters
<K>
the key type
<V>
the value type
Imports
java.lang.ref.Reference, .ReferenceQueue, .SoftReference, java.util.AbstractMap, .HashMap, .Map, .Set

Map which stores items using SoftReference. Items can be garbage collected and removed. It is not a general purpose cache, as it doesn't implement some methods, and others not according to the map definition, to improve speed.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SoftValuesHashMap.SoftValue<T>

A soft reference that has a hard reference to the key.

Field Summary

Modifier and TypeField and Description
private final Map<K, SoftValuesHashMap.SoftValue<V>>
private final ReferenceQueue<V>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides java.util.AbstractMap.clear.

Implements java.util.Map.clear.

Removes all of the mappings from this map (optional operation).

public Set<Map.Entry<K, V>>
entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

public V
get(Object
the key whose associated value is to be returned
key
)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

private void
public V

Returns:

null or the old object.
put
(K
the key
key
,
V
the value
value
)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Store the object.

public V

Returns:

null or the old object
remove
(Object
the key
key
)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Remove an object.

Inherited from java.util.AbstractMap:
clonecontainsKeycontainsValueequalshashCodeisEmptykeySetputAllsizetoStringvalues

Field Detail

mapback to summary
private final Map<K, SoftValuesHashMap.SoftValue<V>> map
queueback to summary
private final ReferenceQueue<V> queue

Constructor Detail

SoftValuesHashMapback to summary
public SoftValuesHashMap()

Method Detail

clearback to summary
public void clear()

Overrides java.util.AbstractMap.clear.

Implements java.util.Map.clear.

Doc from java.util.AbstractMap.clear.

Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.

Annotations
@Override
entrySetback to summary
public Set<Map.Entry<K, V>> entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<K, V>>

a set view of the mappings contained in this map

Annotations
@Override
getback to summary
public V get(Object key)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Doc from java.util.AbstractMap.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
key:Object

Doc from java.util.Map.get.

the key whose associated value is to be returned

Returns:V

Doc from java.util.Map.get.

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
processQueueback to summary
private void processQueue()
Annotations
@SuppressWarnings:unchecked
putback to summary
public V put(K key, V value)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Store the object. The return value of this method is null or a SoftReference.

Parameters
key:K

the key

value:V

the value

Returns:V

null or the old object.

Annotations
@Override
removeback to summary
public V remove(Object key)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Remove an object.

Parameters
key:Object

the key

Returns:V

null or the old object

Annotations
@Override
org.h2.util back to summary

private Class SoftValuesHashMap.SoftValue<T>

extends SoftReference<T>
Class Inheritance

A soft reference that has a hard reference to the key.

Field Summary

Modifier and TypeField and Description
pack-priv final Object

Constructor Summary

AccessConstructor and Description
public
SoftValue(T ref, ReferenceQueue<T> q, Object key)

Method Summary

Inherited from java.lang.ref.SoftReference:
get

Field Detail

keyback to summary
pack-priv final Object key

Constructor Detail

SoftValueback to summary
public SoftValue(T ref, ReferenceQueue<T> q, Object key)