|
|
||||||||||
| 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.FlexMapImpl
An implementation of FlexMap by MarkM & Sidney, based on an earlier design by Dan.
| Field Summary | |
static int |
DEFAULT_INIT_CAPACITY
Similarly, the default initial capacity of java.util.Hashtable is 101. |
static float |
DEFAULT_LOAD_FACTOR
This default load factor is calculated to preserve the same marginal space cost per hash map entry as java.util.Hashtable, given its default load factor of 0.75. |
private static int |
DEFAULT_THRESH
For either map, multiplying the two defaults gives the same default threshold -- how many a default map can hold without growing: 75. |
(package private) KeyColumn |
myKeys
|
(package private) float |
myLoadFactor
The load factor for the map. |
(package private) ShareCount |
myShareCount
|
(package private) int |
mySizeThreshold
The current size threshold for the map, that is, the number of elements to hold before growing. |
(package private) Column |
myValues
|
(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 | |
|
FlexMapImpl()
Reasonable defaults |
|
FlexMapImpl(Class keyType,
Class valueType)
Reasonable defaults |
|
FlexMapImpl(Class keyType,
Class valueType,
int initCapacity)
|
|
FlexMapImpl(Class keyType,
Class valueType,
int initCapacity,
float loadFactor)
|
|
FlexMapImpl(int initialCapacity)
Reasonable defaults |
|
FlexMapImpl(int initialCapacity,
float loadFactor)
Reasonable defaults |
private |
FlexMapImpl(KeyColumn keys,
Column values)
Reasonable defaults |
(package private) |
FlexMapImpl(KeyColumn keys,
Column values,
float loadFactor)
|
(package private) |
FlexMapImpl(KeyColumn keys,
Column values,
float loadFactor,
ShareCount shareCount)
|
| Method Summary | |
FlexMap |
diverge(Class kType,
Class vType)
Unlike java.util.Hashtable, this part efficiently makes a lazy copy by copy-on-write sharing. |
Object |
get(Object key)
Returns the value to which the key is mapped in this map. |
Object |
get(Object key,
Object instead)
Returns the value to which the key is mapped in this map. |
Object |
getKeys(Class type)
Enabled: Returns a divergent array-of-type of all the keys in order. |
Object |
getValues(Class type)
Enabled: Returns a divergent array-of-type of all the values in order. |
void |
iterate(AssocFunc func)
Enabled: Call 'func' with each key-value pair in the table, in order. |
Class |
keyType()
All keys in this map must be of this type |
boolean |
maps(Object key)
Returns true if the specified object is a key in the collection, as defined by the equality function of the collection. |
void |
put(Object key,
Object value,
boolean strict)
Enabled: Causes 'key' to map to 'value'. |
(package private) void |
rehash()
|
void |
removeAll()
Rather than doing a write-fault (which would make a private copy to be immediately dropped) this decrements the sharing count and re-initializes. |
void |
removeKey(Object key,
boolean strict)
Enabled: Removes the given key (or its equivalent, according to the equal function) from the collection. |
int |
size()
The number of keys in the collection |
Class |
valueType()
All values in this map must be of this type |
(package private) void |
writeFault()
|
private Object |
writeReplace()
Given that cmap is a snapshot() of this map, writeReplace() unserializes to a promise for cmap.diverge(keyType, valueType). |
| Methods inherited from class org.erights.e.elib.tables.FlexMap |
__optUncall, __printOn, 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, extract, getKeys, getPair, getPair, getValues, intersects, 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
public static final float DEFAULT_LOAD_FACTOR
public static final int DEFAULT_INIT_CAPACITY
private static final int DEFAULT_THRESH
KeyColumn myKeys
Column myValues
int mySizeThreshold
float myLoadFactor
ShareCount myShareCount
| Constructor Detail |
public FlexMapImpl()
public FlexMapImpl(int initialCapacity)
public FlexMapImpl(int initialCapacity,
float loadFactor)
public FlexMapImpl(Class keyType,
Class valueType)
private FlexMapImpl(KeyColumn keys,
Column values)
FlexMapImpl(KeyColumn keys,
Column values,
float loadFactor)
FlexMapImpl(KeyColumn keys,
Column values,
float loadFactor,
ShareCount shareCount)
public FlexMapImpl(Class keyType,
Class valueType,
int initCapacity)
public FlexMapImpl(Class keyType,
Class valueType,
int initCapacity,
float loadFactor)
| Method Detail |
private Object writeReplace()
throws ObjectStreamException
ObjectStreamException
public Object get(Object key)
throws IndexOutOfBoundsException
get in class EMapkey - nullOk;
IndexOutOfBoundsException - if key doesn't map to anything.org.erights.e.elib.ref.Ref#isSettled
public Object get(Object key,
Object instead)
get in class EMapkey - nullOk;instead - nullOk;
org.erights.e.elib.ref.Ref#isSettledpublic int size()
size in class EMappublic void iterate(AssocFunc func)
EMap
iterate in interface Iteratableiterate in class EMappublic boolean maps(Object key)
maps in class EMapkey - the object to look for
public Object getKeys(Class type)
EMapXXX Should 'type' be a ValueGuard rather than a Class?
getKeys in class EMappublic Object getValues(Class type)
EMapXXX Should 'type' be a ValueGuard rather than a Class?
getValues in class EMap
public void put(Object key,
Object value,
boolean strict)
FlexMapUnlike Dictionary, this doesn't return the old value. If you want it, use 'get' first.
If the key is overwritten, then the key order is unchanged. If the key is novel, it's added to the end of the order.
put in class FlexMaporg.erights.e.elib.ref.Ref#isSettledvoid rehash()
public void removeKey(Object key,
boolean strict)
FlexMapUnlike Dictionary, this does not return the old value. If you want this for a FlexMap, use 'get' first.
If 'key' wasn't in the table, the table (including its order) is unmodified. Otherwise, the last key in the table is moved in the ordering to take the place of the removed 'key'.
removeKey in class FlexMapkey - the key to removepublic void removeAll()
removeAll in class FlexMap
public FlexMap diverge(Class kType,
Class vType)
diverge in class EMappublic Class keyType()
keyType in class EMappublic Class valueType()
valueType in class EMapvoid writeFault()
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||