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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/lib/js_array.dart

Issue 14071002: Added new version of reduce. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed more uses of max, and a few bugs. 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
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 part of _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The interceptor class for [List]. The compiler recognizes this 8 * The interceptor class for [List]. The compiler recognizes this
9 * class as an interceptor, and changes references to [:this:] to 9 * class as an interceptor, and changes references to [:this:] to
10 * actually use the receiver of the method, which is generated as an extra 10 * actually use the receiver of the method, which is generated as an extra
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 Iterable<E> skip(int n) { 115 Iterable<E> skip(int n) {
116 return IterableMixinWorkaround.skipList(this, n); 116 return IterableMixinWorkaround.skipList(this, n);
117 } 117 }
118 118
119 Iterable<E> skipWhile(bool test(E value)) { 119 Iterable<E> skipWhile(bool test(E value)) {
120 return IterableMixinWorkaround.skipWhile(this, test); 120 return IterableMixinWorkaround.skipWhile(this, test);
121 } 121 }
122 122
123 reduce(initialValue, combine(previousValue, E element)) { 123 E reduce(E combine(E value, E element)) {
124 return IterableMixinWorkaround.reduce(this, initialValue, combine); 124 return IterableMixinWorkaround.reduce(this, combine);
125 } 125 }
126 126
127 fold(initialValue, combine(previousValue, E element)) { 127 fold(initialValue, combine(previousValue, E element)) {
128 return IterableMixinWorkaround.fold(this, initialValue, combine); 128 return IterableMixinWorkaround.fold(this, initialValue, combine);
129 } 129 }
130 130
131 E firstWhere(bool test(E value), {E orElse()}) { 131 E firstWhere(bool test(E value), {E orElse()}) {
132 return IterableMixinWorkaround.firstWhere(this, test, orElse); 132 return IterableMixinWorkaround.firstWhere(this, test, orElse);
133 } 133 }
134 134
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (length > 0) return this[length - 1]; 205 if (length > 0) return this[length - 1];
206 throw new StateError("No elements"); 206 throw new StateError("No elements");
207 } 207 }
208 208
209 E get single { 209 E get single {
210 if (length == 1) return this[0]; 210 if (length == 1) return this[0];
211 if (length == 0) throw new StateError("No elements"); 211 if (length == 0) throw new StateError("No elements");
212 throw new StateError("More than one element"); 212 throw new StateError("More than one element");
213 } 213 }
214 214
215 E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare);
216
217 E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare);
218
219 void removeRange(int start, int length) { 215 void removeRange(int start, int length) {
220 checkGrowable(this, 'removeRange'); 216 checkGrowable(this, 'removeRange');
221 if (length == 0) { 217 if (length == 0) {
222 return; 218 return;
223 } 219 }
224 checkNull(start); // TODO(ahe): This is not specified but co19 tests it. 220 checkNull(start); // TODO(ahe): This is not specified but co19 tests it.
225 checkNull(length); // TODO(ahe): This is not specified but co19 tests it. 221 checkNull(length); // TODO(ahe): This is not specified but co19 tests it.
226 if (start is !int) throw new ArgumentError(start); 222 if (start is !int) throw new ArgumentError(start);
227 if (length is !int) throw new ArgumentError(length); 223 if (length is !int) throw new ArgumentError(length);
228 if (length < 0) throw new ArgumentError(length); 224 if (length < 0) throw new ArgumentError(length);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 313 }
318 } 314 }
319 315
320 /** 316 /**
321 * Dummy subclasses that allow the backend to track more precise 317 * Dummy subclasses that allow the backend to track more precise
322 * information about arrays through their type. 318 * information about arrays through their type.
323 */ 319 */
324 class JSMutableArray extends JSArray {} 320 class JSMutableArray extends JSArray {}
325 class JSFixedArray extends JSMutableArray {} 321 class JSFixedArray extends JSMutableArray {}
326 class JSExtendableArray extends JSMutableArray {} 322 class JSExtendableArray extends JSMutableArray {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698