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

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

Issue 8422005: Remove List.fromList constructor, and List.copyFrom. They are duplicates of the new range methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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) 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 List<T> { 5 class GrowableObjectArray<T> implements List<T> {
6 ObjectArray<T> backingArray; 6 ObjectArray<T> backingArray;
7 7
8 void copyFrom(List<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 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 for (int i = start; i < start + length; i++) { 59 for (int i = start; i < start + length; i++) {
60 backingArray[i] = initialValue; 60 backingArray[i] = initialValue;
61 } 61 }
62 } 62 }
63 this.length = this.length + length; 63 this.length = this.length + length;
64 } 64 }
65 65
66 List<T> getRange(int start, int length) { 66 List<T> getRange(int start, int length) {
67 if (length == 0) return []; 67 if (length == 0) return [];
68 Arrays.rangeCheck(this, start, length); 68 Arrays.rangeCheck(this, start, length);
69 return new List<T>.fromList(this, start, start + length); 69 List list = new List<T>();
70 list.length = length;
71 Arrays.copy(this, start, list, 0, length);
72 return list;
70 } 73 }
71 74
72 // The length of this growable array. It is always less than the 75 // The length of this growable array. It is always less than the
73 // length of the backing array. 76 // length of the backing array.
74 int _length; 77 int _length;
75 // Constant used by indexOf and lastIndexOf when the element given 78 // Constant used by indexOf and lastIndexOf when the element given
76 // is not in the array. 79 // is not in the array.
77 static final int ABSENT = -1; 80 static final int ABSENT = -1;
78 81
79 GrowableObjectArray() 82 GrowableObjectArray()
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (!hasNext()) { 236 if (!hasNext()) {
234 throw const NoMoreElementsException(); 237 throw const NoMoreElementsException();
235 } 238 }
236 return _array[_pos++]; 239 return _array[_pos++];
237 } 240 }
238 241
239 final GrowableObjectArray<T> _array; 242 final GrowableObjectArray<T> _array;
240 int _pos; 243 int _pos;
241 } 244 }
242 245
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698