Type Params | Return Type | Name and description |
---|---|---|
|
public void |
clear() |
|
public boolean |
containsKey(Object key) |
|
public boolean |
containsValue(Object value) |
|
public Set<Map.Entry<K, V>> |
entrySet() |
|
public boolean |
equals(Object obj) |
|
public V |
get(Object key) Returns the value to which the specified key is mapped, or the default value as specified by the initializing closure if this map contains no mapping for the key. |
|
public int |
hashCode() |
|
public boolean |
isEmpty() |
|
public Set<K> |
keySet() |
<K, V> |
public static Map<K, V> |
newInstance(Map<K, V> m, Closure<V> initClosure) Decorates the given Map allowing a default value to be specified. |
<K, V> |
public static Map<K, V> |
newInstance(Map<K, V> m, boolean autoGrow, boolean autoShrink, Closure<V> initClosure) Decorates the given Map allowing a default value to be specified. |
|
public V |
put(K key, V value) Associates the specified value with the specified key in this map. |
|
public void |
putAll(Map<? extends K, ? extends V> m) |
|
public V |
remove(Object key) |
|
public int |
size() |
|
public Collection<V> |
values() |
Returns the value to which the specified key is mapped,
or the default value as specified by the initializing closure
if this map contains no mapping for the key.
If autoGrow
is true and the initializing closure is called,
the map is modified to contain the new key and value so that the calculated
value is effectively cached if needed again.
Otherwise, the map will be unchanged.
Decorates the given Map allowing a default value to be specified.
m
- a Map to wrapinitClosure
- the closure which when passed the key
returns the default value Decorates the given Map allowing a default value to be specified.
Allows the behavior to be configured using autoGrow
and autoShrink
parameters.
The value of autoShrink
doesn't alter any values in the initial wrapped map, but you
can start with an empty map and use putAll
if you really need the minimal backing map value.
m
- a Map to wrapautoGrow
- when true, also mutate the map adding in this value; otherwise, don't mutate the map, just return to calculated valueautoShrink
- when true, ensure the key will be removed if attempting to store the default value using put or putAllinitClosure
- the closure which when passed the key
returns the default value Associates the specified value with the specified key in this map.
If autoShrink
is true, the initializing closure is called
and if it evaluates to the value being stored, the value will not be stored
and indeed any existing value will be removed. This can be useful when trying
to keep the memory requirements small for large key sets where only a spare
number of entries differ from the default.
key
if any, otherwise null
.