OLD | NEW |
1 // TODO(jmesserly): remove this once we have a subclassable growable list | 1 // TODO(jmesserly): remove this once we have a subclassable growable list |
2 // in our libraries. | 2 // in our libraries. |
3 | 3 |
4 /// A [List] proxy that you can subclass. | 4 /// A [List] proxy that you can subclass. |
5 library list_proxy; | 5 library list_proxy; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' show Random; | 8 import 'dart:math' show Random; |
9 | 9 |
10 // TOOD(jmesserly): this needs to be removed, but fixing NodeList is tricky. | 10 // TOOD(jmesserly): this needs to be removed, but fixing NodeList is tricky. |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 // From Iterable | 41 // From Iterable |
42 Iterator<E> get iterator => _list.iterator; | 42 Iterator<E> get iterator => _list.iterator; |
43 | 43 |
44 // From List | 44 // From List |
45 E operator [](int index) => _list[index]; | 45 E operator [](int index) => _list[index]; |
46 operator []=(int index, E value) { _list[index] = value; } | 46 operator []=(int index, E value) { _list[index] = value; } |
47 set length(int value) { _list.length = value; } | 47 set length(int value) { _list.length = value; } |
48 void add(E value) { _list.add(value); } | 48 void add(E value) { _list.add(value); } |
49 | 49 |
| 50 void set last(E value) { _list.last = value; } |
50 void addLast(E value) { add(value); } | 51 void addLast(E value) { add(value); } |
51 void addAll(Iterable<E> collection) { _list.addAll(collection); } | 52 void addAll(Iterable<E> collection) { _list.addAll(collection); } |
52 void sort([int compare(E a, E b)]) { _list.sort(compare); } | 53 void sort([int compare(E a, E b)]) { _list.sort(compare); } |
53 void shuffle([Random random]) { _list.shuffle(random); } | 54 void shuffle([Random random]) { _list.shuffle(random); } |
54 | 55 |
55 int indexOf(E element, [int start = 0]) => _list.indexOf(element, start); | 56 int indexOf(E element, [int start = 0]) => _list.indexOf(element, start); |
56 int lastIndexOf(E element, [int start]) => _list.lastIndexOf(element, start); | 57 int lastIndexOf(E element, [int start]) => _list.lastIndexOf(element, start); |
57 void clear() { _list.clear(); } | 58 void clear() { _list.clear(); } |
58 | 59 |
59 E removeAt(int index) => _list.removeAt(index); | 60 E removeAt(int index) => _list.removeAt(index); |
(...skipping 19 matching lines...) Expand all Loading... |
79 Map<int, E> asMap() => _list.asMap(); | 80 Map<int, E> asMap() => _list.asMap(); |
80 | 81 |
81 void replaceRange(int start, int end, Iterable<E> newContents) => | 82 void replaceRange(int start, int end, Iterable<E> newContents) => |
82 _list.replaceRange(start, end, newContents); | 83 _list.replaceRange(start, end, newContents); |
83 | 84 |
84 void setAll(int index, Iterable<E> iterable) => _list.setAll(index, iterable); | 85 void setAll(int index, Iterable<E> iterable) => _list.setAll(index, iterable); |
85 | 86 |
86 void fillRange(int start, int end, [E fillValue]) | 87 void fillRange(int start, int end, [E fillValue]) |
87 => _list.fillRange(start, end, fillValue); | 88 => _list.fillRange(start, end, fillValue); |
88 } | 89 } |
OLD | NEW |