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

Side by Side Diff: third_party/pkg/js/lib/src/wrapping/js/array_to_list_adapter.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
« no previous file with comments | « third_party/pkg/js/lib/js_wrapping.dart ('k') | tools/dom/src/ImmutableListMixin.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of js.wrapping; 5 part of js.wrapping;
6 6
7 /// Adapter to handle a js array as a dart [List]. 7 /// Adapter to handle a js array as a dart [List].
8 /// You can provide a translator to automatically wrap contained Proxy to some 8 /// You can provide a translator to automatically wrap contained Proxy to some
9 /// TypedProxy or something else. 9 /// TypedProxy or something else.
10 class JsArrayToListAdapter<E> extends TypedProxy /*with ListMixin<E>*/ implement s List<E> { 10 class JsArrayToListAdapter<E> extends TypedProxy /*with ListMixin<E>*/ implement s List<E> {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 @override void operator []=(int index, E value) { 46 @override void operator []=(int index, E value) {
47 if (index < 0 || index >= this.length) throw new RangeError.value(index); 47 if (index < 0 || index >= this.length) throw new RangeError.value(index);
48 $unsafe[index] = _toJs(value); 48 $unsafe[index] = _toJs(value);
49 } 49 }
50 @override void set length(int length) { $unsafe.length = length; } 50 @override void set length(int length) { $unsafe.length = length; }
51 @override void sort([int compare(E a, E b)]) { 51 @override void sort([int compare(E a, E b)]) {
52 final sortedList = _asList()..sort(compare); 52 final sortedList = _asList()..sort(compare);
53 setRange(0, sortedList.length, sortedList); 53 setRange(0, sortedList.length, sortedList);
54 } 54 }
55 @override void shuffle() { 55 @override void shuffle([Random random]) {
56 final shuffledList = _asList()..shuffle(); 56 final shuffledList = _asList()..shuffle(random);
57 setRange(0, shuffledList.length, shuffledLength); 57 setRange(0, shuffledList.length, shuffledLength);
58 } 58 }
59 @override void insert(int index, E element) { 59 @override void insert(int index, E element) {
60 $unsafe.splice(index, 0, _toJs(element)); 60 $unsafe.splice(index, 0, _toJs(element));
61 } 61 }
62 @override E removeAt(int index) { 62 @override E removeAt(int index) {
63 if (index < 0 || index >= this.length) throw new RangeError.value(index); 63 if (index < 0 || index >= this.length) throw new RangeError.value(index);
64 return _fromJs($unsafe.splice(index, 1)[0]); 64 return _fromJs($unsafe.splice(index, 1)[0]);
65 } 65 }
66 @override E removeLast() => _fromJs($unsafe.pop()); 66 @override E removeLast() => _fromJs($unsafe.pop());
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // Iterator 547 // Iterator
548 @override bool moveNext() { 548 @override bool moveNext() {
549 if (_currentIndex + 1 < length) { 549 if (_currentIndex + 1 < length) {
550 _currentIndex++; 550 _currentIndex++;
551 return true; 551 return true;
552 } 552 }
553 return false; 553 return false;
554 } 554 }
555 @override E get current => _jsArray[_currentIndex]; 555 @override E get current => _jsArray[_currentIndex];
556 } 556 }
OLDNEW
« no previous file with comments | « third_party/pkg/js/lib/js_wrapping.dart ('k') | tools/dom/src/ImmutableListMixin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698