| OLD | NEW |
| 1 // -- start List<$E> mixins. | 1 // -- start List<$E> mixins. |
| 2 // $E is the element type. | 2 // $E is the element type. |
| 3 | 3 |
| 4 // From Iterable<$E>: | 4 // From Iterable<$E>: |
| 5 | 5 |
| 6 Iterator<$E> iterator() { | 6 Iterator<$E> iterator() { |
| 7 // Note: NodeLists are not fixed size. And most probably length shouldn't | 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 | 8 // be cached in both iterator _and_ forEach method. For now caching it |
| 9 // for consistency. | 9 // for consistency. |
| 10 return new FixedSizeListIterator<$E>(this); | 10 return new FixedSizeListIterator<$E>(this); |
| 11 } | 11 } |
| 12 | 12 |
| 13 // From Collection<$E>: | 13 // From Collection<$E>: |
| 14 | 14 |
| 15 void add($E value) { | 15 void add($E value) { |
| 16 throw new UnsupportedError("Cannot add to immutable List."); | 16 throw new UnsupportedError("Cannot add to immutable List."); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void addLast($E value) { | 19 void addLast($E value) { |
| 20 throw new UnsupportedError("Cannot add to immutable List."); | 20 throw new UnsupportedError("Cannot add to immutable List."); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void addAll(Collection<$E> collection) { | 23 void addAll(Collection<$E> collection) { |
| 24 throw new UnsupportedError("Cannot add to immutable List."); | 24 throw new UnsupportedError("Cannot add to immutable List."); |
| 25 } | 25 } |
| 26 | 26 |
| 27 $if DEFINE_CONTAINS | 27 $if DEFINE_CONTAINS |
| 28 bool contains($E element) => _Collections.contains(this, element); | 28 bool contains($E element) => Collections.contains(this, element); |
| 29 $else | 29 $else |
| 30 // contains() defined by IDL. | 30 // contains() defined by IDL. |
| 31 $endif | 31 $endif |
| 32 | 32 |
| 33 void forEach(void f($E element)) => _Collections.forEach(this, f); | 33 void forEach(void f($E element)) => Collections.forEach(this, f); |
| 34 | 34 |
| 35 Collection map(f($E element)) => _Collections.map(this, [], f); | 35 Collection map(f($E element)) => Collections.map(this, [], f); |
| 36 | 36 |
| 37 Collection<$E> filter(bool f($E element)) => | 37 Collection<$E> filter(bool f($E element)) => |
| 38 _Collections.filter(this, <$E>[], f); | 38 Collections.filter(this, <$E>[], f); |
| 39 | 39 |
| 40 bool every(bool f($E element)) => _Collections.every(this, f); | 40 bool every(bool f($E element)) => Collections.every(this, f); |
| 41 | 41 |
| 42 bool some(bool f($E element)) => _Collections.some(this, f); | 42 bool some(bool f($E element)) => Collections.some(this, f); |
| 43 | 43 |
| 44 bool get isEmpty => this.length == 0; | 44 bool get isEmpty => this.length == 0; |
| 45 | 45 |
| 46 // From List<$E>: | 46 // From List<$E>: |
| 47 | 47 |
| 48 void sort([Comparator<$E> compare = Comparable.compare]) { | 48 void sort([Comparator<$E> compare = Comparable.compare]) { |
| 49 throw new UnsupportedError("Cannot sort immutable List."); | 49 throw new UnsupportedError("Cannot sort immutable List."); |
| 50 } | 50 } |
| 51 | 51 |
| 52 int indexOf($E element, [int start = 0]) => | 52 int indexOf($E element, [int start = 0]) => |
| (...skipping 21 matching lines...) Expand all Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 void insertRange(int start, int rangeLength, [$E initialValue]) { | 76 void insertRange(int start, int rangeLength, [$E initialValue]) { |
| 77 throw new UnsupportedError("Cannot insertRange on immutable List."); | 77 throw new UnsupportedError("Cannot insertRange on immutable List."); |
| 78 } | 78 } |
| 79 | 79 |
| 80 List<$E> getRange(int start, int rangeLength) => | 80 List<$E> getRange(int start, int rangeLength) => |
| 81 _Lists.getRange(this, start, rangeLength, <$E>[]); | 81 _Lists.getRange(this, start, rangeLength, <$E>[]); |
| 82 | 82 |
| 83 // -- end List<$E> mixins. | 83 // -- end List<$E> mixins. |
| OLD | NEW |