OLD | NEW |
| (Empty) |
1 | |
2 class _Uint32ArrayJs extends _ArrayBufferViewJs implements Uint32Array, List<int
> native "*Uint32Array" { | |
3 | |
4 factory Uint32Array(int length) => _construct_Uint32Array(length); | |
5 | |
6 factory Uint32Array.fromList(List<int> list) => _construct_Uint32Array(list); | |
7 | |
8 factory Uint32Array.fromBuffer(ArrayBuffer buffer) => _construct_Uint32Array(b
uffer); | |
9 | |
10 static _construct_Uint32Array(arg) native 'return new Uint32Array(arg);'; | |
11 | |
12 static final int BYTES_PER_ELEMENT = 4; | |
13 | |
14 final int length; | |
15 | |
16 int operator[](int index) native "return this[index];"; | |
17 | |
18 void operator[]=(int index, int value) native "this[index] = value"; | |
19 // -- start List<int> mixins. | |
20 // int is the element type. | |
21 | |
22 // From Iterable<int>: | |
23 | |
24 Iterator<int> 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<int>(this); | |
29 } | |
30 | |
31 // From Collection<int>: | |
32 | |
33 void add(int value) { | |
34 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
35 } | |
36 | |
37 void addLast(int value) { | |
38 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
39 } | |
40 | |
41 void addAll(Collection<int> collection) { | |
42 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
43 } | |
44 | |
45 void forEach(void f(int element)) => _Collections.forEach(this, f); | |
46 | |
47 Collection map(f(int element)) => _Collections.map(this, [], f); | |
48 | |
49 Collection<int> filter(bool f(int element)) => | |
50 _Collections.filter(this, <int>[], f); | |
51 | |
52 bool every(bool f(int element)) => _Collections.every(this, f); | |
53 | |
54 bool some(bool f(int element)) => _Collections.some(this, f); | |
55 | |
56 bool isEmpty() => this.length == 0; | |
57 | |
58 // From List<int>: | |
59 | |
60 void sort(int compare(int a, int b)) { | |
61 throw new UnsupportedOperationException("Cannot sort immutable List."); | |
62 } | |
63 | |
64 int indexOf(int element, [int start = 0]) => | |
65 _Lists.indexOf(this, element, start, this.length); | |
66 | |
67 int lastIndexOf(int element, [int start = 0]) => | |
68 _Lists.lastIndexOf(this, element, start); | |
69 | |
70 int last() => this[length - 1]; | |
71 | |
72 // FIXME: implement thesee. | |
73 void setRange(int start, int length, List<int> 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, [int initialValue]) { | |
80 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis
t."); | |
81 } | |
82 List<int> getRange(int start, int length) => | |
83 _Lists.getRange(this, start, length, <int>[]); | |
84 | |
85 // -- end List<int> mixins. | |
86 | |
87 void setElements(Object array, [int offset = null]) native ''' | |
88 if (offset == null) return this.set(array); | |
89 return this.set(array, offset);'''; | |
90 | |
91 _Uint32ArrayJs subarray(int start, [int end = null]) native; | |
92 } | |
OLD | NEW |