|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.erights.e.elib.tables.EMap | +--org.erights.e.elib.tables.FlexMap | +--org.erights.e.elib.tables.WeakValueMap
Untamed: A WeakValueMap is FlexMap whose values may be garbage collected.
A WeakValueMap acts as if an external entity (ie, the garbage collector) shares access to the map and occasionally decides to remove some elements. As a result, a WeakValueMap which isn't being changed by the program may nevertheless find itself shrinking over time. This external modifications can only occur 1) in their own turn, or 2) at the beginning of any operation that causes an enumeration.
The snapshot(), readOnly(), clone(), or diverge() of a WeakValueMap is not weak.
BUG: For some unfathomable reason, the actual values never seem to get collected, even though WeakValue by itself, when tested, seems to work fine.
XXX This class needs its own writeReplace() method.
java.util.WeakHashMap
,
Serialized FormField Summary | |
private FlexMap |
myStuff
|
private Class |
myValueType
|
(package private) static long |
serialVersionUID
|
Fields inherited from class org.erights.e.elib.tables.EMap |
|
Fields inherited from interface org.erights.e.elib.serial.PassByProxy |
HONORARY, HONORED_NAMES |
Fields inherited from interface org.erights.e.elib.serial.Persistent |
HONORARY, HONORED_NAMES |
Constructor Summary | |
WeakValueMap()
Enabled: |
|
WeakValueMap(Class keyType,
Class valueType)
Enabled: |
Method Summary | |
void |
__printOn(TextWriter out)
Enabled: Does not remove garbage first, which is weird, but the other would be weirder. |
Object |
get(Object key,
Object instead)
Enabled: Does not remove garbage first, except for the value itself if it has been collected. |
Object |
getKeys(Class type)
Enabled: Does *not* remove garbage first, which is dangerous. |
Object |
getValues(Class type)
Enabled: Removes garbage first |
Class |
keyType()
Enabled: Does not remove garbage first |
void |
put(Object key,
Object value,
boolean strict)
Enabled: Does not remove garbage first. |
void |
removeAll()
Enabled: Does not remove garbage first |
void |
removeKey(Object key,
boolean strict)
Enabled: Does not remove garbage first. |
int |
size()
Enabled: Does *not* remove garbage first, but affected when garbage is removed. |
Class |
valueType()
Enabled: Does not remove garbage first |
Methods inherited from class org.erights.e.elib.tables.FlexMap |
__optUncall, clone, domain, fromColumns, fromPairs, fromTypes, fromTypes, interning, interning, make, make, put, putAll, putAll, readOnly, removeKey, removeKeys, removeKeys, snapshot |
Methods inherited from class org.erights.e.elib.tables.EMap |
and, butNot, contains, diverge, diverge, extract, get, getKeys, getPair, getPair, getValues, intersects, iterate, maps, optExtract, or, or, printOn, sortKeys, sortKeys, sortValues, sortValues, toString, with, without |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
static final long serialVersionUID
private final Class myValueType
private final FlexMap myStuff
Constructor Detail |
public WeakValueMap(Class keyType, Class valueType)
public WeakValueMap()
Method Detail |
public int size()
size
in class EMap
public Object getKeys(Class type)
When used in concert with getValues, be sure to call getValues first and hold on to the result when calling getKeys, so that none of the values will be become garbage between the two operations.
Or, better yet, just call getPair(), which is safe on all kinds of maps.
getKeys
in class EMap
public Object getValues(Class type)
getValues
in class EMap
public Class keyType()
keyType
in class EMap
public Class valueType()
valueType
in class EMap
public Object get(Object key, Object instead)
get
in class EMap
key
- nullOk;instead
- nullOk;
org.erights.e.elib.ref.Ref#isSettled
public void put(Object key, Object value, boolean strict)
WeakValueMap doesn't support strict=true.
put
in class FlexMap
org.erights.e.elib.ref.Ref#isSettled
public void removeKey(Object key, boolean strict)
WeakValueMap doesn't support strict=true.
removeKey
in class FlexMap
key
- the key to removepublic void removeAll()
removeAll
in class FlexMap
public void __printOn(TextWriter out) throws IOException
__printOn
in interface EPrintable
__printOn
in class FlexMap
IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |