Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: sdk/lib/collection/maps.dart

Issue 2467113003: Make EfficientLength extend Iterable. (Closed)
Patch Set: Reverted, prepare to reland. Make new test not break web-testing framework. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sdk/lib/collection/list.dart ('k') | sdk/lib/collection/queue.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 abstract class UnmodifiableMapBase<K, V> = 104 abstract class UnmodifiableMapBase<K, V> =
105 MapBase<K, V> with _UnmodifiableMapMixin<K, V>; 105 MapBase<K, V> with _UnmodifiableMapMixin<K, V>;
106 106
107 /** 107 /**
108 * Implementation of [Map.values] based on the map and its [Map.keys] iterable. 108 * Implementation of [Map.values] based on the map and its [Map.keys] iterable.
109 * 109 *
110 * Iterable that iterates over the values of a `Map`. 110 * Iterable that iterates over the values of a `Map`.
111 * It accesses the values by iterating over the keys of the map, and using the 111 * It accesses the values by iterating over the keys of the map, and using the
112 * map's `operator[]` to lookup the keys. 112 * map's `operator[]` to lookup the keys.
113 */ 113 */
114 class _MapBaseValueIterable<K, V> extends Iterable<V> 114 class _MapBaseValueIterable<K, V> extends EfficientLengthIterable<V> {
115 implements EfficientLength {
116 final Map<K, V> _map; 115 final Map<K, V> _map;
117 _MapBaseValueIterable(this._map); 116 _MapBaseValueIterable(this._map);
118 117
119 int get length => _map.length; 118 int get length => _map.length;
120 bool get isEmpty => _map.isEmpty; 119 bool get isEmpty => _map.isEmpty;
121 bool get isNotEmpty => _map.isNotEmpty; 120 bool get isNotEmpty => _map.isNotEmpty;
122 V get first => _map[_map.keys.first]; 121 V get first => _map[_map.keys.first];
123 V get single => _map[_map.keys.single]; 122 V get single => _map[_map.keys.single];
124 V get last => _map[_map.keys.last]; 123 V get last => _map[_map.keys.last];
125 124
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 map[keyIterator.current] = valueIterator.current; 345 map[keyIterator.current] = valueIterator.current;
347 hasNextKey = keyIterator.moveNext(); 346 hasNextKey = keyIterator.moveNext();
348 hasNextValue = valueIterator.moveNext(); 347 hasNextValue = valueIterator.moveNext();
349 } 348 }
350 349
351 if (hasNextKey || hasNextValue) { 350 if (hasNextKey || hasNextValue) {
352 throw new ArgumentError("Iterables do not have same length."); 351 throw new ArgumentError("Iterables do not have same length.");
353 } 352 }
354 } 353 }
355 } 354 }
OLDNEW
« no previous file with comments | « sdk/lib/collection/list.dart ('k') | sdk/lib/collection/queue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698