OLD | NEW |
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 interface ByteArray extends List default _InternalByteArray { | 5 interface ByteArray extends List default _InternalByteArray { |
6 ByteArray(int length); | 6 ByteArray(int length); |
7 | 7 |
8 int get length(); | 8 int get length(); |
9 | 9 |
10 int getInt8(int byteOffset); | 10 int getInt8(int byteOffset); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 int removeLast() { | 135 int removeLast() { |
136 throw const UnsupportedOperationException( | 136 throw const UnsupportedOperationException( |
137 "Cannot remove from a byte array"); | 137 "Cannot remove from a byte array"); |
138 } | 138 } |
139 | 139 |
140 int last() { | 140 int last() { |
141 return this[length - 1]; | 141 return this[length - 1]; |
142 } | 142 } |
143 | 143 |
| 144 String toString() { |
| 145 return Collections.collectionToString(this); |
| 146 } |
| 147 |
144 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | 148 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { |
145 if (length < 0) { | 149 if (length < 0) { |
146 throw new IllegalArgumentException("negative length $length"); | 150 throw new IllegalArgumentException("negative length $length"); |
147 } | 151 } |
148 if (from is ByteArray) { | 152 if (from is ByteArray) { |
149 _setRange(start, length, from, startFrom); | 153 _setRange(start, length, from, startFrom); |
150 } else { | 154 } else { |
151 Arrays.copy(from, startFrom, this, start, length); | 155 Arrays.copy(from, startFrom, this, start, length); |
152 } | 156 } |
153 } | 157 } |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 508 |
505 void _setFloat32(int byteOffset, double value) | 509 void _setFloat32(int byteOffset, double value) |
506 native "ExternalByteArray_setFloat32"; | 510 native "ExternalByteArray_setFloat32"; |
507 | 511 |
508 double _getFloat64(int byteOffset) | 512 double _getFloat64(int byteOffset) |
509 native "ExternalByteArray_getFloat64"; | 513 native "ExternalByteArray_getFloat64"; |
510 | 514 |
511 void _setFloat64(int byteOffset, double value) | 515 void _setFloat64(int byteOffset, double value) |
512 native "ExternalByteArray_setFloat64"; | 516 native "ExternalByteArray_setFloat64"; |
513 } | 517 } |
OLD | NEW |