|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
org.cometd.util.ImmutableHashMap<K,V>
K - The key typeV - The key valuepublic class ImmutableHashMap<K,V>
Immutable Hash Map.
FixedHashMap is a hash Map implementation that provides both
mutable and immutable APIs to the same data structure. The immutable
API applies to deep structures of FixedHashMaps of FixedHashMaps.
The implementation uses a fixed size array of hash entries whose keys and hashes are retained when removed from the map, which is optimal for pooled maps that will frequently contain the same key over and over.
FixedMap keys cannot be null. FixedMap values may be null, but null values are treated exactly as if the entry is not added to the map. Setting a value to null is equivalent to removing the entry
The #getEntry(Object)) may be used to obtain references
to Map.Entry instances that will not change for a given key and thus
may be used for direct access to the related value.
This map is not thread safe and multiple threads should not access the map without some synchronization
.
| Nested Class Summary | |
|---|---|
static class |
ImmutableHashMap.ImmutableEntry<K,V>
|
class |
ImmutableHashMap.Mutable
|
static class |
ImmutableHashMap.MutableEntry<K,V>
|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
ImmutableHashMap()
|
|
ImmutableHashMap(int nominalSize)
|
|
| Method Summary | |
|---|---|
ImmutableHashMap.Mutable |
asMutable()
Get the immutable API to this map. |
boolean |
containsKey(Object key)
|
Set<Map.Entry<K,V>> |
entrySet()
|
V |
get(Object key)
|
Map.Entry<K,V> |
getEntry(K key)
Get an entry reference. |
ImmutableHashMap.ImmutableEntry<K,V> |
getEntryReference(K key)
Get an entry reference. |
protected void |
onChange(K key)
Called if the map is about to be changed. |
int |
size()
|
| Methods inherited from class java.util.AbstractMap |
|---|
clear, clone, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, toString, values |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
clear, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, values |
| Constructor Detail |
|---|
public ImmutableHashMap()
public ImmutableHashMap(int nominalSize)
| Method Detail |
|---|
public ImmutableHashMap.Mutable asMutable()
public Map.Entry<K,V> getEntry(K key)
key - The key to lookup.
public ImmutableHashMap.ImmutableEntry<K,V> getEntryReference(K key)
The entries stored in the top level of the maps entry buckets are never deleted, only nulled. Thus references returned to them can be kept over calls to reset and used to directly access the value without a hash lookup.
This method returns only such top level entries.
key - The key to lookup.
IllegalStateException - if key is not a top level entry
protected void onChange(K key)
throws UnsupportedOperationException
key - The key to be changed, or null if multiple keys.
UnsupportedOperationException - If change is not allowed/public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>entrySet in class AbstractMap<K,V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>public V get(Object key)
get in interface Map<K,V>get in class AbstractMap<K,V>public int size()
size in interface Map<K,V>size in class AbstractMap<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||