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

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

Issue 1620923002: Remove stale comment in ImmutableList implementation (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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) 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;
11 11
12 12
13 V operator [](Object key) { 13 V operator [](Object key) {
14 // TODO(hausner): Since the keys are sorted, we could do a binary 14 // To preserve the key-value order of the map literal, the keys are
15 // search. But is it worth it? 15 // not sorted. Need to do linear search or implement an additional
16 // lookup table.
16 for (int i = 0; i < _kvPairs.length - 1; i += 2) { 17 for (int i = 0; i < _kvPairs.length - 1; i += 2) {
17 if (key == _kvPairs[i]) { 18 if (key == _kvPairs[i]) {
18 return _kvPairs[i+1]; 19 return _kvPairs[i+1];
19 } 20 }
20 } 21 }
21 return null; 22 return null;
22 } 23 }
23 24
24 bool get isEmpty { 25 bool get isEmpty {
25 return _kvPairs.length == 0; 26 return _kvPairs.length == 0;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 _current = _map._kvPairs[newIndex * 2 + 1]; 145 _current = _map._kvPairs[newIndex * 2 + 1];
145 return true; 146 return true;
146 } 147 }
147 _current = null; 148 _current = null;
148 _index = _map.length; 149 _index = _map.length;
149 return false; 150 return false;
150 } 151 }
151 152
152 E get current => _current; 153 E get current => _current;
153 } 154 }
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