| Index: sdk/lib/collection/collections.dart
|
| diff --git a/sdk/lib/collection/collections.dart b/sdk/lib/collection/collections.dart
|
| index fb9a94b8832dcbfb685b08ca6d39ab0750444a8e..e8dd28847935e11328a5b9a611ed2b3c540b4c9e 100644
|
| --- a/sdk/lib/collection/collections.dart
|
| +++ b/sdk/lib/collection/collections.dart
|
| @@ -12,8 +12,21 @@ part of dart.collection;
|
| */
|
| class UnmodifiableListView<E> extends UnmodifiableListBase<E> {
|
| final Iterable<E> _source;
|
| +
|
| /** Create an unmodifiable list backed by [source]. */
|
| UnmodifiableListView(Iterable<E> source) : _source = source;
|
| +
|
| + /**
|
| + * Returns a view of [source] that's guaranteed to be unmodifiable.
|
| + *
|
| + * If [source] already extends [UnmodifiableListBase] or
|
| + * [UnmodifiableListView], it is returned without re-wrapping it.
|
| + */
|
| + static List ensure(Iterable source) =>
|
| + source is UnmodifiableListBase
|
| + ? source
|
| + : new UnmodifiableListView(source);
|
| +
|
| int get length => _source.length;
|
| E operator[](int index) => _source.elementAt(index);
|
| }
|
|
|