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