|
||||||||||
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 | |
---|---|
class |
ImmutableHashMap.Mutable
|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Constructor Summary | |
---|---|
ImmutableHashMap()
|
|
ImmutableHashMap(int nominalSize)
|
Method Summary | |
---|---|
ImmutableHashMap.Mutable |
asMutable()
Get the immutable API to this map. |
boolean |
containsKey(java.lang.Object key)
|
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
|
V |
get(java.lang.Object key)
|
java.util.Map.Entry<K,V> |
getEntry(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 java.util.Map.Entry<K,V> getEntry(K key)
key
-
protected void onChange(K key) throws java.lang.UnsupportedOperationException
key
- The key to be changed, or null if multiple keys.
java.lang.UnsupportedOperationException
- If change is not allowed/public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in interface java.util.Map<K,V>
entrySet
in class java.util.AbstractMap<K,V>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,V>
containsKey
in class java.util.AbstractMap<K,V>
public V get(java.lang.Object key)
get
in interface java.util.Map<K,V>
get
in class java.util.AbstractMap<K,V>
public int size()
size
in interface java.util.Map<K,V>
size
in class java.util.AbstractMap<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |