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

Side by Side Diff: compiler/lib/implementation/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
« no previous file with comments | « client/touch/TouchHandler.dart ('k') | corelib/src/list.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 ListFactory { 5 class ListFactory {
6 factory List<E>.from(Iterable<E> other) { 6 factory List<E>.from(Iterable<E> other) {
7 List<E> list = new List<E>(); 7 List<E> list = new List<E>();
8 for (final e in other) { 8 for (final e in other) {
9 list.add(e); 9 list.add(e);
10 } 10 }
11 return list; 11 return list;
12 } 12 }
13 13
14 factory List<E>.fromList(List<E> other, int startIndex, int endIndex) { 14 factory List<E>.fromList(List<E> other, int startIndex, int endIndex) {
floitsch 2011/10/31 09:40:44 forgot to remove this line.
ngeoffray 2011/10/31 09:47:45 Done.
15 List list = new List<E>();
16 if (endIndex > other.length) endIndex = other.length;
17 if (startIndex < 0) startIndex = 0;
18 int count = endIndex - startIndex;
19 if (count > 0) {
20 list.length = count;
21 Arrays.copy(other, startIndex, list, 0, count);
22 }
23 return list;
24 } 15 }
25 16
26 factory List<E>([int length = null]) { 17 factory List<E>([int length = null]) {
27 bool isFixed = true; 18 bool isFixed = true;
28 if (length === null) { 19 if (length === null) {
29 length = 0; 20 length = 0;
30 isFixed = false; 21 isFixed = false;
31 } else if (length < 0) { 22 } else if (length < 0) {
32 throw new IllegalArgumentException("negative length $length"); 23 throw new IllegalArgumentException("negative length $length");
33 } 24 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 137 }
147 if (start < 0 || start > this.length) { 138 if (start < 0 || start > this.length) {
148 throw new IndexOutOfRangeException(start); 139 throw new IndexOutOfRangeException(start);
149 } 140 }
150 _insertRange(start, length, initialValue); 141 _insertRange(start, length, initialValue);
151 } 142 }
152 143
153 List<T> getRange(int start, int length) { 144 List<T> getRange(int start, int length) {
154 if (length == 0) return []; 145 if (length == 0) return [];
155 Arrays.rangeCheck(this, start, length); 146 Arrays.rangeCheck(this, start, length);
156 return new List<T>.fromList(this, start, start + length); 147 List list = new List<T>();
148 list.length = length;
149 Arrays.copy(this, start, list, 0, length);
150 return list;
157 } 151 }
158 152
159 int indexOf(T element, int startIndex) { 153 int indexOf(T element, int startIndex) {
160 return Arrays.indexOf(this, element, startIndex, this.length); 154 return Arrays.indexOf(this, element, startIndex, this.length);
161 } 155 }
162 156
163 int lastIndexOf(T element, int startIndex) { 157 int lastIndexOf(T element, int startIndex) {
164 return Arrays.lastIndexOf(this, element, startIndex); 158 return Arrays.lastIndexOf(this, element, startIndex);
165 } 159 }
166 160
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 261 }
268 262
269 static List _newList(int len) native { 263 static List _newList(int len) native {
270 return new List(len); 264 return new List(len);
271 } 265 }
272 266
273 static void _throwIndexOutOfRangeException(int index) native { 267 static void _throwIndexOutOfRangeException(int index) native {
274 throw new IndexOutOfRangeException(index); 268 throw new IndexOutOfRangeException(index);
275 } 269 }
276 } 270 }
OLDNEW
« no previous file with comments | « client/touch/TouchHandler.dart ('k') | corelib/src/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698