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

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

Issue 2984683002: VM: Remove old LinkedHashMap implementation that is no longer used (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « no previous file | no next file » | 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 8 @patch
9 class HashMap<K, V> { 9 class HashMap<K, V> {
10 @patch 10 @patch
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 return true; 821 return true;
822 } 822 }
823 } 823 }
824 _current = null; 824 _current = null;
825 return false; 825 return false;
826 } 826 }
827 827
828 E get current => _current; 828 E get current => _current;
829 } 829 }
830 830
831 class _LinkedHashMapEntry extends _HashMapEntry {
832 /// Double-linked list of entries of a linked hash map.
833 /// The _LinkedHashMap itself is the head of the list, so the type is "var".
834 /// Both are initialized to `this` when initialized.
835 var _nextEntry;
836 var _previousEntry;
837 _LinkedHashMapEntry(key, value, int hashCode, _LinkedHashMapEntry next,
838 this._previousEntry, this._nextEntry)
839 : super(key, value, hashCode, next) {
840 _previousEntry._nextEntry = this;
841 _nextEntry._previousEntry = this;
842 }
843 }
844
845 class _LinkedHashMapKeyIterable<K> extends EfficientLengthIterable<K> {
846 LinkedHashMap<K, dynamic> _map;
847 _LinkedHashMapKeyIterable(this._map);
848 Iterator<K> get iterator => new _LinkedHashMapKeyIterator<K>(_map);
849 bool contains(Object key) => _map.containsKey(key);
850 bool get isEmpty => _map.isEmpty;
851 bool get isNotEmpty => _map.isNotEmpty;
852 int get length => _map.length;
853 Set<K> toSet() => _map._newKeySet()..addAll(this);
854 }
855
856 class _LinkedHashMapValueIterable<V> extends EfficientLengthIterable<V> {
857 LinkedHashMap<dynamic, V> _map;
858 _LinkedHashMapValueIterable(this._map);
859 Iterator<V> get iterator => new _LinkedHashMapValueIterator<V>(_map);
860 bool contains(Object value) => _map.containsValue(value);
861 bool get isEmpty => _map.isEmpty;
862 bool get isNotEmpty => _map.isNotEmpty;
863 int get length => _map.length;
864 }
865
866 abstract class _LinkedHashMapIterator<T> implements Iterator<T> {
867 final LinkedHashMap _map;
868 var _next;
869 T _current;
870 int _modificationCount;
871 _LinkedHashMapIterator(LinkedHashMap map)
872 : _map = map,
873 _next = map._nextEntry,
874 _modificationCount = map._modificationCount;
875
876 bool moveNext() {
877 if (_modificationCount != _map._modificationCount) {
878 throw new ConcurrentModificationError(_map);
879 }
880 if (identical(_map, _next)) {
881 _current = null;
882 return false;
883 }
884 _LinkedHashMapEntry entry = _next;
885 _next = entry._nextEntry;
886 _current = _getValue(entry);
887 return true;
888 }
889
890 T _getValue(_LinkedHashMapEntry entry);
891
892 T get current => _current;
893 }
894
895 class _LinkedHashMapKeyIterator<K> extends _LinkedHashMapIterator<K> {
896 _LinkedHashMapKeyIterator(LinkedHashMap map) : super(map);
897 K _getValue(_LinkedHashMapEntry entry) => entry.key;
898 }
899
900 class _LinkedHashMapValueIterator<V> extends _LinkedHashMapIterator<V> {
901 _LinkedHashMapValueIterator(LinkedHashMap map) : super(map);
902 V _getValue(_LinkedHashMapEntry entry) => entry.value;
903 }
904
905 /** 831 /**
906 * A hash-based map that iterates keys and values in key insertion order. 832 * A hash-based map that iterates keys and values in key insertion order.
833 * This is never actually instantiated any more - the constructor always
zra 2017/07/20 16:44:07 'the constructor always ...' Maybe update comment
erikcorry 2017/07/28 08:28:10 Done.
834 * returns an instance of CompactLinkedHashMap, which despite the name
835 * does not use links (but is insertion-ordered as if it did).
907 */ 836 */
908 @patch 837 @patch
909 class LinkedHashMap<K, V> { 838 class LinkedHashMap<K, V> {
910 /// Holds a double-linked list of entries in insertion order.
911 /// The fields have the same name as the ones in [_LinkedHashMapEntry],
912 /// and this map is itself used as the head entry of the list.
913 /// Set to `this` when initialized, representing the empty list (containing
914 /// only the head entry itself).
915 var _nextEntry;
916 var _previousEntry;
917
918 @patch 839 @patch
919 factory LinkedHashMap( 840 factory LinkedHashMap(
920 {bool equals(K key1, K key2), 841 {bool equals(K key1, K key2),
921 int hashCode(K key), 842 int hashCode(K key),
922 bool isValidKey(potentialKey)}) { 843 bool isValidKey(potentialKey)}) {
923 if (isValidKey == null) { 844 if (isValidKey == null) {
924 if (hashCode == null) { 845 if (hashCode == null) {
925 if (equals == null) { 846 if (equals == null) {
926 return new _InternalLinkedHashMap<K, V>(); 847 return new _InternalLinkedHashMap<K, V>();
927 } 848 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 if (equals == null) { 900 if (equals == null) {
980 equals = _defaultEquals; 901 equals = _defaultEquals;
981 } 902 }
982 } 903 }
983 return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey); 904 return new _CompactLinkedCustomHashSet<E>(equals, hashCode, isValidKey);
984 } 905 }
985 906
986 @patch 907 @patch
987 factory LinkedHashSet.identity() = _CompactLinkedIdentityHashSet<E>; 908 factory LinkedHashSet.identity() = _CompactLinkedIdentityHashSet<E>;
988 } 909 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698