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

Side by Side Diff: runtime/lib/collection_patch.dart

Issue 1104063002: Make EfficientLength public, as EfficientLengthIterable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 5 years, 7 months 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 | Annotate | Revision Log
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 patch class HashMap<K, V> { 5 patch class HashMap<K, V> {
6 /* patch */ factory HashMap({ bool equals(K key1, K key2), 6 /* patch */ factory HashMap({ bool equals(K key1, K key2),
7 int hashCode(K key), 7 int hashCode(K key),
8 bool isValidKey(potentialKey) }) { 8 bool isValidKey(potentialKey) }) {
9 if (isValidKey == null) { 9 if (isValidKey == null) {
10 if (hashCode == null) { 10 if (hashCode == null) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 425
426 426
427 class _HashMapEntry { 427 class _HashMapEntry {
428 final key; 428 final key;
429 var value; 429 var value;
430 final int hashCode; 430 final int hashCode;
431 _HashMapEntry next; 431 _HashMapEntry next;
432 _HashMapEntry(this.key, this.value, this.hashCode, this.next); 432 _HashMapEntry(this.key, this.value, this.hashCode, this.next);
433 } 433 }
434 434
435 abstract class _HashMapIterable<E> extends IterableBase<E> 435 abstract class _HashMapIterable<E> extends Iterable<E>
436 implements EfficientLength { 436 implements EfficientLengthIterable<E> {
437 final HashMap _map; 437 final HashMap _map;
438 _HashMapIterable(this._map); 438 _HashMapIterable(this._map);
439 int get length => _map.length; 439 int get length => _map.length;
440 bool get isEmpty => _map.isEmpty; 440 bool get isEmpty => _map.isEmpty;
441 bool get isNotEmpty => _map.isNotEmpty; 441 bool get isNotEmpty => _map.isNotEmpty;
442 } 442 }
443 443
444 class _HashMapKeyIterable<K> extends _HashMapIterable<K> { 444 class _HashMapKeyIterable<K> extends _HashMapIterable<K> {
445 _HashMapKeyIterable(HashMap map) : super(map); 445 _HashMapKeyIterable(HashMap map) : super(map);
446 Iterator<K> get iterator => new _HashMapKeyIterator<K>(_map); 446 Iterator<K> get iterator => new _HashMapKeyIterator<K>(_map);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 var _nextEntry; 828 var _nextEntry;
829 var _previousEntry; 829 var _previousEntry;
830 _LinkedHashMapEntry(key, value, int hashCode, _LinkedHashMapEntry next, 830 _LinkedHashMapEntry(key, value, int hashCode, _LinkedHashMapEntry next,
831 this._previousEntry, this._nextEntry) 831 this._previousEntry, this._nextEntry)
832 : super(key, value, hashCode, next) { 832 : super(key, value, hashCode, next) {
833 _previousEntry._nextEntry = this; 833 _previousEntry._nextEntry = this;
834 _nextEntry._previousEntry = this; 834 _nextEntry._previousEntry = this;
835 } 835 }
836 } 836 }
837 837
838 class _LinkedHashMapKeyIterable<K> extends IterableBase<K> 838 class _LinkedHashMapKeyIterable<K> extends Iterable<K>
839 implements EfficientLength { 839 implements EfficientLengthIterable<K> {
840 LinkedHashMap<K, dynamic> _map; 840 LinkedHashMap<K, dynamic> _map;
841 _LinkedHashMapKeyIterable(this._map); 841 _LinkedHashMapKeyIterable(this._map);
842 Iterator<K> get iterator => new _LinkedHashMapKeyIterator<K>(_map); 842 Iterator<K> get iterator => new _LinkedHashMapKeyIterator<K>(_map);
843 bool contains(Object key) => _map.containsKey(key); 843 bool contains(Object key) => _map.containsKey(key);
844 bool get isEmpty => _map.isEmpty; 844 bool get isEmpty => _map.isEmpty;
845 bool get isNotEmpty => _map.isNotEmpty; 845 bool get isNotEmpty => _map.isNotEmpty;
846 int get length => _map.length; 846 int get length => _map.length;
847 Set<K> toSet() => _map._newKeySet()..addAll(this); 847 Set<K> toSet() => _map._newKeySet()..addAll(this);
848 } 848 }
849 849
850 class _LinkedHashMapValueIterable<V> extends IterableBase<V> 850 class _LinkedHashMapValueIterable<V> extends Iterable<V>
851 implements EfficientLength { 851 implements EfficientLengthIterable<V> {
852 LinkedHashMap<dynamic, V> _map; 852 LinkedHashMap<dynamic, V> _map;
853 _LinkedHashMapValueIterable(this._map); 853 _LinkedHashMapValueIterable(this._map);
854 Iterator<V> get iterator => new _LinkedHashMapValueIterator<V>(_map); 854 Iterator<V> get iterator => new _LinkedHashMapValueIterator<V>(_map);
855 bool contains(Object value) => _map.containsValue(value); 855 bool contains(Object value) => _map.containsValue(value);
856 bool get isEmpty => _map.isEmpty; 856 bool get isEmpty => _map.isEmpty;
857 bool get isNotEmpty => _map.isNotEmpty; 857 bool get isNotEmpty => _map.isNotEmpty;
858 int get length => _map.length; 858 int get length => _map.length;
859 } 859 }
860 860
861 abstract class _LinkedHashMapIterator<T> implements Iterator<T> { 861 abstract class _LinkedHashMapIterator<T> implements Iterator<T> {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 if (equals == null) { 976 if (equals == null) {
977 equals = _defaultEquals; 977 equals = _defaultEquals;
978 } 978 }
979 } 979 }
980 return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey); 980 return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey);
981 } 981 }
982 982
983 /* patch */ factory LinkedHashSet.identity() = 983 /* patch */ factory LinkedHashSet.identity() =
984 _CompactLinkedIdentityHashSet<E>; 984 _CompactLinkedIdentityHashSet<E>;
985 } 985 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698