public final class LocalMap extends Object implements Map
This class represents a map which can be temporarily modified without
impacting other threads (scoped changes).
Operation on instances of this class are 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 (association with
null values instead of removing the entries).
| Constructor and Description |
|---|
LocalMap()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all mappings from this map (sets the local values to
null). |
boolean |
containsKey(Object key)
Indicates if this map contains a mapping for the specified key.
|
boolean |
containsValue(Object value)
Indicates if this map associates one or more keys to the
specified value.
|
Set |
entrySet()
Returns a
FastCollection view of the mappings contained in this
map. |
Object |
get(Object key)
Returns the value to which this map associates the specified key.
|
Object |
getDefault(Object key)
Returns the default value for the specified key.
|
boolean |
isEmpty()
Indicates if this map contains no key-value mappings.
|
Set |
keySet()
Returns a
FastCollection view of the keys contained in this map. |
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this map.
|
void |
putAll(Map map)
Copies all of the mappings from the specified map to this map.
|
Object |
putDefault(Object key,
Object defaultValue)
Sets the default value for the specified key (typically done at
initialization).
|
Object |
remove(Object key)
Removes the mapping for this key from this map if present
(sets the local value to
null). |
LocalMap |
setKeyComparator(FastComparator keyComparator)
Sets the key comparator for this local map.
|
LocalMap |
setValueComparator(FastComparator valueComparator)
Sets the value comparator for this local map.
|
int |
size()
Returns the number of key-value mappings in this map.
|
Collection |
values()
Returns a
FastCollection view of the values contained in this
map. |
public LocalMap setKeyComparator(FastComparator keyComparator)
keyComparator - the key comparator.thispublic LocalMap setValueComparator(FastComparator valueComparator)
valueComparator - the value comparator.thispublic Object putDefault(Object key, Object 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.NullPointerException - if the key is null.public Object getDefault(Object key)
key - the key with which the default value is associated.null if there was no mapping for the key.NullPointerException - if the key is null.public int size()
public boolean isEmpty()
public boolean containsKey(Object key)
containsKey in interface Mapkey - the key whose presence in this map is to be tested.true if this map contains a mapping for the
specified key; false otherwise.NullPointerException - if the key is null.public boolean containsValue(Object value)
containsValue in interface Mapvalue - the value whose presence in this map is to be tested.true if this map maps one or more keys to the
specified value.NullPointerException - if the key is null.public Object get(Object key)
get in interface Mapkey - the key whose associated value is to be returned.null if there is no mapping for the key.NullPointerException - if key is null.public Object put(Object key, Object value)
put in interface Mapkey - 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.NullPointerException - if the key is null.public void putAll(Map map)
putAll in interface Mapmap - the mappings to be stored in this map.NullPointerException - the specified map is null,
or the specified map contains null keys.public Object remove(Object key)
null).remove in interface Mapkey - the key whose value is set to nullput(key, null)NullPointerException - if the key is null.public void clear()
null).public Set keySet()
FastCollection view of the keys contained in this map.keySet in interface MapFastCollection).public Collection values()
FastCollection view of the values contained in this
map.values in interface MapFastCollection).public Set entrySet()
FastCollection view of the mappings contained in this
map.entrySet in interface MapFastCollection).Copyright © 2005–2024 Javolution. All rights reserved.