| 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 library dart2js.mirrors.util; | 5 library dart2js.mirrors.util; |
| 6 | 6 |
| 7 import 'dart:collection' show Maps; | 7 import 'dart:collection' show Maps; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * An abstract map implementation. This class can be used as a superclass for | 10 * An abstract map implementation. This class can be used as a superclass for |
| 11 * implementing maps, requiring only the further implementation of the | 11 * implementing maps, requiring only the further implementation of the |
| 12 * [:operator []:], [:forEach:] and [:length:] methods to provide a fully | 12 * [:operator []:], [:forEach:] and [:length:] methods to provide a fully |
| 13 * implemented immutable map. | 13 * implemented immutable map. |
| 14 */ | 14 */ |
| 15 // TODO(lrn): Consider using UnmodifiableBaseMap/UnmodifiableMapWrapper | |
| 16 // for these classes, or just rewrite for a bit more efficiency. | |
| 17 abstract class AbstractMap<K, V> implements Map<K, V> { | 15 abstract class AbstractMap<K, V> implements Map<K, V> { |
| 18 AbstractMap(); | 16 AbstractMap(); |
| 19 | 17 |
| 20 AbstractMap.from(Map<K, V> other) { | 18 AbstractMap.from(Map<K, V> other) { |
| 21 other.forEach((k,v) => this[k] = v); | 19 other.forEach((k,v) => this[k] = v); |
| 22 } | 20 } |
| 23 | 21 |
| 24 void operator []=(K key, value) { | 22 void operator []=(K key, value) { |
| 25 throw new UnsupportedError('[]= is not supported'); | 23 throw new UnsupportedError('[]= is not supported'); |
| 26 } | 24 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 173 |
| 176 void forEach(void f(K key, Vout value)) { | 174 void forEach(void f(K key, Vout value)) { |
| 177 _map.forEach((K k, Vin v) { | 175 _map.forEach((K k, Vin v) { |
| 178 var value = _filter(v); | 176 var value = _filter(v); |
| 179 if (value != null) { | 177 if (value != null) { |
| 180 f(k, value); | 178 f(k, value); |
| 181 } | 179 } |
| 182 }); | 180 }); |
| 183 } | 181 } |
| 184 } | 182 } |
| OLD | NEW |