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

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

Issue 11186017: Change sort on scalar arrays to take optional comparison function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « no previous file | no next file » | 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) 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 patch class Int8List { 5 patch class Int8List {
6 /* patch */ factory Int8List(int length) { 6 /* patch */ factory Int8List(int length) {
7 return new _Int8Array(length); 7 return new _Int8Array(length);
8 } 8 }
9 9
10 /* patch */ factory Int8List.view(ByteArray array, 10 /* patch */ factory Int8List.view(ByteArray array,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 void addLast(value) { 174 void addLast(value) {
175 throw const UnsupportedOperationException( 175 throw const UnsupportedOperationException(
176 "Cannot add to a non-extendable array"); 176 "Cannot add to a non-extendable array");
177 } 177 }
178 178
179 void addAll(Collection value) { 179 void addAll(Collection value) {
180 throw const UnsupportedOperationException( 180 throw const UnsupportedOperationException(
181 "Cannot add to a non-extendable array"); 181 "Cannot add to a non-extendable array");
182 } 182 }
183 183
184 void sort(int compare(a, b)) { 184 void sort([Comparator compare = Comparable.compare]) {
185 DualPivotQuicksort.sort(this, compare); 185 DualPivotQuicksort.sort(this, compare);
186 } 186 }
187 187
188 int indexOf(element, [int start = 0]) { 188 int indexOf(element, [int start = 0]) {
189 return Arrays.indexOf(this, element, start, this.length); 189 return Arrays.indexOf(this, element, start, this.length);
190 } 190 }
191 191
192 int lastIndexOf(element, [int start = null]) { 192 int lastIndexOf(element, [int start = null]) {
193 if (start === null) start = length - 1; 193 if (start === null) start = length - 1;
194 return Arrays.lastIndexOf(this, element, start); 194 return Arrays.lastIndexOf(this, element, start);
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 void addLast(value) { 1652 void addLast(value) {
1653 throw const UnsupportedOperationException( 1653 throw const UnsupportedOperationException(
1654 "Cannot add to a non-extendable array"); 1654 "Cannot add to a non-extendable array");
1655 } 1655 }
1656 1656
1657 void addAll(Collection value) { 1657 void addAll(Collection value) {
1658 throw const UnsupportedOperationException( 1658 throw const UnsupportedOperationException(
1659 "Cannot add to a non-extendable array"); 1659 "Cannot add to a non-extendable array");
1660 } 1660 }
1661 1661
1662 void sort(int compare(a, b)) { 1662 void sort([Comparator compare = Comparable.compare]) {
1663 DualPivotQuicksort.sort(this, compare); 1663 DualPivotQuicksort.sort(this, compare);
1664 } 1664 }
1665 1665
1666 int indexOf(element, [int start = 0]) { 1666 int indexOf(element, [int start = 0]) {
1667 return Arrays.indexOf(this, element, start, this.length); 1667 return Arrays.indexOf(this, element, start, this.length);
1668 } 1668 }
1669 1669
1670 int lastIndexOf(element, [int start = null]) { 1670 int lastIndexOf(element, [int start = null]) {
1671 if (start === null) start = length - 1; 1671 if (start === null) start = length - 1;
1672 return Arrays.lastIndexOf(this, element, start); 1672 return Arrays.lastIndexOf(this, element, start);
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 } 2409 }
2410 _rangeCheck(this.length, start, length); 2410 _rangeCheck(this.length, start, length);
2411 return _array.subByteArray(_offset + start, length); 2411 return _array.subByteArray(_offset + start, length);
2412 } 2412 }
2413 2413
2414 static const int _BYTES_PER_ELEMENT = 8; 2414 static const int _BYTES_PER_ELEMENT = 8;
2415 final ByteArray _array; 2415 final ByteArray _array;
2416 final int _offset; 2416 final int _offset;
2417 final int _length; 2417 final int _length;
2418 } 2418 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698