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