|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.util.LocalMap<K,V>
public final class LocalMap<K,V>
This class represents a map which can be temporarily modified
without impacting other threads (locally
scoped changes).
Operation on instances of this class are completely thread-safe.
For example:
public class XMLFormat {
static LocalMap
Note: Because key-value mappings are inherited, the semantic of
remove(java.lang.Object) and clear() is slightly modified (associate
null values instead of removing the entries).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
LocalMap()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all mappings from this map (sets the local values to null). |
boolean |
containsKey(java.lang.Object key)
Indicates if this map contains a mapping for the specified key. |
boolean |
containsValue(java.lang.Object value)
Indicates if this map associates one or more keys to the specified value. |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
Returns a FastCollection view of the mappings contained in this
map. |
V |
get(java.lang.Object key)
Returns the value to which this map associates the specified key. |
boolean |
isEmpty()
Indicates if this map contains no key-value mappings. |
java.util.Set<K> |
keySet()
Returns a FastCollection view of the keys contained in this map. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this map. |
void |
putAll(java.util.Map<? extends K,? extends V> map)
Copies all of the mappings from the specified map to this map. |
V |
putDefault(K key,
V defaultValue)
Sets the default value for the specified key (typically done at initialization). |
V |
remove(java.lang.Object key)
Removes the mapping for this key from this map if present (sets the local value to null). |
LocalMap<K,V> |
setKeyComparator(FastComparator<? super K> keyComparator)
Sets the key comparator for this local map. |
LocalMap<K,V> |
setValueComparator(FastComparator<? super V> valueComparator)
Sets the value comparator for this local map. |
int |
size()
Returns the number of key-value mappings in this map. |
java.util.Collection<V> |
values()
Returns a FastCollection view of the values contained in this
map. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public LocalMap()
| Method Detail |
|---|
public LocalMap<K,V> setKeyComparator(FastComparator<? super K> keyComparator)
keyComparator - the key comparator.
thispublic LocalMap<K,V> setValueComparator(FastComparator<? super V> valueComparator)
valueComparator - the value comparator.
this
public V putDefault(K key,
V defaultValue)
key - the key with which the specified value is to be associated.defaultValue - the default value to be associated with the
specified key.
null if there was no mapping for key. A
null return can also indicate that the map
previously associated null with the specified key.
java.lang.NullPointerException - if the key is null.public int size()
size in interface java.util.Map<K,V>public boolean isEmpty()
isEmpty in interface java.util.Map<K,V>true if this map contains no key-value mappings;
false otherwise.public boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Map<K,V>key - the key whose presence in this map is to be tested.
true if this map contains a mapping for the
specified key; false otherwise.
java.lang.NullPointerException - if the key is null.public boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Map<K,V>value - the value whose presence in this map is to be tested.
true if this map maps one or more keys to the
specified value.
java.lang.NullPointerException - if the key is null.public V get(java.lang.Object key)
get in interface java.util.Map<K,V>key - the key whose associated value is to be returned.
null if there is no mapping for the key.
java.lang.NullPointerException - if key is null.
public V put(K key,
V value)
put in interface java.util.Map<K,V>key - the key with which the specified value is to be associated.value - the value to be associated with the specified key.
null if there was no mapping for key. A
null return can also indicate that the map
previously associated null with the specified key.
java.lang.NullPointerException - if the key is null.public void putAll(java.util.Map<? extends K,? extends V> map)
putAll in interface java.util.Map<K,V>map - the mappings to be stored in this map.
java.lang.NullPointerException - the specified map is null,
or the specified map contains null keys.public V remove(java.lang.Object key)
null).
remove in interface java.util.Map<K,V>key - the key whose value is set to null
put(key, null)
java.lang.NullPointerException - if the key is null.public void clear()
null).
clear in interface java.util.Map<K,V>public java.util.Set<K> keySet()
FastCollection view of the keys contained in this map.
keySet in interface java.util.Map<K,V>FastCollection).public java.util.Collection<V> values()
FastCollection view of the values contained in this
map.
values in interface java.util.Map<K,V>FastCollection).public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
FastCollection view of the mappings contained in this
map.
entrySet in interface java.util.Map<K,V>FastCollection).
|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||