| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // TODO(srdjan): Use shared array implementation. | 6 // TODO(srdjan): Use shared array implementation. |
| 7 class _List<E> implements List<E> { | 7 class _List<E> implements List<E> { |
| 8 static final int _classId = (new _List(0))._cid; | 8 static final int _classId = (new _List(0))._cid; |
| 9 | 9 |
| 10 factory _List(length) native "List_allocate"; | 10 factory _List(length) native "List_allocate"; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 E get first { | 236 E get first { |
| 237 if (length > 0) return this[0]; | 237 if (length > 0) return this[0]; |
| 238 throw IterableElementError.noElement(); | 238 throw IterableElementError.noElement(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 E get last { | 241 E get last { |
| 242 if (length > 0) return this[length - 1]; | 242 if (length > 0) return this[length - 1]; |
| 243 throw IterableElementError.noElement(); | 243 throw IterableElementError.noElement(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void set last(E value) { | |
| 247 if (length == 0) throw IterableElementError.noElement(); | |
| 248 this[length - 1] = value; | |
| 249 } | |
| 250 | |
| 251 E get single { | 246 E get single { |
| 252 if (length == 1) return this[0]; | 247 if (length == 1) return this[0]; |
| 253 if (length == 0) throw IterableElementError.noElement(); | 248 if (length == 0) throw IterableElementError.noElement(); |
| 254 throw IterableElementError.tooMany(); | 249 throw IterableElementError.tooMany(); |
| 255 } | 250 } |
| 256 | 251 |
| 257 List<E> toList({ bool growable: true}) { | 252 List<E> toList({ bool growable: true}) { |
| 258 return new List<E>.from(this, growable: growable); | 253 return new List<E>.from(this, growable: growable); |
| 259 } | 254 } |
| 260 | 255 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 285 | 280 |
| 286 factory _ImmutableList._from(List from, int offset, int length) | 281 factory _ImmutableList._from(List from, int offset, int length) |
| 287 native "ImmutableList_from"; | 282 native "ImmutableList_from"; |
| 288 | 283 |
| 289 E operator [](int index) native "List_getIndexed"; | 284 E operator [](int index) native "List_getIndexed"; |
| 290 | 285 |
| 291 void operator []=(int index, E value) { | 286 void operator []=(int index, E value) { |
| 292 throw UnmodifiableListError.change(); | 287 throw UnmodifiableListError.change(); |
| 293 } | 288 } |
| 294 | 289 |
| 295 void set last(E value) { | |
| 296 throw UnmodifiableListError.change(); | |
| 297 } | |
| 298 | |
| 299 int get length native "List_getLength"; | 290 int get length native "List_getLength"; |
| 300 | 291 |
| 301 void insert(int index, E element) { | 292 void insert(int index, E element) { |
| 302 throw UnmodifiableListError.add(); | 293 throw UnmodifiableListError.add(); |
| 303 } | 294 } |
| 304 | 295 |
| 305 void insertAll(int index, Iterable<E> iterable) { | 296 void insertAll(int index, Iterable<E> iterable) { |
| 306 throw UnmodifiableListError.add(); | 297 throw UnmodifiableListError.add(); |
| 307 } | 298 } |
| 308 | 299 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 } | 530 } |
| 540 _position = _length; | 531 _position = _length; |
| 541 _current = null; | 532 _current = null; |
| 542 return false; | 533 return false; |
| 543 } | 534 } |
| 544 | 535 |
| 545 E get current { | 536 E get current { |
| 546 return _current; | 537 return _current; |
| 547 } | 538 } |
| 548 } | 539 } |
| OLD | NEW |