OLD | NEW |
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 Loading... |
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 Iterable<E> | 435 abstract class _HashMapIterable<E> extends IterableBase<E> |
436 implements EfficientLengthIterable<E> { | 436 implements EfficientLength { |
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 Loading... |
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 Iterable<K> | 838 class _LinkedHashMapKeyIterable<K> extends IterableBase<K> |
839 implements EfficientLengthIterable<K> { | 839 implements EfficientLength { |
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 Iterable<V> | 850 class _LinkedHashMapValueIterable<V> extends IterableBase<V> |
851 implements EfficientLengthIterable<V> { | 851 implements EfficientLength { |
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 if (equals == null) { | 969 if (equals == null) { |
970 equals = _defaultEquals; | 970 equals = _defaultEquals; |
971 } | 971 } |
972 } | 972 } |
973 return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey); | 973 return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey); |
974 } | 974 } |
975 | 975 |
976 /* patch */ factory LinkedHashSet.identity() = | 976 /* patch */ factory LinkedHashSet.identity() = |
977 _CompactLinkedIdentityHashSet<E>; | 977 _CompactLinkedIdentityHashSet<E>; |
978 } | 978 } |
OLD | NEW |