// -- start List<$E> mixins. | |
// $E is the element type. | |
// From Iterable<$E>: | |
Iterator<$E> iterator() { | |
// Note: NodeLists are not fixed size. And most probably length shouldn't | |
// be cached in both iterator _and_ forEach method. For now caching it | |
// for consistency. | |
return new _FixedSizeListIterator<$E>(this); | |
} | |
// From Collection<$E>: | |
void add($E value) { | |
throw const UnsupportedOperationException("Cannot add to immutable List."); | |
} | |
void addLast($E value) { | |
throw const UnsupportedOperationException("Cannot add to immutable List."); | |
} | |
void addAll(Collection<$E> collection) { | |
throw const UnsupportedOperationException("Cannot add to immutable List."); | |
} | |
void forEach(void f($E element)) => _Collections.forEach(this, f); | |
Collection map(f($E element)) => _Collections.map(this, [], f); | |
Collection<$E> filter(bool f($E element)) => | |
_Collections.filter(this, <$E>[], f); | |
bool every(bool f($E element)) => _Collections.every(this, f); | |
bool some(bool f($E element)) => _Collections.some(this, f); | |
bool isEmpty() => this.length == 0; | |
// From List<$E>: | |
void sort(int compare($E a, $E b)) { | |
throw const UnsupportedOperationException("Cannot sort immutable List."); | |
} | |
int indexOf($E element, [int start = 0]) => | |
_Lists.indexOf(this, element, start, this.length); | |
int lastIndexOf($E element, [int start]) { | |
if (start === null) start = length - 1; | |
return _Lists.lastIndexOf(this, element, start); | |
} | |
$E last() => this[length - 1]; | |
$E removeLast() { | |
throw const UnsupportedOperationException("Cannot removeLast on immutable List."); | |
} | |
void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { | |
throw const UnsupportedOperationException("Cannot setRange on immutable List."); | |
} | |
void removeRange(int start, int rangeLength) { | |
throw const UnsupportedOperationException("Cannot removeRange on immutable List."); | |
} | |
void insertRange(int start, int rangeLength, [$E initialValue]) { | |
throw const UnsupportedOperationException("Cannot insertRange on immutable List."); | |
} | |
List<$E> getRange(int start, int rangeLength) => | |
_Lists.getRange(this, start, rangeLength, <$E>[]); | |
// -- end List<$E> mixins. |