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

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: Forgot to upload before committing Created 7 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_collection_dev/iterable.dart ('k') | sdk/lib/_internal/lib/collection_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) 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 17 matching lines...) Expand all
28 void insertAll(int at, Iterable<E> iterable) { 28 void insertAll(int at, Iterable<E> iterable) {
29 throw new UnsupportedError( 29 throw new UnsupportedError(
30 "Cannot add to a fixed-length list"); 30 "Cannot add to a fixed-length list");
31 } 31 }
32 32
33 void addAll(Iterable<E> iterable) { 33 void addAll(Iterable<E> iterable) {
34 throw new UnsupportedError( 34 throw new UnsupportedError(
35 "Cannot add to a fixed-length list"); 35 "Cannot add to a fixed-length list");
36 } 36 }
37 37
38 bool remove(E element) { 38 bool remove(Object element) {
39 throw new UnsupportedError( 39 throw new UnsupportedError(
40 "Cannot remove from a fixed-length list"); 40 "Cannot remove from a fixed-length list");
41 } 41 }
42 42
43 void removeAll(Iterable elements) { 43 void removeAll(Iterable elements) {
44 throw new UnsupportedError( 44 throw new UnsupportedError(
45 "Cannot remove from a fixed-length list"); 45 "Cannot remove from a fixed-length list");
46 } 46 }
47 47
48 void retainAll(Iterable elements) { 48 void retainAll(Iterable elements) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void insertAll(int at, Iterable<E> iterable) { 123 void insertAll(int at, Iterable<E> iterable) {
124 throw new UnsupportedError( 124 throw new UnsupportedError(
125 "Cannot add to an unmodifiable list"); 125 "Cannot add to an unmodifiable list");
126 } 126 }
127 127
128 void addAll(Iterable<E> iterable) { 128 void addAll(Iterable<E> iterable) {
129 throw new UnsupportedError( 129 throw new UnsupportedError(
130 "Cannot add to an unmodifiable list"); 130 "Cannot add to an unmodifiable list");
131 } 131 }
132 132
133 bool remove(E element) { 133 bool remove(Object element) {
134 throw new UnsupportedError( 134 throw new UnsupportedError(
135 "Cannot remove from an unmodifiable list"); 135 "Cannot remove from an unmodifiable list");
136 } 136 }
137 137
138 void removeAll(Iterable elements) { 138 void removeAll(Iterable elements) {
139 throw new UnsupportedError( 139 throw new UnsupportedError(
140 "Cannot remove from an unmodifiable list"); 140 "Cannot remove from an unmodifiable list");
141 } 141 }
142 142
143 void retainAll(Iterable elements) { 143 void retainAll(Iterable elements) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 get isNotEmpty => _values.isNotEmpty; 241 bool get isNotEmpty => _values.isNotEmpty;
242 bool containsValue(E value) => _values.contains(value); 242 bool containsValue(Object value) => _values.contains(value);
243 bool containsKey(int key) => key is int && key >= 0 && key < length; 243 bool containsKey(int key) => key is int && key >= 0 && key < length;
244 244
245 void forEach(void f(int key, E value)) { 245 void forEach(void f(int key, E value)) {
246 int length = _values.length; 246 int length = _values.length;
247 for (int i = 0; i < length; i++) { 247 for (int i = 0; i < length; i++) {
248 f(i, _values[i]); 248 f(i, _values[i]);
249 if (length != _values.length) { 249 if (length != _values.length) {
250 throw new ConcurrentModificationError(_values); 250 throw new ConcurrentModificationError(_values);
251 } 251 }
252 } 252 }
(...skipping 17 matching lines...) Expand all
270 } 270 }
271 271
272 class ReversedListIterable<E> extends ListIterable<E> { 272 class ReversedListIterable<E> extends ListIterable<E> {
273 Iterable<E> _source; 273 Iterable<E> _source;
274 ReversedListIterable(this._source); 274 ReversedListIterable(this._source);
275 275
276 int get length => _source.length; 276 int get length => _source.length;
277 277
278 E elementAt(int index) => _source.elementAt(_source.length - 1 - index); 278 E elementAt(int index) => _source.elementAt(_source.length - 1 - index);
279 } 279 }
OLDNEW
« no previous file with comments | « sdk/lib/_collection_dev/iterable.dart ('k') | sdk/lib/_internal/lib/collection_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698