|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vladium.util.SoftValueMap
MT-safety: an instance of this class is not safe for access from multiple concurrent threads [even if access is done by a single thread at a time]. The caller is expected to synchronize externally on an instance [the implementation does not do internal synchronization for the sake of efficiency]. java.util.ConcurrentModificationException is not supported either.
Nested Class Summary | |
(package private) static class |
SoftValueMap.IndexedSoftReference
An extension of WeakReference that can store an index of the bucket it is associated with. |
(package private) static class |
SoftValueMap.SoftEntry
The structure used for chaining colliding keys. |
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Field Summary | |
private static boolean |
DEBUG
|
private static boolean |
ENQUEUE_FOUND_CLEARED_ENTRIES
|
private static java.lang.String |
EOL
|
private static boolean |
IDENTITY_OPTIMIZATION
|
private SoftValueMap.SoftEntry[] |
m_buckets
|
private float |
m_loadFactor
|
private int |
m_readAccessCount
|
private int |
m_readClearCheckFrequency
|
private int |
m_size
|
private int |
m_sizeThreshold
|
private java.lang.ref.ReferenceQueue |
m_valueReferenceQueue
|
private int |
m_writeAccessCount
|
private int |
m_writeClearCheckFrequency
|
Constructor Summary | |
SoftValueMap()
Equivalent to SoftValueMap(1, 1) . |
|
SoftValueMap(int initialCapacity,
float loadFactor,
int readClearCheckFrequency,
int writeClearCheckFrequency)
Constructs a SoftValueMap with specified initial capacity, load factor, and cleared value removal frequencies. |
|
SoftValueMap(int readClearCheckFrequency,
int writeClearCheckFrequency)
Equivalent to SoftValueMap(11, 0.75F, getClearCheckFrequency, putClearCheckFrequency) . |
Method Summary | |
void |
clear()
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
(package private) void |
debugDump(java.lang.StringBuffer out)
|
java.util.Set |
entrySet()
|
boolean |
equals(java.lang.Object rhs)
|
java.lang.Object |
get(java.lang.Object key)
Returns the value that is mapped to a given 'key'. |
int |
hashCode()
|
boolean |
isEmpty()
Returns 'false' is this map contains key-value mappings (even if some of the values may have been cleared already but not removed from the table). |
java.util.Set |
keySet()
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Updates the table to map 'key' to 'value'. |
void |
putAll(java.util.Map map)
|
private void |
rehash()
Re-hashes the table into a new array of buckets. |
java.lang.Object |
remove(java.lang.Object key)
|
private void |
removeClearedValues()
Removes all entries whose soft values have been cleared _and_ enqueued. |
int |
size()
Returns the number of key-value mappings in this map. |
java.lang.String |
toString()
Overrides Object.toString() for debug purposes. |
java.util.Collection |
values()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private final java.lang.ref.ReferenceQueue m_valueReferenceQueue
private final float m_loadFactor
private final int m_readClearCheckFrequency
private final int m_writeClearCheckFrequency
private SoftValueMap.SoftEntry[] m_buckets
private int m_size
private int m_sizeThreshold
private int m_readAccessCount
private int m_writeAccessCount
private static final java.lang.String EOL
private static final boolean IDENTITY_OPTIMIZATION
private static final boolean ENQUEUE_FOUND_CLEARED_ENTRIES
private static final boolean DEBUG
Constructor Detail |
public SoftValueMap()
SoftValueMap(1, 1)
.
public SoftValueMap(int readClearCheckFrequency, int writeClearCheckFrequency)
SoftValueMap(11, 0.75F, getClearCheckFrequency, putClearCheckFrequency)
.
public SoftValueMap(int initialCapacity, float loadFactor, int readClearCheckFrequency, int writeClearCheckFrequency)
initialCapacity
- initial number of hash buckets in the table
[may not be negative, 0 is equivalent to 1].loadFactor
- the load factor to use to determine rehashing points
[must be in (0.0, 1.0] range].readClearCheckFrequency
- specifies that every readClearCheckFrequency
get(java.lang.Object)
should check for and remove all mappings whose soft values
have been cleared by the garbage collector [may not be less than 1].writeClearCheckFrequency
- specifies that every writeClearCheckFrequency
put(java.lang.Object, java.lang.Object)
should check for and remove all mappings whose soft values
have been cleared by the garbage collector [may not be less than 1].Method Detail |
public boolean equals(java.lang.Object rhs)
equals
in interface java.util.Map
public int hashCode()
hashCode
in interface java.util.Map
public java.lang.String toString()
public int size()
NOTE: in contrast with the java.util.WeakHashMap implementation, this is a constant time operation.
size
in interface java.util.Map
public boolean isEmpty()
NOTE: in contrast with the java.util.WeakHashMap implementation, this is a constant time operation.
isEmpty
in interface java.util.Map
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
key
- mapping key [may not be null].
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
key
- mapping key [may not be null].value
- mapping value [may not be null].
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
public void clear()
clear
in interface java.util.Map
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
public void putAll(java.util.Map map)
putAll
in interface java.util.Map
public java.util.Set keySet()
keySet
in interface java.util.Map
public java.util.Set entrySet()
entrySet
in interface java.util.Map
public java.util.Collection values()
values
in interface java.util.Map
void debugDump(java.lang.StringBuffer out)
private void rehash()
private void removeClearedValues()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |