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 part of dart.collection; | 5 part of dart.collection; |
6 | 6 |
7 /** | 7 /** |
8 * This class provides default implementations for Iterables (including Lists). | 8 * This class provides default implementations for Iterables (including Lists). |
9 * | 9 * |
10 * Once Dart receives Mixins it will be replaced with mixin classes. | 10 * Once Dart receives Mixins it will be replaced with mixin classes. |
11 */ | 11 */ |
12 @deprecated | |
12 class IterableMixinWorkaround { | 13 class IterableMixinWorkaround { |
13 static bool contains(Iterable iterable, var element) { | 14 static bool contains(Iterable iterable, var element) { |
14 for (final e in iterable) { | 15 for (final e in iterable) { |
15 if (element == e) return true; | 16 if (element == e) return true; |
16 } | 17 } |
17 return false; | 18 return false; |
18 } | 19 } |
19 | 20 |
20 static void forEach(Iterable iterable, void f(o)) { | 21 static void forEach(Iterable iterable, void f(o)) { |
21 for (final e in iterable) { | 22 for (final e in iterable) { |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 // This is currently a List as well as an Iterable. | 336 // This is currently a List as well as an Iterable. |
336 return new SubListIterable(list, n, null); | 337 return new SubListIterable(list, n, null); |
337 } | 338 } |
338 | 339 |
339 static Iterable skipWhile(Iterable iterable, bool test(var value)) { | 340 static Iterable skipWhile(Iterable iterable, bool test(var value)) { |
340 // The generic type is currently lost. It will be fixed with mixins. | 341 // The generic type is currently lost. It will be fixed with mixins. |
341 return new SkipWhileIterable(iterable, test); | 342 return new SkipWhileIterable(iterable, test); |
342 } | 343 } |
343 | 344 |
344 static Iterable reversedList(List list) { | 345 static Iterable reversedList(List list) { |
345 return new ReversedListIterable(list); | 346 return new _ReversedListIterable(list); |
floitsch
2013/04/09 11:56:07
Move it back.
| |
346 } | 347 } |
347 | 348 |
348 static void sortList(List list, int compare(a, b)) { | 349 static void sortList(List list, int compare(a, b)) { |
349 if (compare == null) compare = Comparable.compare; | 350 if (compare == null) compare = Comparable.compare; |
350 Sort.sort(list, compare); | 351 Sort.sort(list, compare); |
351 } | 352 } |
352 | 353 |
353 static int indexOfList(List list, var element, int start) { | 354 static int indexOfList(List list, var element, int start) { |
354 return Arrays.indexOf(list, element, start, list.length); | 355 return Arrays.indexOf(list, element, start, list.length); |
355 } | 356 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 * The source of the elements may be a [List] or any [Iterable] with | 429 * The source of the elements may be a [List] or any [Iterable] with |
429 * efficient [Iterable.length] and [Iterable.elementAt]. | 430 * efficient [Iterable.length] and [Iterable.elementAt]. |
430 */ | 431 */ |
431 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { | 432 class UnmodifiableListView<E> extends UnmodifiableListBase<E> { |
432 Iterable<E> _source; | 433 Iterable<E> _source; |
433 /** Create an unmodifiable list backed by [source]. */ | 434 /** Create an unmodifiable list backed by [source]. */ |
434 UnmodifiableListView(Iterable<E> source) : _source = source; | 435 UnmodifiableListView(Iterable<E> source) : _source = source; |
435 int get length => _source.length; | 436 int get length => _source.length; |
436 E operator[](int index) => _source.elementAt(index); | 437 E operator[](int index) => _source.elementAt(index); |
437 } | 438 } |
OLD | NEW |