| 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); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // From List<$E>: | 40 // From List<$E>: |
| 41 | 41 |
| 42 void sort(int compare($E a, $E b)) { | 42 void sort(int compare($E a, $E b)) { |
| 43 throw new UnsupportedOperationException("Cannot sort immutable List."); | 43 throw new UnsupportedOperationException("Cannot sort immutable List."); |
| 44 } | 44 } |
| 45 | 45 |
| 46 int indexOf($E element, [int start = 0]) => | 46 int indexOf($E element, [int start = 0]) => |
| 47 _Lists.indexOf(this, element, start, this.length); | 47 _Lists.indexOf(this, element, start, this.length); |
| 48 | 48 |
| 49 int lastIndexOf($E element, [int start = 0]) => | 49 int lastIndexOf($E element, [int start]) { |
| 50 _Lists.lastIndexOf(this, element, start); | 50 if (start === null) start = length - 1; |
| 51 return _Lists.lastIndexOf(this, element, start); |
| 52 } |
| 51 | 53 |
| 52 $E last() => this[length - 1]; | 54 $E last() => this[length - 1]; |
| 53 | 55 |
| 56 $E removeLast() { |
| 57 throw new UnsupportedOperationException("Cannot removeLast on immutable List
."); |
| 58 } |
| 59 |
| 54 // FIXME: implement these. | 60 // FIXME: implement these. |
| 55 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { | 61 void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { |
| 56 throw new UnsupportedOperationException("Cannot setRange on immutable List."
); | 62 throw new UnsupportedOperationException("Cannot setRange on immutable List."
); |
| 57 } | 63 } |
| 64 |
| 58 void removeRange(int start, int rangeLength) { | 65 void removeRange(int start, int rangeLength) { |
| 59 throw new UnsupportedOperationException("Cannot removeRange on immutable Lis
t."); | 66 throw new UnsupportedOperationException("Cannot removeRange on immutable Lis
t."); |
| 60 } | 67 } |
| 68 |
| 61 void insertRange(int start, int rangeLength, [$E initialValue]) { | 69 void insertRange(int start, int rangeLength, [$E initialValue]) { |
| 62 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis
t."); | 70 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis
t."); |
| 63 } | 71 } |
| 72 |
| 64 List<$E> getRange(int start, int rangeLength) => | 73 List<$E> getRange(int start, int rangeLength) => |
| 65 _Lists.getRange(this, start, rangeLength, <$E>[]); | 74 _Lists.getRange(this, start, rangeLength, <$E>[]); |
| 66 | 75 |
| 67 // -- end List<$E> mixins. | 76 // -- end List<$E> mixins. |
| OLD | NEW |