|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.tbee.cache.simple.LossyHashMap<K,V>
public class LossyHashMap<K,V>
This class is a HashMap (for fast access) but uses weak references for its values, so the garbage collecter may remove referenced values. The keys are strong references, so they are not cleaned. The weak references are hidden from the user, so the class behaves like a normal hashmap except for the fact that values can "dissappear". This class is useful for implementing caches of objects. If the system runs out of memory, the cache is automatically cleaned.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
static char |
MODE_SOFT
|
static char |
MODE_STRONG
|
static char |
MODE_WEAK
|
static String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
| Constructor Summary | |
|---|---|
LossyHashMap()
extended HashMap constructor: adds the mode |
|
LossyHashMap(char pMode)
extended HashMap constructor: adds the mode |
|
LossyHashMap(char pMode,
int initialCapacity)
extended HashMap constructor: adds the mode |
|
LossyHashMap(char pMode,
int initialCapacity,
float loadFactor)
extended HashMap constructor: adds the mode |
|
LossyHashMap(char pMode,
Map t)
extended HashMap constructor: adds the mode |
|
LossyHashMap(int initialCapacity)
this constructor comes from the HashMap and assume STRONG mode |
|
LossyHashMap(int initialCapacity,
float loadFactor)
this constructor comes from the HashMap and assume STRONG mode |
|
LossyHashMap(Map t)
this constructor comes from the HashMap and assume STRONG mode |
|
| Method Summary | |
|---|---|
void |
addFinalizeListener(FinalizeListener pFinalizeListener)
|
void |
addRemoveListener(RemoveListener pRemoveListener)
|
void |
callFinalizeListener(org.tbee.cache.simple.FinalizeLogger pFinalizeLogger)
|
void |
callRemoveListener(Object pKey,
Object pValue)
|
void |
clean()
remove entries of which the reference was cleared (soft or weak references) |
void |
clear()
removes all entries |
Object |
clone()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
Set |
entrySet()
|
V |
get(Object key)
|
char |
getMode()
get the active mode |
boolean |
isEmpty()
|
Set<K> |
keySet()
|
Object |
put(Object key,
Object value)
|
void |
putAll(Map t)
|
V |
remove(Object key)
|
void |
removeFinalizeListener(FinalizeListener pFinalizeListener)
|
void |
removeRemoveListener(RemoveListener pRemoveListener)
|
void |
removeValue(Object value)
|
int |
size()
|
String |
toString()
|
Collection |
values()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Field Detail |
|---|
public static final String SOURCECODE_VERSION
public static char MODE_STRONG
public static char MODE_SOFT
public static char MODE_WEAK
| Constructor Detail |
|---|
public LossyHashMap()
public LossyHashMap(char pMode)
public LossyHashMap(char pMode,
int initialCapacity)
public LossyHashMap(char pMode,
int initialCapacity,
float loadFactor)
public LossyHashMap(char pMode,
Map t)
public LossyHashMap(int initialCapacity)
public LossyHashMap(int initialCapacity,
float loadFactor)
public LossyHashMap(Map t)
| Method Detail |
|---|
public char getMode()
public void addFinalizeListener(FinalizeListener pFinalizeListener)
public void removeFinalizeListener(FinalizeListener pFinalizeListener)
public void callFinalizeListener(org.tbee.cache.simple.FinalizeLogger pFinalizeLogger)
public void addRemoveListener(RemoveListener pRemoveListener)
public void callRemoveListener(Object pKey,
Object pValue)
public void removeRemoveListener(RemoveListener pRemoveListener)
public void clean()
public void clear()
clear in interface Map<K,V>public Object clone()
clone in class Objectpublic boolean containsKey(Object key)
containsKey in interface Map<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>public Set entrySet()
entrySet in interface Map<K,V>public V get(Object key)
get in interface Map<K,V>public boolean isEmpty()
isEmpty in interface Map<K,V>public Set<K> keySet()
keySet in interface Map<K,V>
public Object put(Object key,
Object value)
put in interface Map<K,V>public void putAll(Map t)
putAll in interface Map<K,V>public V remove(Object key)
remove in interface Map<K,V>public void removeValue(Object value)
public int size()
size in interface Map<K,V>public String toString()
toString in class Objectpublic Collection values()
values in interface Map<K,V>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||