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

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

Issue 262803003: Unify error messages for iterables and lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Capitalize messages. Created 6 years, 7 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 | « runtime/lib/array.dart ('k') | sdk/lib/collection/iterable.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 4
5 class _GrowableList<T> implements List<T> { 5 class _GrowableList<T> implements List<T> {
6 static final int _classId = (new _GrowableList(0))._cid; 6 static final int _classId = (new _GrowableList(0))._cid;
7 7
8 void insert(int index, T element) { 8 void insert(int index, T element) {
9 if (index < 0 || index > length) { 9 if (index < 0 || index > length) {
10 throw new RangeError.range(index, 0, length); 10 throw new RangeError.range(index, 0, length);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 T removeLast() { 191 T removeLast() {
192 var len = length - 1; 192 var len = length - 1;
193 var elem = this[len]; 193 var elem = this[len];
194 this[len] = null; 194 this[len] = null;
195 _setLength(len); 195 _setLength(len);
196 return elem; 196 return elem;
197 } 197 }
198 198
199 T get first { 199 T get first {
200 if (length > 0) return this[0]; 200 if (length > 0) return this[0];
201 throw new StateError("No elements"); 201 throw IterableElementError.noElement();
202 } 202 }
203 203
204 T get last { 204 T get last {
205 if (length > 0) return this[length - 1]; 205 if (length > 0) return this[length - 1];
206 throw new StateError("No elements"); 206 throw IterableElementError.noElement();
207 } 207 }
208 208
209 T get single { 209 T get single {
210 if (length == 1) return this[0]; 210 if (length == 1) return this[0];
211 if (length == 0) throw new StateError("No elements"); 211 if (length == 0) throw IterableElementError.noElement();
212 throw new StateError("More than one element"); 212 throw IterableElementError.tooMany();;
213 } 213 }
214 214
215 int indexOf(Object element, [int start = 0]) { 215 int indexOf(Object element, [int start = 0]) {
216 return IterableMixinWorkaround.indexOfList(this, element, start); 216 return IterableMixinWorkaround.indexOfList(this, element, start);
217 } 217 }
218 218
219 int lastIndexOf(Object element, [int start = null]) { 219 int lastIndexOf(Object element, [int start = null]) {
220 return IterableMixinWorkaround.lastIndexOfList(this, element, start); 220 return IterableMixinWorkaround.lastIndexOfList(this, element, start);
221 } 221 }
222 222
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 353 }
354 354
355 Set<T> toSet() { 355 Set<T> toSet() {
356 return new Set<T>.from(this); 356 return new Set<T>.from(this);
357 } 357 }
358 358
359 Map<int, T> asMap() { 359 Map<int, T> asMap() {
360 return IterableMixinWorkaround.asMapList(this); 360 return IterableMixinWorkaround.asMapList(this);
361 } 361 }
362 } 362 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | sdk/lib/collection/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698