UnmodifiableMapView<K, V> class
An unmodifiable map.
An UnmodifiableMapView contains a Map object and ensures that it does not change. Methods that would change the map, such as addAll and remove, throw an UnsupportedError. Permitted operations defer to the wrapped map.
class UnmodifiableMapView<K, V> extends DelegatingMap<K, V> with UnmodifiableMapMixin<K, V> { UnmodifiableMapView(Map<K, V> baseMap) : super(baseMap); }
Extends
DelegatingMap<K, V> > UnmodifiableMapView<K, V>
Mixins
Constructors
new UnmodifiableMapView(Map<K, V> baseMap) #
Creates a Map instance with the default implementation, LinkedHashMap.
A LinkedHashMap
requires the keys to implement compatible
operator==
and hashCode
, and it allows null as a key.
UnmodifiableMapView(Map<K, V> baseMap) : super(baseMap);
Properties
final bool isEmpty #
final bool isNotEmpty #
final Iterable<K> keys #
The keys of this
.
The returned iterable has efficient length
and contains
operations,
based on length and containsKey of the map.
Iterable<K> get keys => _base.keys;
final int length #
Operators
V operator [](Object key) #
Returns the value for the given key or null if key is not in the map. Because null values are supported, one should either use containsKey to distinguish between an absent key and a null value, or use the putIfAbsent method.
V operator [](Object key) => _base[key];
void operator []=(K key, V value) #
Throws an UnsupportedError; operations that change the map are disallowed.
void operator []=(K key, V value) => _throw();
Methods
void addAll(Map<K, V> other) #
Throws an UnsupportedError; operations that change the map are disallowed.
void addAll(Map<K, V> other) => _throw();
void clear() #
Throws an UnsupportedError; operations that change the map are disallowed.
void clear() => _throw();
bool containsKey(Object key) #
bool containsValue(Object value) #
void forEach(void f(K key, V value)) #
V putIfAbsent(K key, V ifAbsent()) #
Throws an UnsupportedError; operations that change the map are disallowed.
V putIfAbsent(K key, V ifAbsent()) { _throw(); }
V remove(K key) #
Throws an UnsupportedError; operations that change the map are disallowed.
V remove(K key) { _throw(); }