| Index: sdk/lib/collection/list.dart
|
| diff --git a/sdk/lib/_collection_dev/list.dart b/sdk/lib/collection/list.dart
|
| similarity index 61%
|
| copy from sdk/lib/_collection_dev/list.dart
|
| copy to sdk/lib/collection/list.dart
|
| index 1e40785f3a6540ab555979cb6cf7ba87fe7236d6..8c9dcd086dde71344cc7b55f95ec5f2ba805883e 100644
|
| --- a/sdk/lib/_collection_dev/list.dart
|
| +++ b/sdk/lib/collection/list.dart
|
| @@ -2,7 +2,15 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -part of dart._collection.dev;
|
| +part of dart.collection;
|
| +
|
| +/**
|
| + * Abstract implementation of a list.
|
| + *
|
| + * All operations are defined in terms of `length`, `operator[]`,
|
| + * `operator[]=` and `length=`, which need to be implemented.
|
| + */
|
| +typedef ListBase<E> = Object with ListMixin<E>;
|
|
|
| /**
|
| * Base implementation of a [List] class.
|
| @@ -446,291 +454,3 @@ abstract class ListMixin<E> implements List<E> {
|
|
|
| Iterable<E> get reversed => new ReversedListIterable(this);
|
| }
|
| -
|
| -/**
|
| - * Mixin that throws on the length changing operations of [List].
|
| - *
|
| - * Intended to mix-in on top of [ListMixin] for fixed-length lists.
|
| - */
|
| -abstract class FixedLengthListMixin<E> {
|
| - void set length(int newLength) {
|
| - throw new UnsupportedError(
|
| - "Cannot change the length of a fixed-length list");
|
| - }
|
| -
|
| - void add(E value) {
|
| - throw new UnsupportedError(
|
| - "Cannot add to a fixed-length list");
|
| - }
|
| -
|
| - void insert(int index, E value) {
|
| - throw new UnsupportedError(
|
| - "Cannot add to a fixed-length list");
|
| - }
|
| -
|
| - void addAll(Iterable<E> iterable) {
|
| - throw new UnsupportedError(
|
| - "Cannot add to a fixed-length list");
|
| - }
|
| -
|
| - void remove(E element) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from a fixed-length list");
|
| - }
|
| -
|
| - void removeAll(Iterable elements) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from a fixed-length list");
|
| - }
|
| -
|
| - void retainAll(Iterable elements) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from a fixed-length list");
|
| - }
|
| -
|
| - void removeWhere(bool test(E element)) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from a fixed-length list");
|
| - }
|
| -
|
| - void retainWhere(bool test(E element)) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from a fixed-length list");
|
| - }
|
| -
|
| - void clear() {
|
| - throw new UnsupportedError(
|
| - "Cannot clear a fixed-length list");
|
| - }
|
| -
|
| - E removeAt(int index) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from a fixed-length list");
|
| - }
|
| -
|
| - E removeLast() {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from a fixed-length list");
|
| - }
|
| -
|
| - void removeRange(int start, int length) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from a fixed-length list");
|
| - }
|
| -
|
| - void insertRange(int start, int length, [E initialValue]) {
|
| - throw new UnsupportedError(
|
| - "Cannot insert range in a fixed-length list");
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * Mixin for an unmodifiable [List] class.
|
| - *
|
| - * This overrides all mutating methods with methods that throw.
|
| - * This mixin is intended to be mixed in on top of [ListMixin] on
|
| - * unmodifiable lists.
|
| - */
|
| -abstract class UnmodifiableListMixin<E> {
|
| -
|
| - void operator []=(int index, E value) {
|
| - throw new UnsupportedError(
|
| - "Cannot modify an unmodifiable list");
|
| - }
|
| -
|
| - void set length(int newLength) {
|
| - throw new UnsupportedError(
|
| - "Cannot change the length of an unmodifiable list");
|
| - }
|
| -
|
| - void add(E value) {
|
| - throw new UnsupportedError(
|
| - "Cannot add to an unmodifiable list");
|
| - }
|
| -
|
| - E insert(int index, E value) {
|
| - throw new UnsupportedError(
|
| - "Cannot add to an unmodifiable list");
|
| - }
|
| -
|
| - void addAll(Iterable<E> iterable) {
|
| - throw new UnsupportedError(
|
| - "Cannot add to an unmodifiable list");
|
| - }
|
| -
|
| - void remove(E element) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from an unmodifiable list");
|
| - }
|
| -
|
| - void removeAll(Iterable elements) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from an unmodifiable list");
|
| - }
|
| -
|
| - void retainAll(Iterable elements) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from an unmodifiable list");
|
| - }
|
| -
|
| - void removeWhere(bool test(E element)) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from an unmodifiable list");
|
| - }
|
| -
|
| - void retainWhere(bool test(E element)) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from an unmodifiable list");
|
| - }
|
| -
|
| - void sort([Comparator<E> compare]) {
|
| - throw new UnsupportedError(
|
| - "Cannot modify an unmodifiable list");
|
| - }
|
| -
|
| - void clear() {
|
| - throw new UnsupportedError(
|
| - "Cannot clear an unmodifiable list");
|
| - }
|
| -
|
| - E removeAt(int index) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from an unmodifiable list");
|
| - }
|
| -
|
| - E removeLast() {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from an unmodifiable list");
|
| - }
|
| -
|
| - void setRange(int start, int length, List<E> from, [int startFrom]) {
|
| - throw new UnsupportedError(
|
| - "Cannot modify an unmodifiable list");
|
| - }
|
| -
|
| - void removeRange(int start, int length) {
|
| - throw new UnsupportedError(
|
| - "Cannot remove from an unmodifiable list");
|
| - }
|
| -
|
| - void insertRange(int start, int length, [E initialValue]) {
|
| - throw new UnsupportedError(
|
| - "Cannot insert range in an unmodifiable list");
|
| - }
|
| -}
|
| -
|
| -
|
| -/**
|
| - * Abstract implementation of a list.
|
| - *
|
| - * All operations are defined in terms of `length`, `operator[]`,
|
| - * `operator[]=` and `length=`, which need to be implemented.
|
| - */
|
| -abstract class ListBase<E> extends ListMixin<E> implements List<E> {}
|
| -
|
| -/**
|
| - * Abstract implementation of a fixed-length list.
|
| - *
|
| - * All operations are defined in terms of `length`, `operator[]` and
|
| - * `operator[]=`, which need to be implemented.
|
| - */
|
| -abstract class FixedLengthListBase<E> extends ListBase<E>
|
| - with FixedLengthListMixin<E> {}
|
| -
|
| -/**
|
| - * Abstract implementation of an unmodifiable list.
|
| - *
|
| - * All operations are defined in terms of `length` and `operator[]`,
|
| - * which need to be implemented.
|
| - */
|
| -abstract class UnmodifiableListBase<E> extends ListBase<E>
|
| - with UnmodifiableListMixin<E> {}
|
| -
|
| -/** An empty fixed-length (and therefore unmodifiable) list. */
|
| -class EmptyList<E> extends FixedLengthListBase<E> {
|
| - int get length => 0;
|
| - E operator[](int index) { throw new RangeError.value(index); }
|
| - void operator []=(int index, E value) { throw new RangeError.value(index); }
|
| - Iterable<E> skip(int count) => const EmptyIterable();
|
| - Iterable<E> take(int count) => const EmptyIterable();
|
| - Iterable<E> get reversed => const EmptyIterable();
|
| - void sort([int compare(E a, E b)]) {}
|
| -}
|
| -
|
| -class ReversedListIterable<E> extends ListIterable<E> {
|
| - Iterable<E> _source;
|
| - ReversedListIterable(this._source);
|
| -
|
| - int get length => _source.length;
|
| -
|
| - E elementAt(int index) => _source.elementAt(_source.length - 1 - index);
|
| -}
|
| -
|
| -/**
|
| - * An [Iterable] of the UTF-16 code units of a [String] in index order.
|
| - */
|
| -class CodeUnits extends UnmodifiableListBase<int> {
|
| - /** The string that this is the code units of. */
|
| - String _string;
|
| -
|
| - CodeUnits(this._string);
|
| -
|
| - int get length => _string.length;
|
| - int operator[](int i) => _string.codeUnitAt(i);
|
| -}
|
| -
|
| -class _ListIndicesIterable extends ListIterable<int> {
|
| - List _backedList;
|
| -
|
| - _ListIndicesIterable(this._backedList);
|
| -
|
| - int get length => _backedList.length;
|
| - int elementAt(int index) {
|
| - if (index < 0 || index >= length) {
|
| - throw new RangeError.range(index, 0, length);
|
| - }
|
| - return index;
|
| - }
|
| -}
|
| -
|
| -class ListMapView<E> implements Map<int, E> {
|
| - List<E> _values;
|
| -
|
| - ListMapView(this._values);
|
| -
|
| - E operator[] (int key) => containsKey(key) ? _values[key] : null;
|
| - int get length => _values.length;
|
| -
|
| - Iterable<E> get values => new SubListIterable<E>(_values, 0, null);
|
| - Iterable<int> get keys => new _ListIndicesIterable(_values);
|
| -
|
| - bool get isEmpty => _values.isEmpty;
|
| - bool containsValue(E value) => _values.contains(value);
|
| - bool containsKey(int key) => key is int && key >= 0 && key < length;
|
| -
|
| - void forEach(void f(int key, E value)) {
|
| - int length = _values.length;
|
| - for (int i = 0; i < length; i++) {
|
| - f(i, _values[i]);
|
| - if (length != _values.length) {
|
| - throw new ConcurrentModificationError(_values);
|
| - }
|
| - }
|
| - }
|
| -
|
| - void operator[]= (int key, E value) {
|
| - throw new UnsupportedError("Cannot modify an unmodifiable map");
|
| - }
|
| -
|
| - E putIfAbsent(int key, E ifAbsent()) {
|
| - throw new UnsupportedError("Cannot modify an unmodifiable map");
|
| - }
|
| -
|
| - E remove(int key) {
|
| - throw new UnsupportedError("Cannot modify an unmodifiable map");
|
| - }
|
| -
|
| - void clear() {
|
| - throw new UnsupportedError("Cannot modify an unmodifiable map");
|
| - }
|
| -}
|
|
|