OLD | NEW |
1 // -- start List<$E> mixins. | 1 // -- start List<$E> mixins. |
2 // $E is the element type. | 2 // $E is the element type. |
3 | 3 |
4 $if DEFINE_LENGTH_AS_NUM_ITEMS | 4 $if DEFINE_LENGTH_AS_NUM_ITEMS |
5 // SVG Collections expose numberOfItems rather than length. | 5 // SVG Collections expose numberOfItems rather than length. |
6 int get length => numberOfItems; | 6 int get length => numberOfItems; |
7 $endif | 7 $endif |
8 | 8 |
9 $if DEFINE_LENGTH_SETTER | 9 $if DEFINE_LENGTH_SETTER |
10 void set length(int value) { | 10 set length(int value) { |
11 throw new UnsupportedError("Cannot resize immutable List."); | 11 throw new UnsupportedError("Cannot resize immutable List."); |
12 } | 12 } |
13 $endif | 13 $endif |
14 | 14 |
15 $E get first { | 15 $E get first { |
16 if (this.length > 0) { | 16 if (this.length > 0) { |
17 $if DART2JS | 17 $if DART2JS |
18 return JS('$E', '#[0]', this); | 18 return JS('$E', '#[0]', this); |
19 $else | 19 $else |
20 $if USE_NATIVE_INDEXED_GETTER | 20 $if USE_NATIVE_INDEXED_GETTER |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return this[0]; | 55 return this[0]; |
56 $endif | 56 $endif |
57 $endif | 57 $endif |
58 } | 58 } |
59 if (len == 0) throw new StateError("No elements"); | 59 if (len == 0) throw new StateError("No elements"); |
60 throw new StateError("More than one element"); | 60 throw new StateError("More than one element"); |
61 } | 61 } |
62 | 62 |
63 $E elementAt(int index) => this[index]; | 63 $E elementAt(int index) => this[index]; |
64 // -- end List<$E> mixins. | 64 // -- end List<$E> mixins. |
OLD | NEW |