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

Side by Side Diff: sdk/lib/_collection_dev/list.dart

Issue 14246008: Allow Object when doing lookups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 part of dart._collection.dev; 5 part of dart._collection.dev;
6 6
7 /** 7 /**
8 * Mixin that throws on the length changing operations of [List]. 8 * Mixin that throws on the length changing operations of [List].
9 * 9 *
10 * Intended to mix-in on top of [ListMixin] for fixed-length lists. 10 * Intended to mix-in on top of [ListMixin] for fixed-length lists.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 ListMapView(this._values); 232 ListMapView(this._values);
233 233
234 E operator[] (int key) => containsKey(key) ? _values[key] : null; 234 E operator[] (int key) => containsKey(key) ? _values[key] : null;
235 int get length => _values.length; 235 int get length => _values.length;
236 236
237 Iterable<E> get values => new SubListIterable<E>(_values, 0, null); 237 Iterable<E> get values => new SubListIterable<E>(_values, 0, null);
238 Iterable<int> get keys => new _ListIndicesIterable(_values); 238 Iterable<int> get keys => new _ListIndicesIterable(_values);
239 239
240 bool get isEmpty => _values.isEmpty; 240 bool get isEmpty => _values.isEmpty;
241 bool containsValue(E value) => _values.contains(value); 241 bool containsValue(Object value) => _values.contains(value);
242 bool containsKey(int key) => key is int && key >= 0 && key < length; 242 bool containsKey(Object key) => key is int && key >= 0 && key < length;
243 243
244 void forEach(void f(int key, E value)) { 244 void forEach(void f(int key, E value)) {
245 int length = _values.length; 245 int length = _values.length;
246 for (int i = 0; i < length; i++) { 246 for (int i = 0; i < length; i++) {
247 f(i, _values[i]); 247 f(i, _values[i]);
248 if (length != _values.length) { 248 if (length != _values.length) {
249 throw new ConcurrentModificationError(_values); 249 throw new ConcurrentModificationError(_values);
250 } 250 }
251 } 251 }
252 } 252 }
(...skipping 16 matching lines...) Expand all
269 } 269 }
270 270
271 class ReversedListIterable<E> extends ListIterable<E> { 271 class ReversedListIterable<E> extends ListIterable<E> {
272 Iterable<E> _source; 272 Iterable<E> _source;
273 ReversedListIterable(this._source); 273 ReversedListIterable(this._source);
274 274
275 int get length => _source.length; 275 int get length => _source.length;
276 276
277 E elementAt(int index) => _source.elementAt(_source.length - 1 - index); 277 E elementAt(int index) => _source.elementAt(_source.length - 1 - index);
278 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698