public class ManMapExt extends Object
Constructor and Description |
---|
ManMapExt() |
Modifier and Type | Method and Description |
---|---|
static <K,V> Map<K,V> |
mapOf(manifold.rt.api.util.Pair<K,V>... entries)
For use with the
key and value binding expression syntax using Pair.and . |
static <K,V> V |
set(Map<K,V> thiz,
K key,
V value)
Implements the indexed assignment operator for Map to enable the syntax:
map[key] = value
|
public static <K,V> V set(Map<K,V> thiz, K key, V value)
map[key] = value
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyUnsupportedOperationException
- if the put operation
is not supported by this mapClassCastException
- if the class of the specified key or value
prevents it from being stored in this mapNullPointerException
- if the specified key or value is null
and this map does not permit null keys or valuesIllegalArgumentException
- if some property of the specified key
or value prevents it from being stored in this map
@SafeVarargs public static <K,V> Map<K,V> mapOf(manifold.rt.api.util.Pair<K,V>... entries)
key and value
binding expression syntax using Pair.and
.
import static manifold.rt.api.util.Pair.and;
Map<String, Integer> scores =
mapOf("Moe" and 100, "Larry" and 107, "Curly" and 111);
Returns a new read-only map with the specified contents, given as a list of pairs where the first value is the key and the second is the value.
If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.
Entries of the map are iterated in the order they were specified.
entries
- key/value pairs, for use with the key and value
binding expression syntax via Pair.and
.UnsupportedOperationException
- if the put operation
is not supported by this mapClassCastException
- if the class of the specified key or value
prevents it from being stored in this mapNullPointerException
- if the specified key or value is null
and this map does not permit null keys or valuesIllegalArgumentException
- if some property of the specified key
or value prevents it from being stored in this map
Copyright © 2024. All rights reserved.