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

Side by Side Diff: runtime/lib/immutable_map.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/growable_array.dart ('k') | runtime/lib/string_patch.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 // Immutable map class for compiler generated map literals. 4 // Immutable map class for compiler generated map literals.
5 5
6 class ImmutableMap<K, V> implements Map<K, V> { 6 class ImmutableMap<K, V> implements Map<K, V> {
7 final _ImmutableList _kvPairs; 7 final _ImmutableList _kvPairs;
8 8
9 const ImmutableMap._create(_ImmutableList keyValuePairs) 9 const ImmutableMap._create(_ImmutableList keyValuePairs)
10 : _kvPairs = keyValuePairs; 10 : _kvPairs = keyValuePairs;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 V remove(Object key) { 79 V remove(Object key) {
80 throw new UnsupportedError("Cannot remove from unmodifiable Map"); 80 throw new UnsupportedError("Cannot remove from unmodifiable Map");
81 } 81 }
82 82
83 String toString() { 83 String toString() {
84 return Maps.mapToString(this); 84 return Maps.mapToString(this);
85 } 85 }
86 } 86 }
87 87
88 class _ImmutableMapKeyIterable<E> extends IterableBase<E> 88 class _ImmutableMapKeyIterable<E> extends EfficientLengthIterable<E> {
89 implements EfficientLength {
90 final ImmutableMap _map; 89 final ImmutableMap _map;
91 _ImmutableMapKeyIterable(this._map); 90 _ImmutableMapKeyIterable(this._map);
92 91
93 Iterator<E> get iterator { 92 Iterator<E> get iterator {
94 return new _ImmutableMapKeyIterator<E>(_map); 93 return new _ImmutableMapKeyIterator<E>(_map);
95 } 94 }
96 95
97 int get length => _map.length; 96 int get length => _map.length;
98 } 97 }
99 98
100 class _ImmutableMapValueIterable<E> extends IterableBase<E> 99 class _ImmutableMapValueIterable<E> extends EfficientLengthIterable<E> {
101 implements EfficientLength {
102 final ImmutableMap _map; 100 final ImmutableMap _map;
103 _ImmutableMapValueIterable(this._map); 101 _ImmutableMapValueIterable(this._map);
104 102
105 Iterator<E> get iterator { 103 Iterator<E> get iterator {
106 return new _ImmutableMapValueIterator<E>(_map); 104 return new _ImmutableMapValueIterator<E>(_map);
107 } 105 }
108 106
109 int get length => _map.length; 107 int get length => _map.length;
110 } 108 }
111 109
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 _current = _map._kvPairs[newIndex * 2 + 1]; 143 _current = _map._kvPairs[newIndex * 2 + 1];
146 return true; 144 return true;
147 } 145 }
148 _current = null; 146 _current = null;
149 _index = _map.length; 147 _index = _map.length;
150 return false; 148 return false;
151 } 149 }
152 150
153 E get current => _current; 151 E get current => _current;
154 } 152 }
OLDNEW
« no previous file with comments | « runtime/lib/growable_array.dart ('k') | runtime/lib/string_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698