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