Chromium Code Reviews| Index: runtime/lib/byte_array.dart |
| =================================================================== |
| --- runtime/lib/byte_array.dart (revision 3621) |
| +++ runtime/lib/byte_array.dart (working copy) |
| @@ -63,6 +63,40 @@ |
| return _length(); |
| } |
| + void setRange(int start, int length, List<int> from, [int startFrom = 0]) { |
| + if (length < 0) { |
| + throw new IllegalArgumentException("negative length $length"); |
| + } |
| + if (from is ByteArray) { |
| + copy(this, start, from, startFrom, length); |
| + } else { |
| + Arrays.copy(from, startFrom, this, start, length); |
| + } |
| + } |
| + |
| + |
| + List getRange(int start, int length) { |
| + if (length == 0) return []; |
| + Arrays.rangeCheck(this, start, length); |
| + ByteArray list = new ByteArray(length); |
| + copy(list, 0, this, start, length); |
| + return list; |
| + } |
| + |
| + static copy(ByteArray dst, |
|
Anders Johnsen
2012/01/26 19:38:13
I'm not entirely happy with the placement of this
cshapiro
2012/01/27 23:00:04
I would create a private instance method _setRange
Anders Johnsen
2012/01/27 23:42:39
Thank you, way better! :)
|
| + int dstStart, |
| + ByteArray src, |
| + int srcStart, |
| + int length) { |
| + dst._copyFromByteArray(src, srcStart, dstStart, length); |
| + } |
| + |
| + void _copyFromByteArray(ByteArray src, |
| + int srcStart, |
| + int dstStart, |
| + int count) |
| + native "ByteArray_copyFromByteArray"; |
| + |
| bool every(bool f(int element)) { |
| return Collections.every(this, f); |
| } |