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

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

Issue 12379085: Revert "Move Arrays class to private library." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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/byte_array.dart ('k') | runtime/lib/simd128.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 30 matching lines...) Expand all
41 void removeMatching(bool test(T element)) { 41 void removeMatching(bool test(T element)) {
42 IterableMixinWorkaround.removeMatchingList(this, test); 42 IterableMixinWorkaround.removeMatchingList(this, test);
43 } 43 }
44 44
45 void retainMatching(bool test(T element)) { 45 void retainMatching(bool test(T element)) {
46 IterableMixinWorkaround.removeMatchingList(this, 46 IterableMixinWorkaround.removeMatchingList(this,
47 (T element) => !test(element)); 47 (T element) => !test(element));
48 } 48 }
49 49
50 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { 50 void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
51 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); 51 if (length < 0) {
52 throw new ArgumentError("negative length $length");
53 }
54 Arrays.copy(from, startFrom, this, start, length);
52 } 55 }
53 56
54 void removeRange(int start, int length) { 57 void removeRange(int start, int length) {
55 if (length == 0) { 58 if (length == 0) {
56 return; 59 return;
57 } 60 }
58 Arrays.rangeCheck(this, start, length); 61 Arrays.rangeCheck(this, start, length);
59 Arrays.copy(this, 62 Arrays.copy(this,
60 start + length, 63 start + length,
61 this, 64 this,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (length == 1) return this[0]; 187 if (length == 1) return this[0];
185 if (length == 0) throw new StateError("No elements"); 188 if (length == 0) throw new StateError("No elements");
186 throw new StateError("More than one element"); 189 throw new StateError("More than one element");
187 } 190 }
188 191
189 T min([int compare(T a, T b)]) => IterableMixinWorkaround.min(this, compare); 192 T min([int compare(T a, T b)]) => IterableMixinWorkaround.min(this, compare);
190 193
191 T max([int compare(T a, T b)]) => IterableMixinWorkaround.max(this, compare); 194 T max([int compare(T a, T b)]) => IterableMixinWorkaround.max(this, compare);
192 195
193 int indexOf(T element, [int start = 0]) { 196 int indexOf(T element, [int start = 0]) {
194 return IterableMixinWorkaround.indexOfList(this, element, start); 197 return Arrays.indexOf(this, element, start, length);
195 } 198 }
196 199
197 int lastIndexOf(T element, [int start = null]) { 200 int lastIndexOf(T element, [int start = null]) {
198 return IterableMixinWorkaround.lastIndexOfList(this, element, start); 201 if (start == null) start = length - 1;
202 return Arrays.lastIndexOf(this, element, start);
199 } 203 }
200 204
201 void _grow(int new_length) { 205 void _grow(int new_length) {
202 var new_data = new _ObjectArray(new_length); 206 var new_data = new _ObjectArray(new_length);
203 for (int i = 0; i < length; i++) { 207 for (int i = 0; i < length; i++) {
204 new_data[i] = this[i]; 208 new_data[i] = this[i];
205 } 209 }
206 _setData(new_data); 210 _setData(new_data);
207 } 211 }
208 212
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 325 }
322 326
323 Set<T> toSet() { 327 Set<T> toSet() {
324 return new Set<T>.from(this); 328 return new Set<T>.from(this);
325 } 329 }
326 330
327 Map<int, T> asMap() { 331 Map<int, T> asMap() {
328 return IterableMixinWorkaround.asMapList(this); 332 return IterableMixinWorkaround.asMapList(this);
329 } 333 }
330 } 334 }
OLDNEW
« no previous file with comments | « runtime/lib/byte_array.dart ('k') | runtime/lib/simd128.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698