OLD | NEW |
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 // patch classes for Int8List ..... Float64List and ByteData implementations. | 5 // patch classes for Int8List ..... Float64List and ByteData implementations. |
6 | 6 |
7 import "dart:_internal"; | 7 import "dart:_internal"; |
8 import 'dart:math' show Random; | 8 import 'dart:math' show Random; |
9 | 9 |
10 patch class Int8List { | 10 patch class Int8List { |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 470 |
471 List toList({bool growable: true}) { | 471 List toList({bool growable: true}) { |
472 return new List.from(this, growable: growable); | 472 return new List.from(this, growable: growable); |
473 } | 473 } |
474 | 474 |
475 Set toSet() { | 475 Set toSet() { |
476 return new Set.from(this); | 476 return new Set.from(this); |
477 } | 477 } |
478 | 478 |
479 List sublist(int start, [int end]) { | 479 List sublist(int start, [int end]) { |
480 if (end == null) end = this.length; | 480 end = RangeError.checkValidRange(start, end, this.length); |
481 var length = end - start; | 481 var length = end - start; |
482 _rangeCheck(this.length, start, length); | |
483 List result = _createList(length); | 482 List result = _createList(length); |
484 result.setRange(0, length, this, start); | 483 result.setRange(0, length, this, start); |
485 return result; | 484 return result; |
486 } | 485 } |
487 | 486 |
488 void setRange(int start, int end, Iterable from, [int skipCount = 0]) { | 487 void setRange(int start, int end, Iterable from, [int skipCount = 0]) { |
489 // Check ranges. | 488 // Check ranges. |
490 if (0 > start || start > end || end > length) { | 489 if (0 > start || start > end || end > length) { |
491 RangeError.checkValidRange(start, end, length); // Always throws. | 490 RangeError.checkValidRange(start, end, length); // Always throws. |
492 assert(false); | 491 assert(false); |
(...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3609 } | 3608 } |
3610 } | 3609 } |
3611 | 3610 |
3612 | 3611 |
3613 int _defaultIfNull(object, value) { | 3612 int _defaultIfNull(object, value) { |
3614 if (object == null) { | 3613 if (object == null) { |
3615 return value; | 3614 return value; |
3616 } | 3615 } |
3617 return object; | 3616 return object; |
3618 } | 3617 } |
OLD | NEW |