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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 195 } |
196 | 196 |
197 bool get isNotEmpty => !isEmpty; | 197 bool get isNotEmpty => !isEmpty; |
198 | 198 |
199 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); | 199 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); |
200 | 200 |
201 void sort([int compare(E a, E b)]) { | 201 void sort([int compare(E a, E b)]) { |
202 IterableMixinWorkaround.sortList(this, compare); | 202 IterableMixinWorkaround.sortList(this, compare); |
203 } | 203 } |
204 | 204 |
205 void shuffle() { | 205 void shuffle([Random random]) { |
206 IterableMixinWorkaround.shuffleList(this); | 206 IterableMixinWorkaround.shuffleList(this, random); |
207 } | 207 } |
208 | 208 |
209 int indexOf(Object element, [int start = 0]) { | 209 int indexOf(Object element, [int start = 0]) { |
210 return Arrays.indexOf(this, element, start, this.length); | 210 return Arrays.indexOf(this, element, start, this.length); |
211 } | 211 } |
212 | 212 |
213 int lastIndexOf(Object element, [int start = null]) { | 213 int lastIndexOf(Object element, [int start = null]) { |
214 if (start == null) start = length - 1; | 214 if (start == null) start = length - 1; |
215 return Arrays.lastIndexOf(this, element, start); | 215 return Arrays.lastIndexOf(this, element, start); |
216 } | 216 } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 453 |
454 bool get isNotEmpty => !isEmpty; | 454 bool get isNotEmpty => !isEmpty; |
455 | 455 |
456 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); | 456 Iterable<E> get reversed => IterableMixinWorkaround.reversedList(this); |
457 | 457 |
458 void sort([int compare(E a, E b)]) { | 458 void sort([int compare(E a, E b)]) { |
459 throw new UnsupportedError( | 459 throw new UnsupportedError( |
460 "Cannot modify an immutable array"); | 460 "Cannot modify an immutable array"); |
461 } | 461 } |
462 | 462 |
463 void shuffle() { | 463 void shuffle([Random random]) { |
464 throw new UnsupportedError( | 464 throw new UnsupportedError( |
465 "Cannot modify an immutable array"); | 465 "Cannot modify an immutable array"); |
466 } | 466 } |
467 | 467 |
468 String toString() { | 468 String toString() { |
469 return IterableMixinWorkaround.toStringIterable(this, '[', ']'); | 469 return IterableMixinWorkaround.toStringIterable(this, '[', ']'); |
470 } | 470 } |
471 | 471 |
472 int indexOf(Object element, [int start = 0]) { | 472 int indexOf(Object element, [int start = 0]) { |
473 return Arrays.indexOf(this, element, start, this.length); | 473 return Arrays.indexOf(this, element, start, this.length); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 558 } |
559 _position = _length; | 559 _position = _length; |
560 _current = null; | 560 _current = null; |
561 return false; | 561 return false; |
562 } | 562 } |
563 | 563 |
564 E get current { | 564 E get current { |
565 return _current; | 565 return _current; |
566 } | 566 } |
567 } | 567 } |
OLD | NEW |