Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: runtime/lib/array.dart

Issue 25931003: Make List.shuffle take an optional Random object to use. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/unmodifiable_collection/lib/unmodifiable_collection.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698