|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.millscript.commons.util.map.AbstractIMap<K,V>
org.millscript.commons.util.map.AbstractUMap<K,V>
org.millscript.commons.util.map.AbstractEMap<K,V>
org.millscript.commons.util.map.AbstractEReferenceHashMap<K,V>
public abstract class AbstractEReferenceHashMap<K,V>
This class provides a mutable hash Map implementation that
stores keys using Reference objects. This allows
mappings within the map to be removed at the discretion of the garbage
collector, depending on the type of reference used.
| Nested Class Summary | |
|---|---|
static class |
AbstractEReferenceHashMap.HashMapIterator<K,V>
This class implements a map iterator which iterates over an array of hash buckets, sharing the backing store with it's enclosing mutable map. |
static class |
AbstractEReferenceHashMap.HashMapKeysIterator<K>
This class implements a map iterator which iterates over an array of hash map buckets, returning each maplet key, sharing the backing store with it's enclosing mutable map. |
static class |
AbstractEReferenceHashMap.HashMapKeysList<K>
This class implements an immutable list which is backed by an array of hash map buckets, but NOTE the values in the list are actually the individual hash maplet keys. |
static class |
AbstractEReferenceHashMap.HashMapMapletIterator<K,V>
This class implements a map iterator which iterates over an array of hash map buckets, returning each maplet as the value. |
static class |
AbstractEReferenceHashMap.HashMapMapletList<K,V>
This class implements an immutable list which is backed by an array of hash map buckets, but NOTE the values in the list are actually the individual hash maplets themselves. |
static class |
AbstractEReferenceHashMap.HashMapValuesIterator<V>
This class implements a map iterator which iterates over an array of hash map buckets, returning each maplet value, sharing the backing store with it's enclosing mutable map. |
static class |
AbstractEReferenceHashMap.HashMapValuesList<V>
This class implements an immutable list which is backed by an array of hash map buckets, but NOTE the values in the list are actually the individual hash maplet values. |
| Field Summary | |
|---|---|
protected java.lang.ref.ReferenceQueue<K> |
referenceQueue
The reference queue we'll use to keep track of collected keys. |
| Constructor Summary | |
|---|---|
AbstractEReferenceHashMap()
Constructs a new, emtpy mutable hash map. |
|
AbstractEReferenceHashMap(IMap<K,V> map)
Constructs a new mutable hash map which contains all the mappings from the specified map. |
|
| Method Summary | |
|---|---|
protected void |
clearQueuedReferences()
This method should be called to clear any queued references, which implies the keys are no longer valid in this mapping. |
java.lang.Object |
clone()
|
boolean |
contains(K key,
V value)
Returns true if this map contains a mapping from the
specified key to the specified value. |
boolean |
containsKey(K key)
Returns true if this map contains an entry for the
specified key. |
boolean |
containsValue(V value)
Returns true if this map contains an entry with the
specified value. |
V |
get(K key)
Returns the value associated with the specified key, or the default value if no such mapping exists. |
void |
insert(K key,
V value)
Inserts the specified key-value pair into this map, associating the key with the value. |
protected void |
insertWithRehash(K key,
V value)
Inserts the specified key-value mapping after performing a rehash of the backing store to increase it's size. |
MapIterator<K,V> |
iterator(boolean share)
Returns an iterator over the mappings in this map. |
abstract java.lang.ref.Reference<K> |
makeReference(K key)
|
void |
remove(K key,
V value)
Removes the specified key-value pair from this map. |
void |
removeAll()
Removes all the mappings from this map. |
void |
removeKey(K key)
Removes the mapping for the specified key. |
void |
removeValue(V value)
Removes any mappings from this map which map to the specified value. |
protected IList<K> |
sharedKeyList()
|
protected IList<Maplet<K,V>> |
sharedMapletList()
|
protected IList<V> |
sharedValueList()
|
int |
size()
Returns the number of mappings defined in this map. |
void |
update(K key,
V value)
Updates the mapping for the specified key with the specified value, changing the previous value. |
| Methods inherited from class org.millscript.commons.util.map.AbstractEMap |
|---|
insert, insertAll, remove, removeAll |
| Methods inherited from class org.millscript.commons.util.map.AbstractUMap |
|---|
update, updateAll |
| Methods inherited from class org.millscript.commons.util.map.AbstractIMap |
|---|
contains, containsAll, decorate, equals, getDefault, hashCode, isEmtpy, keyList, mapletList, setDefault, toString, valueList |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.millscript.commons.util.UMap |
|---|
update, updateAll |
| Methods inherited from interface org.millscript.commons.util.IMap |
|---|
contains, containsAll, equals, getDefault, hashCode, isEmtpy, keyList, mapletList, setDefault, valueList |
| Field Detail |
|---|
protected final transient java.lang.ref.ReferenceQueue<K> referenceQueue
| Constructor Detail |
|---|
public AbstractEReferenceHashMap()
public AbstractEReferenceHashMap(IMap<K,V> map)
map - the Map to copy mappings from| Method Detail |
|---|
protected void clearQueuedReferences()
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionObject.clone()
public boolean contains(K key,
V value)
IMaptrue if this map contains a mapping from the
specified key to the specified value.
contains in interface IMap<K,V>key - the key whose presence to testvalue - the value which must match that stored against the
specified key
true if this map contains a mapping for the
specified key-value combinationIMap.contains(java.lang.Object, java.lang.Object)public boolean containsKey(K key)
IMaptrue if this map contains an entry for the
specified key.
containsKey in interface IMap<K,V>key - the key whose presence to test
true if this map contains a mapping for the
specified keyIMap.containsKey(java.lang.Object)public boolean containsValue(V value)
IMaptrue if this map contains an entry with the
specified value.
containsValue in interface IMap<K,V>value - the value whose presence to test
true if this map contains a mapping with the
specified valueIMap.containsValue(java.lang.Object)public V get(K key)
IMap
get in interface IMap<K,V>key - the key whose associated value to return
IMap.get(java.lang.Object)
public void insert(K key,
V value)
EMap
insert in interface EMap<K,V>key - the key to associate the value withvalue - the value to associate the key withEMap.insert(java.lang.Object, java.lang.Object)
protected void insertWithRehash(K key,
V value)
key - the new key to add to the mappingvalue - the new value to associate with the given keypublic MapIterator<K,V> iterator(boolean share)
IMap
iterator in interface IMap<K,V>share - if true this instances backing store should be
shared with the returned list, otherwise any backing store will be copied.
IMap.iterator(boolean)public abstract java.lang.ref.Reference<K> makeReference(K key)
public void remove(K key,
V value)
EMap
remove in interface EMap<K,V>key - the key to remove from this map if it is associated with
the specified valuevalue - the value to remove from this map if it is associated with
the specified keyEMap.remove(java.lang.Object, java.lang.Object)public void removeAll()
EMap
removeAll in interface EMap<K,V>EMap.removeAll()public void removeKey(K key)
EMap
removeKey in interface EMap<K,V>key - the key to remove from this mapEMap.removeKey(java.lang.Object)public void removeValue(V value)
EMap
removeValue in interface EMap<K,V>value - the value to remove from this mapEMap.removeValue(java.lang.Object)protected IList<K> sharedKeyList()
sharedKeyList in class AbstractIMap<K,V>AbstractIMap.sharedKeyList()protected IList<Maplet<K,V>> sharedMapletList()
sharedMapletList in class AbstractIMap<K,V>AbstractIMap.sharedMapletList()protected IList<V> sharedValueList()
sharedValueList in class AbstractIMap<K,V>AbstractIMap.sharedValueList()public int size()
IMap
size in interface IMap<K,V>IMap.size()
public void update(K key,
V value)
UMap
update in interface UMap<K,V>key - the key to associate the value withvalue - the value to associate the key withUMap.update(java.lang.Object, java.lang.Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||