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

Side by Side Diff: runtime/lib/collection_patch.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 | « runtime/lib/array_patch.dart ('k') | runtime/lib/growable_array.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'dart:typed_data'; 5 import 'dart:typed_data';
6 import 'dart:_internal' as internal; 6 import 'dart:_internal' as internal;
7 7
8 @patch class HashMap<K, V> { 8 @patch class HashMap<K, V> {
9 @patch factory HashMap({ bool equals(K key1, K key2), 9 @patch factory HashMap({ bool equals(K key1, K key2),
10 int hashCode(K key), 10 int hashCode(K key),
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 428
429 429
430 class _HashMapEntry { 430 class _HashMapEntry {
431 final key; 431 final key;
432 var value; 432 var value;
433 final int hashCode; 433 final int hashCode;
434 _HashMapEntry next; 434 _HashMapEntry next;
435 _HashMapEntry(this.key, this.value, this.hashCode, this.next); 435 _HashMapEntry(this.key, this.value, this.hashCode, this.next);
436 } 436 }
437 437
438 abstract class _HashMapIterable<E> extends IterableBase<E> 438 abstract class _HashMapIterable<E> extends EfficientLengthIterable<E> {
439 implements EfficientLength {
440 final HashMap _map; 439 final HashMap _map;
441 _HashMapIterable(this._map); 440 _HashMapIterable(this._map);
442 int get length => _map.length; 441 int get length => _map.length;
443 bool get isEmpty => _map.isEmpty; 442 bool get isEmpty => _map.isEmpty;
444 bool get isNotEmpty => _map.isNotEmpty; 443 bool get isNotEmpty => _map.isNotEmpty;
445 } 444 }
446 445
447 class _HashMapKeyIterable<K> extends _HashMapIterable<K> { 446 class _HashMapKeyIterable<K> extends _HashMapIterable<K> {
448 _HashMapKeyIterable(HashMap map) : super(map); 447 _HashMapKeyIterable(HashMap map) : super(map);
449 Iterator<K> get iterator => new _HashMapKeyIterator<K>(_map); 448 Iterator<K> get iterator => new _HashMapKeyIterator<K>(_map);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 var _nextEntry; 830 var _nextEntry;
832 var _previousEntry; 831 var _previousEntry;
833 _LinkedHashMapEntry(key, value, int hashCode, _LinkedHashMapEntry next, 832 _LinkedHashMapEntry(key, value, int hashCode, _LinkedHashMapEntry next,
834 this._previousEntry, this._nextEntry) 833 this._previousEntry, this._nextEntry)
835 : super(key, value, hashCode, next) { 834 : super(key, value, hashCode, next) {
836 _previousEntry._nextEntry = this; 835 _previousEntry._nextEntry = this;
837 _nextEntry._previousEntry = this; 836 _nextEntry._previousEntry = this;
838 } 837 }
839 } 838 }
840 839
841 class _LinkedHashMapKeyIterable<K> extends IterableBase<K> 840 class _LinkedHashMapKeyIterable<K> extends EfficientLengthIterable<K> {
842 implements EfficientLength {
843 LinkedHashMap<K, dynamic> _map; 841 LinkedHashMap<K, dynamic> _map;
844 _LinkedHashMapKeyIterable(this._map); 842 _LinkedHashMapKeyIterable(this._map);
845 Iterator<K> get iterator => new _LinkedHashMapKeyIterator<K>(_map); 843 Iterator<K> get iterator => new _LinkedHashMapKeyIterator<K>(_map);
846 bool contains(Object key) => _map.containsKey(key); 844 bool contains(Object key) => _map.containsKey(key);
847 bool get isEmpty => _map.isEmpty; 845 bool get isEmpty => _map.isEmpty;
848 bool get isNotEmpty => _map.isNotEmpty; 846 bool get isNotEmpty => _map.isNotEmpty;
849 int get length => _map.length; 847 int get length => _map.length;
850 Set<K> toSet() => _map._newKeySet()..addAll(this); 848 Set<K> toSet() => _map._newKeySet()..addAll(this);
851 } 849 }
852 850
853 class _LinkedHashMapValueIterable<V> extends IterableBase<V> 851 class _LinkedHashMapValueIterable<V> extends EfficientLengthIterable<V> {
854 implements EfficientLength {
855 LinkedHashMap<dynamic, V> _map; 852 LinkedHashMap<dynamic, V> _map;
856 _LinkedHashMapValueIterable(this._map); 853 _LinkedHashMapValueIterable(this._map);
857 Iterator<V> get iterator => new _LinkedHashMapValueIterator<V>(_map); 854 Iterator<V> get iterator => new _LinkedHashMapValueIterator<V>(_map);
858 bool contains(Object value) => _map.containsValue(value); 855 bool contains(Object value) => _map.containsValue(value);
859 bool get isEmpty => _map.isEmpty; 856 bool get isEmpty => _map.isEmpty;
860 bool get isNotEmpty => _map.isNotEmpty; 857 bool get isNotEmpty => _map.isNotEmpty;
861 int get length => _map.length; 858 int get length => _map.length;
862 } 859 }
863 860
864 abstract class _LinkedHashMapIterator<T> implements Iterator<T> { 861 abstract class _LinkedHashMapIterator<T> implements Iterator<T> {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 if (equals == null) { 969 if (equals == null) {
973 equals = _defaultEquals; 970 equals = _defaultEquals;
974 } 971 }
975 } 972 }
976 return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey); 973 return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey);
977 } 974 }
978 975
979 @patch factory LinkedHashSet.identity() = 976 @patch factory LinkedHashSet.identity() =
980 _CompactLinkedIdentityHashSet<E>; 977 _CompactLinkedIdentityHashSet<E>;
981 } 978 }
OLDNEW
« no previous file with comments | « runtime/lib/array_patch.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698