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

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

Issue 11727007: Add min and max to Iterable and Stream. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Address review comments. Fix T->E in Iterable. Created 7 years, 11 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 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.transferable(int length) { 10 /* patch */ factory Int8List.transferable(int length) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (length > 0) return this[length - 1]; 316 if (length > 0) return this[length - 1];
317 throw new StateError("No elements"); 317 throw new StateError("No elements");
318 } 318 }
319 319
320 int get single { 320 int get single {
321 if (length == 1) return this[0]; 321 if (length == 1) return this[0];
322 if (length == 0) throw new StateError("No elements"); 322 if (length == 0) throw new StateError("No elements");
323 throw new StateError("More than one element"); 323 throw new StateError("More than one element");
324 } 324 }
325 325
326 int min([int compare(int a, int b)]) => Collections.min(this, compare);
327
328 int max([int compare(int a, int b)]) => Collections.max(this, compare);
329
326 void removeRange(int start, int length) { 330 void removeRange(int start, int length) {
327 throw new UnsupportedError( 331 throw new UnsupportedError(
328 "Cannot remove from a non-extendable array"); 332 "Cannot remove from a non-extendable array");
329 } 333 }
330 334
331 void insertRange(int start, int length, [initialValue]) { 335 void insertRange(int start, int length, [initialValue]) {
332 throw new UnsupportedError( 336 throw new UnsupportedError(
333 "Cannot add to a non-extendable array"); 337 "Cannot add to a non-extendable array");
334 } 338 }
335 339
(...skipping 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 } 2673 }
2670 _rangeCheck(this.length, start, length); 2674 _rangeCheck(this.length, start, length);
2671 return _array.subByteArray(_offset + start, length); 2675 return _array.subByteArray(_offset + start, length);
2672 } 2676 }
2673 2677
2674 static const int _BYTES_PER_ELEMENT = 8; 2678 static const int _BYTES_PER_ELEMENT = 8;
2675 final ByteArray _array; 2679 final ByteArray _array;
2676 final int _offset; 2680 final int _offset;
2677 final int _length; 2681 final int _length;
2678 } 2682 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698