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; } | |
51 void addLast(E value) { add(value); } | 50 void addLast(E value) { add(value); } |
52 void addAll(Iterable<E> collection) { _list.addAll(collection); } | 51 void addAll(Iterable<E> collection) { _list.addAll(collection); } |
53 void sort([int compare(E a, E b)]) { _list.sort(compare); } | 52 void sort([int compare(E a, E b)]) { _list.sort(compare); } |
54 void shuffle([Random random]) { _list.shuffle(random); } | 53 void shuffle([Random random]) { _list.shuffle(random); } |
55 | 54 |
56 int indexOf(E element, [int start = 0]) => _list.indexOf(element, start); | 55 int indexOf(E element, [int start = 0]) => _list.indexOf(element, start); |
57 int lastIndexOf(E element, [int start]) => _list.lastIndexOf(element, start); | 56 int lastIndexOf(E element, [int start]) => _list.lastIndexOf(element, start); |
58 void clear() { _list.clear(); } | 57 void clear() { _list.clear(); } |
59 | 58 |
60 E removeAt(int index) => _list.removeAt(index); | 59 E removeAt(int index) => _list.removeAt(index); |
(...skipping 19 matching lines...) Expand all Loading... |
80 Map<int, E> asMap() => _list.asMap(); | 79 Map<int, E> asMap() => _list.asMap(); |
81 | 80 |
82 void replaceRange(int start, int end, Iterable<E> newContents) => | 81 void replaceRange(int start, int end, Iterable<E> newContents) => |
83 _list.replaceRange(start, end, newContents); | 82 _list.replaceRange(start, end, newContents); |
84 | 83 |
85 void setAll(int index, Iterable<E> iterable) => _list.setAll(index, iterable); | 84 void setAll(int index, Iterable<E> iterable) => _list.setAll(index, iterable); |
86 | 85 |
87 void fillRange(int start, int end, [E fillValue]) | 86 void fillRange(int start, int end, [E fillValue]) |
88 => _list.fillRange(start, end, fillValue); | 87 => _list.fillRange(start, end, fillValue); |
89 } | 88 } |
OLD | NEW |