| // -- 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 new UnsupportedError("Cannot add to immutable List."); |
| } |
| |
| void addLast($E value) { |
| throw new UnsupportedError("Cannot add to immutable List."); |
| } |
| |
| void addAll(Collection<$E> collection) { |
| throw new UnsupportedError("Cannot add to immutable List."); |
| } |
| |
| $if DEFINE_CONTAINS |
| bool contains($E element) => _Collections.contains(this, element); |
| $else |
| // contains() defined by IDL. |
| $endif |
| |
| 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 get isEmpty => this.length == 0; |
| |
| // From List<$E>: |
| |
| void sort([Comparator<$E> compare = Comparable.compare]) { |
| throw new UnsupportedError("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 get last => this[length - 1]; |
| |
| $E removeLast() { |
| throw new UnsupportedError("Cannot removeLast on immutable List."); |
| } |
| |
| void setRange(int start, int rangeLength, List<$E> from, [int startFrom]) { |
| throw new UnsupportedError("Cannot setRange on immutable List."); |
| } |
| |
| void removeRange(int start, int rangeLength) { |
| throw new UnsupportedError("Cannot removeRange on immutable List."); |
| } |
| |
| void insertRange(int start, int rangeLength, [$E initialValue]) { |
| throw new UnsupportedError("Cannot insertRange on immutable List."); |
| } |
| |
| List<$E> getRange(int start, int rangeLength) => |
| _Lists.getRange(this, start, rangeLength, <$E>[]); |
| |
| // -- end List<$E> mixins. |