| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // TODO(jmesserly): remove this once we have a subclassable growable list | 
|  | 2 // in our libraries. | 
|  | 3 | 
|  | 4 /** A [List] proxy that you can subclass. */ | 
|  | 5 library list_proxy; | 
|  | 6 | 
|  | 7 import 'dart:collection'; | 
|  | 8 | 
|  | 9 // TOOD(jmesserly): this needs to be removed, but fixing NodeList is tricky. | 
|  | 10 class ListProxy<E> extends IterableBase<E> implements List<E> { | 
|  | 11 | 
|  | 12   /** The inner [List<T>] with the actual storage. */ | 
|  | 13   final List<E> _list; | 
|  | 14 | 
|  | 15   /** | 
|  | 16    * Creates a list proxy. | 
|  | 17    * You can optionally specify the list to use for [storage] of the items, | 
|  | 18    * otherwise this will create a [List<E>]. | 
|  | 19    */ | 
|  | 20   ListProxy([List<E> storage]) | 
|  | 21      : _list = storage != null ? storage : <E>[]; | 
|  | 22 | 
|  | 23   // TODO(jmesserly): This should be on List. | 
|  | 24   // See http://code.google.com/p/dart/issues/detail?id=947 | 
|  | 25   bool remove(E item) { | 
|  | 26     int i = indexOf(item); | 
|  | 27     if (i == -1) return false; | 
|  | 28     removeAt(i); | 
|  | 29     return true; | 
|  | 30   } | 
|  | 31 | 
|  | 32   void insert(int index, E item) => _list.insert(index, item); | 
|  | 33 | 
|  | 34   // Override from Iterable to fix performance | 
|  | 35   // Length and last become O(1) instead of O(N) | 
|  | 36   // The others are just different constant factor. | 
|  | 37   int get length => _list.length; | 
|  | 38   E get last => _list.last; | 
|  | 39   E get first => _list.first; | 
|  | 40   E get single => _list.single; | 
|  | 41 | 
|  | 42   // From Iterable | 
|  | 43   Iterator<E> get iterator => _list.iterator; | 
|  | 44 | 
|  | 45   // From List | 
|  | 46   E operator [](int index) => _list[index]; | 
|  | 47   operator []=(int index, E value) { _list[index] = value; } | 
|  | 48   set length(int value) { _list.length = value; } | 
|  | 49   void add(E value) { _list.add(value); } | 
|  | 50 | 
|  | 51   void addLast(E value) { add(value); } | 
|  | 52   void addAll(Iterable<E> collection) { _list.addAll(collection); } | 
|  | 53   void sort([int compare(E a, E b)]) { _list.sort(compare); } | 
|  | 54 | 
|  | 55   int indexOf(E element, [int start = 0]) => _list.indexOf(element, start); | 
|  | 56   int lastIndexOf(E element, [int start]) => _list.lastIndexOf(element, start); | 
|  | 57   void clear() { _list.clear(); } | 
|  | 58 | 
|  | 59   E removeAt(int index) => _list.removeAt(index); | 
|  | 60   E removeLast() => _list.removeLast(); | 
|  | 61 | 
|  | 62   void removeWhere(bool test(E element)) => _list.removeWhere(test); | 
|  | 63   void retainWhere(bool test(E element)) => _list.retainWhere(test); | 
|  | 64 | 
|  | 65   List<E> sublist(int start, [int end]) => _list.sublist(start, end); | 
|  | 66 | 
|  | 67   List<E> getRange(int start, int end) => _list.getRange(start, end); | 
|  | 68 | 
|  | 69   void setRange(int start, int length, List<E> from, [int startFrom = 0]) { | 
|  | 70     _list.setRange(start, length, from, startFrom); | 
|  | 71   } | 
|  | 72   void removeRange(int start, int length) { _list.removeRange(start, length); } | 
|  | 73   void insertAll(int index, Iterable<E> iterable) { | 
|  | 74     _list.insertAll(index, iterable); | 
|  | 75   } | 
|  | 76 | 
|  | 77   Iterable<E> get reversed => _list.reversed; | 
|  | 78 | 
|  | 79   Map<int, E> asMap() => _list.asMap(); | 
|  | 80 | 
|  | 81   void replaceRange(int start, int end, Iterable<E> newContents) => | 
|  | 82       _list.replaceRange(start, end, newContents); | 
|  | 83 | 
|  | 84   void setAll(int index, Iterable<E> iterable) => _list.setAll(index, iterable); | 
|  | 85 | 
|  | 86   void fillRange(int start, int end, [E fillValue]) | 
|  | 87       => _list.fillRange(start, end, fillValue); | 
|  | 88 } | 
| OLD | NEW | 
|---|