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 // TODO(jmesserly): this should extend the base list. | 7 // TODO(jmesserly): this should extend the base list. |
8 // See http://code.google.com/p/dart/issues/detail?id=949 | 8 // See http://code.google.com/p/dart/issues/detail?id=949 |
9 /** A [List<T>] proxy that you can subclass. */ | 9 /** A [List<T>] proxy that you can subclass. */ |
10 class ListProxy<E> implements List<E> { | 10 class ListProxy<E> implements List<E> { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 List<E> getRange(int start, int length) => _list.getRange(start, length); | 44 List<E> getRange(int start, int length) => _list.getRange(start, length); |
45 void forEach(void f(E element)) => _list.forEach(f); | 45 void forEach(void f(E element)) => _list.forEach(f); |
46 Collection map(f(E element)) => _list.map(f); | 46 Collection map(f(E element)) => _list.map(f); |
47 reduce(initialValue, combine(previousValue, E element)) => | 47 reduce(initialValue, combine(previousValue, E element)) => |
48 _list.reduce(initialValue, combine); | 48 _list.reduce(initialValue, combine); |
49 | 49 |
50 Collection<E> filter(bool f(E element)) => _list.filter(f); | 50 Collection<E> filter(bool f(E element)) => _list.filter(f); |
51 bool every(bool f(E element)) => _list.every(f); | 51 bool every(bool f(E element)) => _list.every(f); |
52 bool some(bool f(E element)) => _list.some(f); | 52 bool some(bool f(E element)) => _list.some(f); |
53 bool get isEmpty => _list.isEmpty; | 53 bool get isEmpty => _list.isEmpty; |
54 E last() => _list.last(); | 54 E get last => _list.last; |
55 | 55 |
56 set length(int value) { _list.length = value; } | 56 set length(int value) { _list.length = value; } |
57 operator []=(int index, E value) { _list[index] = value; } | 57 operator []=(int index, E value) { _list[index] = value; } |
58 void add(E value) { _list.add(value); } | 58 void add(E value) { _list.add(value); } |
59 void addLast(E value) { _list.addLast(value); } | 59 void addLast(E value) { _list.addLast(value); } |
60 void addAll(Collection<E> collection) { _list.addAll(collection); } | 60 void addAll(Collection<E> collection) { _list.addAll(collection); } |
61 void sort([compare = Comparable.compare]) { | 61 void sort([compare = Comparable.compare]) { |
62 _list.sort(compare); | 62 _list.sort(compare); |
63 } | 63 } |
64 void clear() { _list.clear(); } | 64 void clear() { _list.clear(); } |
65 E removeAt(int index) { | 65 E removeAt(int index) { |
66 // TODO(jmesserly): removeAt not implemented on the VM? | 66 // TODO(jmesserly): removeAt not implemented on the VM? |
67 var result = _list[index]; | 67 var result = _list[index]; |
68 _list.removeRange(index, 1); | 68 _list.removeRange(index, 1); |
69 return result; | 69 return result; |
70 } | 70 } |
71 E removeLast() => _list.removeLast(); | 71 E removeLast() => _list.removeLast(); |
72 void setRange(int start, int length, List<E> from, [int startFrom]) { | 72 void setRange(int start, int length, List<E> from, [int startFrom]) { |
73 _list.setRange(start, length, from, startFrom); | 73 _list.setRange(start, length, from, startFrom); |
74 } | 74 } |
75 void removeRange(int start, int length) { _list.removeRange(start, length); } | 75 void removeRange(int start, int length) { _list.removeRange(start, length); } |
76 void insertRange(int start, int length, [E initialValue]) { | 76 void insertRange(int start, int length, [E initialValue]) { |
77 _list.insertRange(start, length, initialValue); | 77 _list.insertRange(start, length, initialValue); |
78 } | 78 } |
79 } | 79 } |
OLD | NEW |