OLD | NEW |
---|---|
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 | 5 |
6 // TODO(srdjan): Use shared array implementation. | 6 // TODO(srdjan): Use shared array implementation. |
7 class _ObjectArray<E> implements List<E> { | 7 class _ObjectArray<E> implements List<E> { |
8 | 8 |
9 factory _ObjectArray(length) native "ObjectArray_allocate"; | 9 factory _ObjectArray(length) native "ObjectArray_allocate"; |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 } | 107 } |
108 | 108 |
109 String join([String separator = ""]) { | 109 String join([String separator = ""]) { |
110 return IterableMixinWorkaround.joinList(this, separator); | 110 return IterableMixinWorkaround.joinList(this, separator); |
111 } | 111 } |
112 | 112 |
113 Iterable map(f(E element)) { | 113 Iterable map(f(E element)) { |
114 return IterableMixinWorkaround.mapList(this, f); | 114 return IterableMixinWorkaround.mapList(this, f); |
115 } | 115 } |
116 | 116 |
117 reduce(initialValue, combine(previousValue, E element)) { | 117 reduce(E combine(E value, E element)) { |
floitsch
2013/04/10 15:14:07
Return type is E.
Lasse Reichstein Nielsen
2013/04/11 07:54:04
Done.
| |
118 return IterableMixinWorkaround.reduce(this, initialValue, combine); | 118 return IterableMixinWorkaround.reduce(this, combine); |
119 } | 119 } |
120 | 120 |
121 fold(initialValue, combine(previousValue, E element)) { | 121 fold(initialValue, combine(previousValue, E element)) { |
122 return IterableMixinWorkaround.fold(this, initialValue, combine); | 122 return IterableMixinWorkaround.fold(this, initialValue, combine); |
123 } | 123 } |
124 | 124 |
125 Iterable<E> where(bool f(E element)) { | 125 Iterable<E> where(bool f(E element)) { |
126 return IterableMixinWorkaround.where(this, f); | 126 return IterableMixinWorkaround.where(this, f); |
127 } | 127 } |
128 | 128 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 if (length > 0) return this[length - 1]; | 227 if (length > 0) return this[length - 1]; |
228 throw new StateError("No elements"); | 228 throw new StateError("No elements"); |
229 } | 229 } |
230 | 230 |
231 E get single { | 231 E get single { |
232 if (length == 1) return this[0]; | 232 if (length == 1) return this[0]; |
233 if (length == 0) throw new StateError("No elements"); | 233 if (length == 0) throw new StateError("No elements"); |
234 throw new StateError("More than one element"); | 234 throw new StateError("More than one element"); |
235 } | 235 } |
236 | 236 |
237 E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare); | |
238 | |
239 E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare); | |
240 | |
241 List<E> toList({ bool growable: true}) { | 237 List<E> toList({ bool growable: true}) { |
242 return new List<E>.from(this, growable: growable); | 238 return new List<E>.from(this, growable: growable); |
243 } | 239 } |
244 | 240 |
245 Set<E> toSet() { | 241 Set<E> toSet() { |
246 return new Set<E>.from(this); | 242 return new Set<E>.from(this); |
247 } | 243 } |
248 | 244 |
249 Map<int, E> asMap() { | 245 Map<int, E> asMap() { |
250 return IterableMixinWorkaround.asMapList(this); | 246 return IterableMixinWorkaround.asMapList(this); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 } | 350 } |
355 | 351 |
356 Iterable map(f(E element)) { | 352 Iterable map(f(E element)) { |
357 return IterableMixinWorkaround.mapList(this, f); | 353 return IterableMixinWorkaround.mapList(this, f); |
358 } | 354 } |
359 | 355 |
360 String join([String separator = ""]) { | 356 String join([String separator = ""]) { |
361 return IterableMixinWorkaround.joinList(this, separator); | 357 return IterableMixinWorkaround.joinList(this, separator); |
362 } | 358 } |
363 | 359 |
364 reduce(initialValue, combine(previousValue, E element)) { | 360 reduce(E combine(E value, E element)) { |
floitsch
2013/04/10 15:14:07
return type is E.
Lasse Reichstein Nielsen
2013/04/11 07:54:04
Done.
| |
365 return IterableMixinWorkaround.reduce(this, initialValue, combine); | 361 return IterableMixinWorkaround.reduce(this, combine); |
366 } | 362 } |
367 | 363 |
368 fold(initialValue, combine(previousValue, E element)) { | 364 fold(initialValue, combine(previousValue, E element)) { |
369 return IterableMixinWorkaround.fold(this, initialValue, combine); | 365 return IterableMixinWorkaround.fold(this, initialValue, combine); |
370 } | 366 } |
371 | 367 |
372 Iterable<E> where(bool f(E element)) { | 368 Iterable<E> where(bool f(E element)) { |
373 return IterableMixinWorkaround.where(this, f); | 369 return IterableMixinWorkaround.where(this, f); |
374 } | 370 } |
375 | 371 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 if (length > 0) return this[length - 1]; | 475 if (length > 0) return this[length - 1]; |
480 throw new StateError("No elements"); | 476 throw new StateError("No elements"); |
481 } | 477 } |
482 | 478 |
483 E get single { | 479 E get single { |
484 if (length == 1) return this[0]; | 480 if (length == 1) return this[0]; |
485 if (length == 0) throw new StateError("No elements"); | 481 if (length == 0) throw new StateError("No elements"); |
486 throw new StateError("More than one element"); | 482 throw new StateError("More than one element"); |
487 } | 483 } |
488 | 484 |
489 E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare); | |
490 | |
491 E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare); | |
492 | |
493 List<E> toList({ bool growable: true }) { | 485 List<E> toList({ bool growable: true }) { |
494 return new List<E>.from(this, growable: growable); | 486 return new List<E>.from(this, growable: growable); |
495 } | 487 } |
496 | 488 |
497 Set<E> toSet() { | 489 Set<E> toSet() { |
498 return new Set<E>.from(this); | 490 return new Set<E>.from(this); |
499 } | 491 } |
500 | 492 |
501 Map<int, E> asMap() { | 493 Map<int, E> asMap() { |
502 return IterableMixinWorkaround.asMapList(this); | 494 return IterableMixinWorkaround.asMapList(this); |
(...skipping 22 matching lines...) Expand all Loading... | |
525 } | 517 } |
526 _position = _length; | 518 _position = _length; |
527 _current = null; | 519 _current = null; |
528 return false; | 520 return false; |
529 } | 521 } |
530 | 522 |
531 E get current { | 523 E get current { |
532 return _current; | 524 return _current; |
533 } | 525 } |
534 } | 526 } |
OLD | NEW |