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

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

Issue 8321024: Clean up (most) uses of Array. Still more to come in the VM corelib code base. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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/arrays.dart ('k') | runtime/lib/immutable_map.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 Array<T> { 5 class GrowableObjectArray<T> implements List<T> {
6 Array<T> backingArray; 6 ObjectArray<T> backingArray;
7 7
8 void copyFrom(Array<Object> src, int srcStart, int dstStart, int count) { 8 void copyFrom(List<Object> src, int srcStart, int dstStart, int count) {
9 Arrays.copy(src, srcStart, this, dstStart, count); 9 Arrays.copy(src, srcStart, this, dstStart, count);
10 } 10 }
11 11
12 void setRange(int start, int length, List<T> from, [int startFrom = 0]) { 12 void setRange(int start, int length, List<T> from, [int startFrom = 0]) {
13 if (length < 0) { 13 if (length < 0) {
14 throw new IllegalArgumentException("negative length $length"); 14 throw new IllegalArgumentException("negative length $length");
15 } 15 }
16 Arrays.copy(from, startFrom, this, start, length); 16 Arrays.copy(from, startFrom, this, start, length);
17 } 17 }
18 18
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 void operator []=(int index, T value) { 126 void operator []=(int index, T value) {
127 if (index >= _length) { 127 if (index >= _length) {
128 throw new IndexOutOfRangeException(index); 128 throw new IndexOutOfRangeException(index);
129 } 129 }
130 backingArray[index] = value; 130 backingArray[index] = value;
131 } 131 }
132 132
133 void grow(int capacity) { 133 void grow(int capacity) {
134 Array<T> newArray = new ObjectArray<T>(capacity); 134 ObjectArray<T> newArray = new ObjectArray<T>(capacity);
135 int length = backingArray.length; 135 int length = backingArray.length;
136 for (int i = 0; i < length; i++) { 136 for (int i = 0; i < length; i++) {
137 newArray[i] = backingArray[i]; 137 newArray[i] = backingArray[i];
138 } 138 }
139 backingArray = newArray; 139 backingArray = newArray;
140 } 140 }
141 141
142 int add(T value) { 142 int add(T value) {
143 if (_length == backingArray.length) { 143 if (_length == backingArray.length) {
144 grow(_length * 2); 144 grow(_length * 2);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (!hasNext()) { 233 if (!hasNext()) {
234 throw const NoMoreElementsException(); 234 throw const NoMoreElementsException();
235 } 235 }
236 return _array[_pos++]; 236 return _array[_pos++];
237 } 237 }
238 238
239 final GrowableObjectArray<T> _array; 239 final GrowableObjectArray<T> _array;
240 int _pos; 240 int _pos;
241 } 241 }
242 242
OLDNEW
« no previous file with comments | « runtime/lib/arrays.dart ('k') | runtime/lib/immutable_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698