| OLD | NEW |
| (Empty) |
| 1 // -- start List<$E> mixins. | |
| 2 // $E is the element type. | |
| 3 | |
| 4 // From Iterable<$E>: | |
| 5 | |
| 6 Iterator<$E> iterator() { | |
| 7 // Note: NodeLists are not fixed size. And most probably length shouldn't | |
| 8 // be cached in both iterator _and_ forEach method. For now caching it | |
| 9 // for consistency. | |
| 10 return new _FixedSizeListIterator<$E>(this); | |
| 11 } | |
| 12 | |
| 13 // From Collection<$E>: | |
| 14 | |
| 15 void add($E value) { | |
| 16 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
| 17 } | |
| 18 | |
| 19 void addLast($E value) { | |
| 20 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
| 21 } | |
| 22 | |
| 23 void addAll(Collection<$E> collection) { | |
| 24 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
| 25 } | |
| 26 | |
| 27 void forEach(void f($E element)) => _Collections.forEach(this, f); | |
| 28 | |
| 29 Collection map(f($E element)) => _Collections.map(this, [], f); | |
| 30 | |
| 31 Collection<$E> filter(bool f($E element)) => | |
| 32 _Collections.filter(this, <$E>[], f); | |
| 33 | |
| 34 bool every(bool f($E element)) => _Collections.every(this, f); | |
| 35 | |
| 36 bool some(bool f($E element)) => _Collections.some(this, f); | |
| 37 | |
| 38 bool isEmpty() => this.length == 0; | |
| 39 | |
| 40 // From List<$E>: | |
| 41 | |
| 42 void sort(int compare($E a, $E b)) { | |
| 43 throw new UnsupportedOperationException("Cannot sort immutable List."); | |
| 44 } | |
| 45 | |
| 46 int indexOf($E element, [int start = 0]) => | |
| 47 _Lists.indexOf(this, element, start, this.length); | |
| 48 | |
| 49 int lastIndexOf($E element, [int start = 0]) => | |
| 50 _Lists.lastIndexOf(this, element, start); | |
| 51 | |
| 52 $E last() => this[length - 1]; | |
| 53 | |
| 54 // FIXME: implement thesee. | |
| 55 void setRange(int start, int length, List<$E> from, [int startFrom]) { | |
| 56 throw new UnsupportedOperationException("Cannot setRange on immutable List."
); | |
| 57 } | |
| 58 void removeRange(int start, int length) { | |
| 59 throw new UnsupportedOperationException("Cannot removeRange on immutable Lis
t."); | |
| 60 } | |
| 61 void insertRange(int start, int length, [$E initialValue]) { | |
| 62 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis
t."); | |
| 63 } | |
| 64 List<$E> getRange(int start, int length) => | |
| 65 _Lists.getRange(this, start, length, <$E>[]); | |
| 66 | |
| 67 // -- end List<$E> mixins. | |
| OLD | NEW |