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

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

Issue 14425003: Make List.remove return boolean. (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
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/typeddata.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 _GrowableObjectArray<T> implements List<T> { 5 class _GrowableObjectArray<T> implements List<T> {
6 factory _GrowableObjectArray._uninstantiable() { 6 factory _GrowableObjectArray._uninstantiable() {
7 throw new UnsupportedError( 7 throw new UnsupportedError(
8 "GrowableObjectArray can only be allocated by the VM"); 8 "GrowableObjectArray can only be allocated by the VM");
9 } 9 }
10 10
(...skipping 25 matching lines...) Expand all
36 int newLength = this.length - 1; 36 int newLength = this.length - 1;
37 Arrays.copy(this, 37 Arrays.copy(this,
38 index + 1, 38 index + 1,
39 this, 39 this,
40 index, 40 index,
41 newLength - index); 41 newLength - index);
42 this.length = newLength; 42 this.length = newLength;
43 return result; 43 return result;
44 } 44 }
45 45
46 void remove(Object element) { 46 bool remove(Object element) {
47 for (int i = 0; i < this.length; i++) { 47 for (int i = 0; i < this.length; i++) {
48 if (this[i] == element) { 48 if (this[i] == element) {
49 removeAt(i); 49 removeAt(i);
50 return; 50 return true;
51 } 51 }
52 } 52 }
53 return false;
53 } 54 }
54 55
55 void insertAll(int index, Iterable<T> iterable) { 56 void insertAll(int index, Iterable<T> iterable) {
56 if (index < 0 || index > length) { 57 if (index < 0 || index > length) {
57 throw new RangeError.range(index, 0, length); 58 throw new RangeError.range(index, 0, length);
58 } 59 }
59 // TODO(floitsch): we can probably detect more cases. 60 // TODO(floitsch): we can probably detect more cases.
60 if (iterable is! List && iterable is! Set && iterable is! SubListIterable) { 61 if (iterable is! List && iterable is! Set && iterable is! SubListIterable) {
61 iterable = iterable.toList(); 62 iterable = iterable.toList();
62 } 63 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 350 }
350 351
351 Set<T> toSet() { 352 Set<T> toSet() {
352 return new Set<T>.from(this); 353 return new Set<T>.from(this);
353 } 354 }
354 355
355 Map<int, T> asMap() { 356 Map<int, T> asMap() {
356 return IterableMixinWorkaround.asMapList(this); 357 return IterableMixinWorkaround.asMapList(this);
357 } 358 }
358 } 359 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/typeddata.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698