| Index: dart/sdk/lib/collection/collections.dart
|
| ===================================================================
|
| --- dart/sdk/lib/collection/collections.dart (revision 18634)
|
| +++ dart/sdk/lib/collection/collections.dart (working copy)
|
| @@ -318,14 +318,9 @@
|
| }
|
|
|
| static Iterable mapList(List list, f(var element)) {
|
| - return new MappedListIterable(list, f, 0, null);
|
| + return new MappedListIterable(list, f);
|
| }
|
|
|
| - static List mappedByList(List list, f(var element)) {
|
| - // This is currently a List as well as an Iterable.
|
| - return new MappedList(list, f);
|
| - }
|
| -
|
| static Iterable expand(Iterable iterable, Iterable f(var element)) {
|
| return new ExpandIterable(iterable, f);
|
| }
|
| @@ -333,7 +328,7 @@
|
| static Iterable takeList(List list, int n) {
|
| // The generic type is currently lost. It will be fixed with mixins.
|
| // This is currently a List as well as an Iterable.
|
| - return new ListView(list, 0, n);
|
| + return new SubListIterable(list, 0, n);
|
| }
|
|
|
| static Iterable takeWhile(Iterable iterable, bool test(var value)) {
|
| @@ -344,7 +339,7 @@
|
| static Iterable skipList(List list, int n) {
|
| // The generic type is currently lost. It will be fixed with mixins.
|
| // This is currently a List as well as an Iterable.
|
| - return new ListView(list, n, null);
|
| + return new SubListIterable(list, n, null);
|
| }
|
|
|
| static Iterable skipWhile(Iterable iterable, bool test(var value)) {
|
| @@ -352,8 +347,8 @@
|
| return new SkipWhileIterable(iterable, test);
|
| }
|
|
|
| - static List reversedList(List l) {
|
| - return new ReversedListView(l, 0, null);
|
| + static Iterable reversedList(List l) {
|
| + return new ReversedListIterable(l);
|
| }
|
|
|
| static void sortList(List l, int compare(a, b)) {
|
| @@ -362,141 +357,21 @@
|
| }
|
| }
|
|
|
| -/**
|
| - * The [Collections] class implements static methods useful when
|
| - * writing a class that implements [Collection] and the [iterator]
|
| - * method.
|
| - */
|
| class Collections {
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static bool contains(Iterable iterable, var element)
|
| - => IterableMixinWorkaround.contains(iterable, element);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static void forEach(Iterable iterable, void f(o)) {
|
| - IterableMixinWorkaround.forEach(iterable, f);
|
| - }
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static bool any(Iterable iterable, bool f(o))
|
| - => IterableMixinWorkaround.any(iterable, f);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static bool every(Iterable iterable, bool f(o))
|
| - => IterableMixinWorkaround.every(iterable, f);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic reduce(Iterable iterable,
|
| - dynamic initialValue,
|
| - dynamic combine(dynamic previousValue, element))
|
| - => IterableMixinWorkaround.reduce(iterable, initialValue, combine);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static bool isEmpty(Iterable iterable)
|
| - => IterableMixinWorkaround.isEmpty(iterable);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic first(Iterable iterable)
|
| - => IterableMixinWorkaround.first(iterable);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic last(Iterable iterable)
|
| - => IterableMixinWorkaround.last(iterable);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic min(Iterable iterable, [int compare(var a, var b)])
|
| - => IterableMixinWorkaround.min(iterable, compare);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic max(Iterable iterable, [int compare(var a, var b)])
|
| - => IterableMixinWorkaround.max(iterable, compare);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic single(Iterable iterable)
|
| - => IterableMixinWorkaround.single(iterable);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic firstMatching(Iterable iterable,
|
| - bool test(dynamic value),
|
| - dynamic orElse())
|
| - => IterableMixinWorkaround.firstMatching(iterable, test, orElse);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic lastMatching(Iterable iterable,
|
| - bool test(dynamic value),
|
| - dynamic orElse())
|
| - => IterableMixinWorkaround.lastMatching(iterable, test, orElse);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic lastMatchingInList(List list,
|
| - bool test(dynamic value),
|
| - dynamic orElse())
|
| - => IterableMixinWorkaround.lastMatchingInList(list, test, orElse);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic singleMatching(Iterable iterable, bool test(dynamic value))
|
| - => IterableMixinWorkaround.singleMatching(iterable, test);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static dynamic elementAt(Iterable iterable, int index)
|
| - => IterableMixinWorkaround.elementAt(iterable, index);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static String join(Iterable iterable, [String separator])
|
| - => IterableMixinWorkaround.join(iterable, separator);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static String joinList(List list, [String separator])
|
| - => IterableMixinWorkaround.joinList(list, separator);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static Iterable where(Iterable iterable, bool f(var element))
|
| - => IterableMixinWorkaround.where(iterable, f);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static List mappedByList(List list, f(var element))
|
| - => IterableMixinWorkaround.mappedByList(list, f);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static Iterable takeList(List list, int n)
|
| - => IterableMixinWorkaround.takeList(list, n);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static Iterable takeWhile(Iterable iterable, bool test(var value))
|
| - => IterableMixinWorkaround.takeWhile(iterable, test);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static Iterable skipList(List list, int n)
|
| - => IterableMixinWorkaround.skipList(list, n);
|
| -
|
| - /** Deprecated. Use the same method in [IterableMixinWorkaround] instead.*/
|
| - @deprecated
|
| - static Iterable skipWhile(Iterable iterable, bool test(var value))
|
| - => IterableMixinWorkaround.skipWhile(iterable, test);
|
| -
|
| static String collectionToString(Collection c)
|
| => ToString.collectionToString(c);
|
| }
|
| +
|
| +/**
|
| + * An unmodifiable [List] view of another List.
|
| + *
|
| + * The source of the elements may be a [List] or any [Iterable] with
|
| + * efficient [Iterable.length] and [Iterable.elementAt].
|
| + */
|
| +class UnmodifiableListView<E> extends UnmodifiableListBase<E> {
|
| + Iterable<E> _source;
|
| + /** Create an unmodifiable list backed by [source]. */
|
| + UnmodifiableListView(Iterable<E> source) : _source = source;
|
| + int get length => _source.length;
|
| + E operator[](int index) => _source.elementAt(index);
|
| +}
|
|
|