|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractMap<K,V>
SoftValueHashMap<K,V>
public class SoftValueHashMap<K,V>
Duplicated code from org.geotools.util simply to avoid geotools dependency --------------------------------------------------------------------------------------------- A hash map implementation that uses soft references, leaving memory when an entry is not used anymore and memory is low.
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, but doesn't accepts null
values. Usage of value, key or
entry collections are supported except for direct
usage of their iterators, which may throw
ConcurrentModificationException randomly depending on the garbage
collector activity.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
SoftValueHashMap()
Creates a map with the default hard references count. |
|
SoftValueHashMap(int hardReferencesCount)
Creates a map with the specified hard references count. |
|
| Method Summary | |
|---|---|
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 |
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. |
| Methods inherited from class AbstractMap |
|---|
clone, isEmpty, keySet, values |
| Methods inherited from class Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SoftValueHashMap()
public SoftValueHashMap(int hardReferencesCount)
hardReferencesCount - The maximal number of hard references to keep.| Method Detail |
|---|
public int size()
size in interface Map<K,V>size in class AbstractMap<K,V>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.
get in interface Map<K,V>get in class AbstractMap<K,V>key - key whose associated value is to be returned.
null if none.
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)
putAll in interface Map<K,V>putAll in class AbstractMap<K,V>map - Mappings to be stored in this map.public V remove(Object key)
remove in interface Map<K,V>remove in class AbstractMap<K,V>key - Key whose mapping is to be removed from the map.
null
if there was no entry for key.public void clear()
clear in interface Map<K,V>clear in class AbstractMap<K,V>public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>entrySet in class AbstractMap<K,V>public boolean equals(Object object)
equals in interface Map<K,V>equals in class AbstractMap<K,V>object - The object to compare with this map for equality.public int hashCode()
hashCode in interface Map<K,V>hashCode in class AbstractMap<K,V>public String toString()
toString in class AbstractMap<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||