OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart.collection; | 5 part of dart.collection; |
6 | 6 |
7 /** | 7 /** |
8 * Base class for implementing a [Map]. | 8 * Base class for implementing a [Map]. |
9 * | 9 * |
10 * This class has a basic implementation of all but five of the members of | 10 * This class has a basic implementation of all but five of the members of |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 V get current => _current; | 152 V get current => _current; |
153 } | 153 } |
154 | 154 |
155 /** | 155 /** |
156 * Mixin that overrides mutating map operations with implementations that throw. | 156 * Mixin that overrides mutating map operations with implementations that throw. |
157 */ | 157 */ |
158 abstract class _UnmodifiableMapMixin<K, V> implements Map<K, V> { | 158 abstract class _UnmodifiableMapMixin<K, V> implements Map<K, V> { |
| 159 /** This operation is not supported by an unmodifiable map. */ |
159 void operator[]=(K key, V value) { | 160 void operator[]=(K key, V value) { |
160 throw new UnsupportedError("Cannot modify unmodifiable map"); | 161 throw new UnsupportedError("Cannot modify unmodifiable map"); |
161 } | 162 } |
| 163 /** This operation is not supported by an unmodifiable map. */ |
162 void addAll(Map<K, V> other) { | 164 void addAll(Map<K, V> other) { |
163 throw new UnsupportedError("Cannot modify unmodifiable map"); | 165 throw new UnsupportedError("Cannot modify unmodifiable map"); |
164 } | 166 } |
| 167 /** This operation is not supported by an unmodifiable map. */ |
165 void clear() { | 168 void clear() { |
166 throw new UnsupportedError("Cannot modify unmodifiable map"); | 169 throw new UnsupportedError("Cannot modify unmodifiable map"); |
167 } | 170 } |
| 171 /** This operation is not supported by an unmodifiable map. */ |
168 V remove(Object key) { | 172 V remove(Object key) { |
169 throw new UnsupportedError("Cannot modify unmodifiable map"); | 173 throw new UnsupportedError("Cannot modify unmodifiable map"); |
170 } | 174 } |
| 175 /** This operation is not supported by an unmodifiable map. */ |
171 V putIfAbsent(K key, V ifAbsent()) { | 176 V putIfAbsent(K key, V ifAbsent()) { |
172 throw new UnsupportedError("Cannot modify unmodifiable map"); | 177 throw new UnsupportedError("Cannot modify unmodifiable map"); |
173 } | 178 } |
174 } | 179 } |
175 | 180 |
176 /** | 181 /** |
177 * Wrapper around a class that implements [Map] that only exposes `Map` members. | 182 * Wrapper around a class that implements [Map] that only exposes `Map` members. |
178 * | 183 * |
179 * A simple wrapper that delegates all `Map` members to the map provided in the | 184 * A simple wrapper that delegates all `Map` members to the map provided in the |
180 * constructor. | 185 * constructor. |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 map[keyIterator.current] = valueIterator.current; | 350 map[keyIterator.current] = valueIterator.current; |
346 hasNextKey = keyIterator.moveNext(); | 351 hasNextKey = keyIterator.moveNext(); |
347 hasNextValue = valueIterator.moveNext(); | 352 hasNextValue = valueIterator.moveNext(); |
348 } | 353 } |
349 | 354 |
350 if (hasNextKey || hasNextValue) { | 355 if (hasNextKey || hasNextValue) { |
351 throw new ArgumentError("Iterables do not have same length."); | 356 throw new ArgumentError("Iterables do not have same length."); |
352 } | 357 } |
353 } | 358 } |
354 } | 359 } |
OLD | NEW |