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

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

Issue 10826264: Revert "Add reduce to Collection." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/array.dart ('k') | tests/corelib/collection_test.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 const UnsupportedOperationException( 7 throw const UnsupportedOperationException(
8 "GrowableObjectArray can only be allocated by the VM"); 8 "GrowableObjectArray can only be allocated by the VM");
9 } 9 }
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 for (int i = 0; i < length; i++) { 173 for (int i = 0; i < length; i++) {
174 f(this[i]); 174 f(this[i]);
175 } 175 }
176 } 176 }
177 177
178 Collection map(f(T element)) { 178 Collection map(f(T element)) {
179 return Collections.map(this, 179 return Collections.map(this,
180 new GrowableObjectArray.withCapacity(length), f); 180 new GrowableObjectArray.withCapacity(length), f);
181 } 181 }
182 182
183 Dynamic reduce(Dynamic initialValue,
184 Dynamic combine(Dynamic previousValue, E element)) {
185 return Collections.reduce(this, initialValue, combine);
186 }
187
188 Collection<T> filter(bool f(T element)) { 183 Collection<T> filter(bool f(T element)) {
189 return Collections.filter(this, new GrowableObjectArray<T>(), f); 184 return Collections.filter(this, new GrowableObjectArray<T>(), f);
190 } 185 }
191 186
192 bool every(bool f(T element)) { 187 bool every(bool f(T element)) {
193 return Collections.every(this, f); 188 return Collections.every(this, f);
194 } 189 }
195 190
196 bool some(bool f(T element)) { 191 bool some(bool f(T element)) {
197 return Collections.some(this, f); 192 return Collections.some(this, f);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 T next() { 227 T next() {
233 if (!hasNext()) { 228 if (!hasNext()) {
234 throw const NoMoreElementsException(); 229 throw const NoMoreElementsException();
235 } 230 }
236 return _array[_pos++]; 231 return _array[_pos++];
237 } 232 }
238 233
239 final GrowableObjectArray<T> _array; 234 final GrowableObjectArray<T> _array;
240 int _pos; 235 int _pos;
241 } 236 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | tests/corelib/collection_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698