Map<K,V>
A map associates or "maps" keys of type K to values of type V. Each key can map to at most one value -- a map cannot contain duplicate keys. See Maps for an overview of maps.
The following operations are supported for maps:
+ : (Map<K,V>, Map<K,V>) -> Map<K,V>
Concatenates two maps. If a key exists in both maps, the mapping from the right-hand side is used.
[] : (Map<K,V>, K) -> V
Given a map and a key, returns the value for the given key in the map, or null if the key is not in the map.
in, !in : (K, Map<K,V>) -> Boolean
Given a key and a map, returns true if the map contains the key and the corresponding value is truthy (e.g. not null, 0, or false).
The following methods are available for a map:
any( condition: (K,V) -> Boolean ) -> Boolean
Returns true if any key-value pair in the map satisfies the given condition. The closure should accept two parameters corresponding to the key and value of an entry.
containsKey( key: K ) -> Boolean
Returns true if the map contains a mapping for the given key.
containsValue( value: V ) -> Boolean
Returns true if the map maps one or more keys to the given value.
each( action: (K,V) -> () )
Invokes the given closure for each key-value pair in the map. The closure should accept two parameters corresponding to the key and value of an entry.
entrySet() -> Set<(K,V)>
Returns a set of the key-value pairs in the map.
every( condition: (K,V) -> Boolean ) -> Boolean
Returns true if every key-value pair in the map satisfies the given condition. The closure should accept two parameters corresponding to the key and value of an entry.
isEmpty() -> Boolean
Returns true if the map is empty.
keySet() -> Set<K>
Returns a set of the keys in the map.
size() -> Integer
Returns the number of key-value pairs in the map.
subMap( keys: Iterable<K> ) -> Map<K,V>
Returns a sub-map containing the given keys.
values() -> Bag<V>
Returns a collection of the values in the map.