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

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

Issue 14246008: Allow Object when doing lookups. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix type error. Created 7 years, 6 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; 5 part of dart.collection;
6 6
7 /** 7 /**
8 * Abstract implementation of a list. 8 * Abstract implementation of a list.
9 * 9 *
10 * All operations are defined in terms of `length`, `operator[]`, 10 * All operations are defined in terms of `length`, `operator[]`,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (length == 0) throw new StateError("No elements"); 56 if (length == 0) throw new StateError("No elements");
57 return this[length - 1]; 57 return this[length - 1];
58 } 58 }
59 59
60 E get single { 60 E get single {
61 if (length == 0) throw new StateError("No elements"); 61 if (length == 0) throw new StateError("No elements");
62 if (length > 1) throw new StateError("Too many elements"); 62 if (length > 1) throw new StateError("Too many elements");
63 return this[0]; 63 return this[0];
64 } 64 }
65 65
66 bool contains(E element) { 66 bool contains(Object element) {
67 int length = this.length; 67 int length = this.length;
68 for (int i = 0; i < length; i++) { 68 for (int i = 0; i < length; i++) {
69 if (this[i] == element) return true; 69 if (this[i] == element) return true;
70 if (length != this.length) { 70 if (length != this.length) {
71 throw new ConcurrentModificationError(this); 71 throw new ConcurrentModificationError(this);
72 } 72 }
73 } 73 }
74 return false; 74 return false;
75 } 75 }
76 76
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 for (E element in iterable) { 472 for (E element in iterable) {
473 this[index++] = element; 473 this[index++] = element;
474 } 474 }
475 } 475 }
476 } 476 }
477 477
478 Iterable<E> get reversed => new ReversedListIterable(this); 478 Iterable<E> get reversed => new ReversedListIterable(this);
479 479
480 String toString() => ToString.iterableToString(this); 480 String toString() => ToString.iterableToString(this);
481 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698