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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « runtime/lib/async_sources.gypi ('k') | runtime/lib/double.cc » ('j') | 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.transferable(int length) { 10 /* patch */ factory Int8List.transferable(int length) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 bool contains(element) => Collections.contains(this, element); 190 bool contains(element) => Collections.contains(this, element);
191 191
192 void forEach(void f(element)) { 192 void forEach(void f(element)) {
193 var len = this.length; 193 var len = this.length;
194 for (var i = 0; i < len; i++) { 194 for (var i = 0; i < len; i++) {
195 f(this[i]); 195 f(this[i]);
196 } 196 }
197 } 197 }
198 198
199 Collection map(f(element)) { 199 List mappedBy(f(int element)) {
200 return Collections.map(this, new List(), f); 200 return new MappedList<int, dynamic>(this, f);
201 }
202
203 String join([String separator]) {
204 return Collections.join(this, separator);
201 } 205 }
202 206
203 dynamic reduce(dynamic initialValue, 207 dynamic reduce(dynamic initialValue,
204 dynamic combine(dynamic initialValue, element)) { 208 dynamic combine(dynamic initialValue, element)) {
205 return Collections.reduce(this, initialValue, combine); 209 return Collections.reduce(this, initialValue, combine);
206 } 210 }
207 211
208 Collection filter(bool f(element)) { 212 Collection where(bool f(element)) {
209 return Collections.filter(this, new List(), f); 213 return new WhereIterable<int>(this, f);
214 }
215
216 List<int> take(int n) {
217 return new ListView<int>(this, 0, n);
218 }
219
220 Iterable<int> takeWhile(bool test(int value)) {
221 return new TakeWhileIterable<int>(this, test);
222 }
223
224 List<int> skip(int n) {
225 return new ListView<int>(this, n, null);
226 }
227
228 Iterable<int> skipWhile(bool test(int value)) {
229 return new SkipWhileIterable<int>(this, test);
210 } 230 }
211 231
212 bool every(bool f(element)) { 232 bool every(bool f(element)) {
213 return Collections.every(this, f); 233 return Collections.every(this, f);
214 } 234 }
215 235
216 bool some(bool f(element)) { 236 bool any(bool f(element)) {
217 return Collections.some(this, f); 237 return Collections.any(this, f);
238 }
239
240 int firstMatching(bool test(int value), {int orElse()}) {
241 return Collections.firstMatching(this, test, orElse);
242 }
243
244 int lastMatching(bool test(int value), {int orElse()}) {
245 return Collections.lastMatchingInList(this, test, orElse);
246 }
247
248 int singleMatching(bool test(int value)) {
249 return Collections.singleMatching(this, test);
250 }
251
252 int elementAt(int index) {
253 return this[index];
218 } 254 }
219 255
220 bool get isEmpty { 256 bool get isEmpty {
221 return this.length == 0; 257 return this.length == 0;
222 } 258 }
223 259
224 int get length { 260 int get length {
225 return _length(); 261 return _length();
226 } 262 }
227 263
228 // Methods implementing the List interface. 264 // Methods implementing the List interface.
229 265
230 set length(newLength) { 266 set length(newLength) {
231 throw new UnsupportedError( 267 throw new UnsupportedError(
232 "Cannot resize a non-extendable array"); 268 "Cannot resize a non-extendable array");
233 } 269 }
234 270
235 void add(value) { 271 void add(value) {
236 throw new UnsupportedError( 272 throw new UnsupportedError(
237 "Cannot add to a non-extendable array"); 273 "Cannot add to a non-extendable array");
238 } 274 }
239 275
240 void addLast(value) { 276 void addLast(value) {
241 throw new UnsupportedError( 277 throw new UnsupportedError(
242 "Cannot add to a non-extendable array"); 278 "Cannot add to a non-extendable array");
243 } 279 }
244 280
245 void addAll(Collection value) { 281 void addAll(Iterable value) {
246 throw new UnsupportedError( 282 throw new UnsupportedError(
247 "Cannot add to a non-extendable array"); 283 "Cannot add to a non-extendable array");
248 } 284 }
249 285
250 void sort([int compare(var a, var b)]) { 286 void sort([int compare(var a, var b)]) {
251 if (compare == null) compare = Comparable.compare; 287 if (compare == null) compare = Comparable.compare;
252 coreSort(this, compare); 288 coreSort(this, compare);
253 } 289 }
254 290
255 int indexOf(element, [int start = 0]) { 291 int indexOf(element, [int start = 0]) {
256 return Arrays.indexOf(this, element, start, this.length); 292 return Arrays.indexOf(this, element, start, this.length);
257 } 293 }
258 294
259 int lastIndexOf(element, [int start = null]) { 295 int lastIndexOf(element, [int start = null]) {
260 if (start == null) start = length - 1; 296 if (start == null) start = length - 1;
261 return Arrays.lastIndexOf(this, element, start); 297 return Arrays.lastIndexOf(this, element, start);
262 } 298 }
263 299
264 void clear() { 300 void clear() {
265 throw new UnsupportedError( 301 throw new UnsupportedError(
266 "Cannot remove from a non-extendable array"); 302 "Cannot remove from a non-extendable array");
267 } 303 }
268 304
269 int removeLast() { 305 int removeLast() {
270 throw new UnsupportedError( 306 throw new UnsupportedError(
271 "Cannot remove from a non-extendable array"); 307 "Cannot remove from a non-extendable array");
272 } 308 }
273 309
274 get first { 310 int get first {
275 return this[0]; 311 if (length > 0) return this[0];
312 throw new StateError("No elements");
276 } 313 }
277 314
278 get last { 315 int get last {
279 return this[length - 1]; 316 if (length > 0) return this[length - 1];
317 throw new StateError("No elements");
280 } 318 }
281 319
320 int get single {
321 if (length == 1) return this[0];
322 if (length == 0) throw new StateError("No elements");
323 throw new StateError("More than one element");
324 }
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
282 void removeRange(int start, int length) { 330 void removeRange(int start, int length) {
283 throw new UnsupportedError( 331 throw new UnsupportedError(
284 "Cannot remove from a non-extendable array"); 332 "Cannot remove from a non-extendable array");
285 } 333 }
286 334
287 void insertRange(int start, int length, [initialValue]) { 335 void insertRange(int start, int length, [initialValue]) {
288 throw new UnsupportedError( 336 throw new UnsupportedError(
289 "Cannot add to a non-extendable array"); 337 "Cannot add to a non-extendable array");
290 } 338 }
291 339
292 ByteArray asByteArray([int start = 0, int length]) { 340 ByteArray asByteArray([int start = 0, int length]) {
293 if (length == null) { 341 if (length == null) {
294 length = this.length; 342 length = this.length;
295 } 343 }
296 _rangeCheck(this.length, start, length); 344 _rangeCheck(this.length, start, length);
297 return new _ByteArrayView(this, 345 return new _ByteArrayView(this,
298 start * this.bytesPerElement(), 346 start * this.bytesPerElement(),
299 length * this.bytesPerElement()); 347 length * this.bytesPerElement());
300 } 348 }
301 349
350 List<int> toList() {
351 return new List<int>.from(this);
352 }
353
354 Set<int> toSet() {
355 return new Set<int>.from(this);
356 }
357
302 int _length() native "ByteArray_getLength"; 358 int _length() native "ByteArray_getLength";
303 359
304 void _setRange(int startInBytes, int lengthInBytes, 360 void _setRange(int startInBytes, int lengthInBytes,
305 _ByteArrayBase from, int startFromInBytes) 361 _ByteArrayBase from, int startFromInBytes)
306 native "ByteArray_setRange"; 362 native "ByteArray_setRange";
307 363
308 int _getInt8(int byteOffset) native "ByteArray_getInt8"; 364 int _getInt8(int byteOffset) native "ByteArray_getInt8";
309 int _setInt8(int byteOffset, int value) native "ByteArray_setInt8"; 365 int _setInt8(int byteOffset, int value) native "ByteArray_setInt8";
310 366
311 int _getUint8(int byteOffset) native "ByteArray_getUint8"; 367 int _getUint8(int byteOffset) native "ByteArray_getUint8";
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 } 485 }
430 486
431 int operator[](int index) { 487 int operator[](int index) {
432 return _getIndexed(index); 488 return _getIndexed(index);
433 } 489 }
434 490
435 int operator[]=(int index, int value) { 491 int operator[]=(int index, int value) {
436 _setIndexed(index, _toInt8(value)); 492 _setIndexed(index, _toInt8(value));
437 } 493 }
438 494
439 Iterator<int> iterator() { 495 Iterator<int> get iterator {
440 return new _ByteArrayIterator<int>(this); 496 return new _ByteArrayIterator<int>(this);
441 } 497 }
442 498
443 List<int> getRange(int start, int length) { 499 List<int> getRange(int start, int length) {
444 _rangeCheck(this.length, start, length); 500 _rangeCheck(this.length, start, length);
445 List<int> result = _new(length); 501 List<int> result = _new(length);
446 result.setRange(0, length, this, start); 502 result.setRange(0, length, this, start);
447 return result; 503 return result;
448 } 504 }
449 505
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 554 }
499 555
500 int operator[](int index) { 556 int operator[](int index) {
501 return _getIndexed(index); 557 return _getIndexed(index);
502 } 558 }
503 559
504 int operator[]=(int index, int value) { 560 int operator[]=(int index, int value) {
505 _setIndexed(index, _toUint8(value)); 561 _setIndexed(index, _toUint8(value));
506 } 562 }
507 563
508 Iterator<int> iterator() { 564 Iterator<int> get iterator {
509 return new _ByteArrayIterator<int>(this); 565 return new _ByteArrayIterator<int>(this);
510 } 566 }
511 567
512 List<int> getRange(int start, int length) { 568 List<int> getRange(int start, int length) {
513 _rangeCheck(this.length, start, length); 569 _rangeCheck(this.length, start, length);
514 List<int> result = _new(length); 570 List<int> result = _new(length);
515 result.setRange(0, length, this, start); 571 result.setRange(0, length, this, start);
516 return result; 572 return result;
517 } 573 }
518 574
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 625 }
570 626
571 int operator[](int index) { 627 int operator[](int index) {
572 return _getIndexed(index); 628 return _getIndexed(index);
573 } 629 }
574 630
575 int operator[]=(int index, int value) { 631 int operator[]=(int index, int value) {
576 _setIndexed(index, _toClampedUint8(value)); 632 _setIndexed(index, _toClampedUint8(value));
577 } 633 }
578 634
579 Iterator<int> iterator() { 635 Iterator<int> get iterator {
580 return new _ByteArrayIterator<int>(this); 636 return new _ByteArrayIterator<int>(this);
581 } 637 }
582 638
583 List<int> getRange(int start, int length) { 639 List<int> getRange(int start, int length) {
584 _rangeCheck(this.length, start, length); 640 _rangeCheck(this.length, start, length);
585 List<int> result = _new(length); 641 List<int> result = _new(length);
586 result.setRange(0, length, this, start); 642 result.setRange(0, length, this, start);
587 return result; 643 return result;
588 } 644 }
589 645
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 } 695 }
640 696
641 int operator[](int index) { 697 int operator[](int index) {
642 return _getIndexed(index); 698 return _getIndexed(index);
643 } 699 }
644 700
645 int operator[]=(int index, int value) { 701 int operator[]=(int index, int value) {
646 _setIndexed(index, _toInt16(value)); 702 _setIndexed(index, _toInt16(value));
647 } 703 }
648 704
649 Iterator<int> iterator() { 705 Iterator<int> get iterator {
650 return new _ByteArrayIterator<int>(this); 706 return new _ByteArrayIterator<int>(this);
651 } 707 }
652 708
653 List<int> getRange(int start, int length) { 709 List<int> getRange(int start, int length) {
654 _rangeCheck(this.length, start, length); 710 _rangeCheck(this.length, start, length);
655 List<int> result = _new(length); 711 List<int> result = _new(length);
656 result.setRange(0, length, this, start); 712 result.setRange(0, length, this, start);
657 return result; 713 return result;
658 } 714 }
659 715
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 } 764 }
709 765
710 int operator[](int index) { 766 int operator[](int index) {
711 return _getIndexed(index); 767 return _getIndexed(index);
712 } 768 }
713 769
714 int operator[]=(int index, int value) { 770 int operator[]=(int index, int value) {
715 _setIndexed(index, _toUint16(value)); 771 _setIndexed(index, _toUint16(value));
716 } 772 }
717 773
718 Iterator<int> iterator() { 774 Iterator<int> get iterator {
719 return new _ByteArrayIterator<int>(this); 775 return new _ByteArrayIterator<int>(this);
720 } 776 }
721 777
722 List<int> getRange(int start, int length) { 778 List<int> getRange(int start, int length) {
723 _rangeCheck(this.length, start, length); 779 _rangeCheck(this.length, start, length);
724 List<int> result = _new(length); 780 List<int> result = _new(length);
725 result.setRange(0, length, this, start); 781 result.setRange(0, length, this, start);
726 return result; 782 return result;
727 } 783 }
728 784
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 } 833 }
778 834
779 int operator[](int index) { 835 int operator[](int index) {
780 return _getIndexed(index); 836 return _getIndexed(index);
781 } 837 }
782 838
783 int operator[]=(int index, int value) { 839 int operator[]=(int index, int value) {
784 _setIndexed(index, _toInt32(value)); 840 _setIndexed(index, _toInt32(value));
785 } 841 }
786 842
787 Iterator<int> iterator() { 843 Iterator<int> get iterator {
788 return new _ByteArrayIterator<int>(this); 844 return new _ByteArrayIterator<int>(this);
789 } 845 }
790 846
791 List<int> getRange(int start, int length) { 847 List<int> getRange(int start, int length) {
792 _rangeCheck(this.length, start, length); 848 _rangeCheck(this.length, start, length);
793 List<int> result = _new(length); 849 List<int> result = _new(length);
794 result.setRange(0, length, this, start); 850 result.setRange(0, length, this, start);
795 return result; 851 return result;
796 } 852 }
797 853
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 } 903 }
848 904
849 int operator[](int index) { 905 int operator[](int index) {
850 return _getIndexed(index); 906 return _getIndexed(index);
851 } 907 }
852 908
853 int operator[]=(int index, int value) { 909 int operator[]=(int index, int value) {
854 _setIndexed(index, _toUint32(value)); 910 _setIndexed(index, _toUint32(value));
855 } 911 }
856 912
857 Iterator<int> iterator() { 913 Iterator<int> get iterator {
858 return new _ByteArrayIterator<int>(this); 914 return new _ByteArrayIterator<int>(this);
859 } 915 }
860 916
861 List<int> getRange(int start, int length) { 917 List<int> getRange(int start, int length) {
862 _rangeCheck(this.length, start, length); 918 _rangeCheck(this.length, start, length);
863 List<int> result = _new(length); 919 List<int> result = _new(length);
864 result.setRange(0, length, this, start); 920 result.setRange(0, length, this, start);
865 return result; 921 return result;
866 } 922 }
867 923
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 } 972 }
917 973
918 int operator[](int index) { 974 int operator[](int index) {
919 return _getIndexed(index); 975 return _getIndexed(index);
920 } 976 }
921 977
922 int operator[]=(int index, int value) { 978 int operator[]=(int index, int value) {
923 _setIndexed(index, _toInt64(value)); 979 _setIndexed(index, _toInt64(value));
924 } 980 }
925 981
926 Iterator<int> iterator() { 982 Iterator<int> get iterator {
927 return new _ByteArrayIterator<int>(this); 983 return new _ByteArrayIterator<int>(this);
928 } 984 }
929 985
930 List<int> getRange(int start, int length) { 986 List<int> getRange(int start, int length) {
931 _rangeCheck(this.length, start, length); 987 _rangeCheck(this.length, start, length);
932 List<int> result = _new(length); 988 List<int> result = _new(length);
933 result.setRange(0, length, this, start); 989 result.setRange(0, length, this, start);
934 return result; 990 return result;
935 } 991 }
936 992
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } 1041 }
986 1042
987 int operator[](int index) { 1043 int operator[](int index) {
988 return _getIndexed(index); 1044 return _getIndexed(index);
989 } 1045 }
990 1046
991 int operator[]=(int index, int value) { 1047 int operator[]=(int index, int value) {
992 _setIndexed(index, _toUint64(value)); 1048 _setIndexed(index, _toUint64(value));
993 } 1049 }
994 1050
995 Iterator<int> iterator() { 1051 Iterator<int> get iterator {
996 return new _ByteArrayIterator<int>(this); 1052 return new _ByteArrayIterator<int>(this);
997 } 1053 }
998 1054
999 List<int> getRange(int start, int length) { 1055 List<int> getRange(int start, int length) {
1000 _rangeCheck(this.length, start, length); 1056 _rangeCheck(this.length, start, length);
1001 List<int> result = _new(length); 1057 List<int> result = _new(length);
1002 result.setRange(0, length, this, start); 1058 result.setRange(0, length, this, start);
1003 return result; 1059 return result;
1004 } 1060 }
1005 1061
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } 1110 }
1055 1111
1056 double operator[](int index) { 1112 double operator[](int index) {
1057 return _getIndexed(index); 1113 return _getIndexed(index);
1058 } 1114 }
1059 1115
1060 int operator[]=(int index, double value) { 1116 int operator[]=(int index, double value) {
1061 _setIndexed(index, value); 1117 _setIndexed(index, value);
1062 } 1118 }
1063 1119
1064 Iterator<double> iterator() { 1120 Iterator<double> get iterator {
1065 return new _ByteArrayIterator<double>(this); 1121 return new _ByteArrayIterator<double>(this);
1066 } 1122 }
1067 1123
1068 List<double> getRange(int start, int length) { 1124 List<double> getRange(int start, int length) {
1069 _rangeCheck(this.length, start, length); 1125 _rangeCheck(this.length, start, length);
1070 List<double> result = _new(length); 1126 List<double> result = _new(length);
1071 result.setRange(0, length, this, start); 1127 result.setRange(0, length, this, start);
1072 return result; 1128 return result;
1073 } 1129 }
1074 1130
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 } 1179 }
1124 1180
1125 double operator[](int index) { 1181 double operator[](int index) {
1126 return _getIndexed(index); 1182 return _getIndexed(index);
1127 } 1183 }
1128 1184
1129 int operator[]=(int index, double value) { 1185 int operator[]=(int index, double value) {
1130 _setIndexed(index, value); 1186 _setIndexed(index, value);
1131 } 1187 }
1132 1188
1133 Iterator<double> iterator() { 1189 Iterator<double> get iterator {
1134 return new _ByteArrayIterator<double>(this); 1190 return new _ByteArrayIterator<double>(this);
1135 } 1191 }
1136 1192
1137 List<double> getRange(int start, int length) { 1193 List<double> getRange(int start, int length) {
1138 _rangeCheck(this.length, start, length); 1194 _rangeCheck(this.length, start, length);
1139 List<double> result = _new(length); 1195 List<double> result = _new(length);
1140 result.setRange(0, length, this, start); 1196 result.setRange(0, length, this, start);
1141 return result; 1197 return result;
1142 } 1198 }
1143 1199
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 1233
1178 class _ExternalInt8Array extends _ByteArrayBase implements Int8List { 1234 class _ExternalInt8Array extends _ByteArrayBase implements Int8List {
1179 int operator[](int index) { 1235 int operator[](int index) {
1180 return _getIndexed(index); 1236 return _getIndexed(index);
1181 } 1237 }
1182 1238
1183 int operator[]=(int index, int value) { 1239 int operator[]=(int index, int value) {
1184 _setIndexed(index, _toInt8(value)); 1240 _setIndexed(index, _toInt8(value));
1185 } 1241 }
1186 1242
1187 Iterator<int> iterator() { 1243 Iterator<int> get iterator {
1188 return new _ByteArrayIterator<int>(this); 1244 return new _ByteArrayIterator<int>(this);
1189 } 1245 }
1190 1246
1191 List<int> getRange(int start, int length) { 1247 List<int> getRange(int start, int length) {
1192 _rangeCheck(this.length, start, length); 1248 _rangeCheck(this.length, start, length);
1193 List<int> result = new Int8List(length); 1249 List<int> result = new Int8List(length);
1194 result.setRange(0, length, this, start); 1250 result.setRange(0, length, this, start);
1195 return result; 1251 return result;
1196 } 1252 }
1197 1253
(...skipping 29 matching lines...) Expand all
1227 1283
1228 class _ExternalUint8Array extends _ByteArrayBase implements Uint8List { 1284 class _ExternalUint8Array extends _ByteArrayBase implements Uint8List {
1229 int operator[](int index) { 1285 int operator[](int index) {
1230 return _getIndexed(index); 1286 return _getIndexed(index);
1231 } 1287 }
1232 1288
1233 int operator[]=(int index, int value) { 1289 int operator[]=(int index, int value) {
1234 _setIndexed(index, _toUint8(value)); 1290 _setIndexed(index, _toUint8(value));
1235 } 1291 }
1236 1292
1237 Iterator<int> iterator() { 1293 Iterator<int> get iterator {
1238 return new _ByteArrayIterator<int>(this); 1294 return new _ByteArrayIterator<int>(this);
1239 } 1295 }
1240 1296
1241 List<int> getRange(int start, int length) { 1297 List<int> getRange(int start, int length) {
1242 _rangeCheck(this.length, start, length); 1298 _rangeCheck(this.length, start, length);
1243 List<int> result = new Uint8List(length); 1299 List<int> result = new Uint8List(length);
1244 result.setRange(0, length, this, start); 1300 result.setRange(0, length, this, start);
1245 return result; 1301 return result;
1246 } 1302 }
1247 1303
(...skipping 29 matching lines...) Expand all
1277 1333
1278 class _ExternalInt16Array extends _ByteArrayBase implements Int16List { 1334 class _ExternalInt16Array extends _ByteArrayBase implements Int16List {
1279 int operator[](int index) { 1335 int operator[](int index) {
1280 return _getIndexed(index); 1336 return _getIndexed(index);
1281 } 1337 }
1282 1338
1283 int operator[]=(int index, int value) { 1339 int operator[]=(int index, int value) {
1284 _setIndexed(index, _toInt16(value)); 1340 _setIndexed(index, _toInt16(value));
1285 } 1341 }
1286 1342
1287 Iterator<int> iterator() { 1343 Iterator<int> get iterator {
1288 return new _ByteArrayIterator<int>(this); 1344 return new _ByteArrayIterator<int>(this);
1289 } 1345 }
1290 1346
1291 List<int> getRange(int start, int length) { 1347 List<int> getRange(int start, int length) {
1292 _rangeCheck(this.length, start, length); 1348 _rangeCheck(this.length, start, length);
1293 List<int> result = new Int16List(length); 1349 List<int> result = new Int16List(length);
1294 result.setRange(0, length, this, start); 1350 result.setRange(0, length, this, start);
1295 return result; 1351 return result;
1296 } 1352 }
1297 1353
(...skipping 29 matching lines...) Expand all
1327 1383
1328 class _ExternalUint16Array extends _ByteArrayBase implements Uint16List { 1384 class _ExternalUint16Array extends _ByteArrayBase implements Uint16List {
1329 int operator[](int index) { 1385 int operator[](int index) {
1330 return _getIndexed(index); 1386 return _getIndexed(index);
1331 } 1387 }
1332 1388
1333 int operator[]=(int index, int value) { 1389 int operator[]=(int index, int value) {
1334 _setIndexed(index, _toUint16(value)); 1390 _setIndexed(index, _toUint16(value));
1335 } 1391 }
1336 1392
1337 Iterator<int> iterator() { 1393 Iterator<int> get iterator {
1338 return new _ByteArrayIterator<int>(this); 1394 return new _ByteArrayIterator<int>(this);
1339 } 1395 }
1340 1396
1341 List<int> getRange(int start, int length) { 1397 List<int> getRange(int start, int length) {
1342 _rangeCheck(this.length, start, length); 1398 _rangeCheck(this.length, start, length);
1343 List<int> result = new Uint16List(length); 1399 List<int> result = new Uint16List(length);
1344 result.setRange(0, length, this, start); 1400 result.setRange(0, length, this, start);
1345 return result; 1401 return result;
1346 } 1402 }
1347 1403
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 1435
1380 class _ExternalInt32Array extends _ByteArrayBase implements Int32List { 1436 class _ExternalInt32Array extends _ByteArrayBase implements Int32List {
1381 int operator[](int index) { 1437 int operator[](int index) {
1382 return _getIndexed(index); 1438 return _getIndexed(index);
1383 } 1439 }
1384 1440
1385 int operator[]=(int index, int value) { 1441 int operator[]=(int index, int value) {
1386 _setIndexed(index, _toInt32(value)); 1442 _setIndexed(index, _toInt32(value));
1387 } 1443 }
1388 1444
1389 Iterator<int> iterator() { 1445 Iterator<int> get iterator {
1390 return new _ByteArrayIterator<int>(this); 1446 return new _ByteArrayIterator<int>(this);
1391 } 1447 }
1392 1448
1393 List<int> getRange(int start, int length) { 1449 List<int> getRange(int start, int length) {
1394 _rangeCheck(this.length, start, length); 1450 _rangeCheck(this.length, start, length);
1395 List<int> result = new Int32List(length); 1451 List<int> result = new Int32List(length);
1396 result.setRange(0, length, this, start); 1452 result.setRange(0, length, this, start);
1397 return result; 1453 return result;
1398 } 1454 }
1399 1455
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 1487
1432 class _ExternalUint32Array extends _ByteArrayBase implements Uint32List { 1488 class _ExternalUint32Array extends _ByteArrayBase implements Uint32List {
1433 int operator[](int index) { 1489 int operator[](int index) {
1434 return _getIndexed(index); 1490 return _getIndexed(index);
1435 } 1491 }
1436 1492
1437 int operator[]=(int index, int value) { 1493 int operator[]=(int index, int value) {
1438 _setIndexed(index, _toUint32(value)); 1494 _setIndexed(index, _toUint32(value));
1439 } 1495 }
1440 1496
1441 Iterator<int> iterator() { 1497 Iterator<int> get iterator {
1442 return new _ByteArrayIterator<int>(this); 1498 return new _ByteArrayIterator<int>(this);
1443 } 1499 }
1444 1500
1445 List<int> getRange(int start, int length) { 1501 List<int> getRange(int start, int length) {
1446 _rangeCheck(this.length, start, length); 1502 _rangeCheck(this.length, start, length);
1447 List<int> result = new Uint32List(length); 1503 List<int> result = new Uint32List(length);
1448 result.setRange(0, length, this, start); 1504 result.setRange(0, length, this, start);
1449 return result; 1505 return result;
1450 } 1506 }
1451 1507
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 1539
1484 class _ExternalInt64Array extends _ByteArrayBase implements Int64List { 1540 class _ExternalInt64Array extends _ByteArrayBase implements Int64List {
1485 int operator[](int index) { 1541 int operator[](int index) {
1486 return _getIndexed(index); 1542 return _getIndexed(index);
1487 } 1543 }
1488 1544
1489 int operator[]=(int index, int value) { 1545 int operator[]=(int index, int value) {
1490 _setIndexed(index, _toInt64(value)); 1546 _setIndexed(index, _toInt64(value));
1491 } 1547 }
1492 1548
1493 Iterator<int> iterator() { 1549 Iterator<int> get iterator {
1494 return new _ByteArrayIterator<int>(this); 1550 return new _ByteArrayIterator<int>(this);
1495 } 1551 }
1496 1552
1497 List<int> getRange(int start, int length) { 1553 List<int> getRange(int start, int length) {
1498 _rangeCheck(this.length, start, length); 1554 _rangeCheck(this.length, start, length);
1499 List<int> result = new Int64List(length); 1555 List<int> result = new Int64List(length);
1500 result.setRange(0, length, this, start); 1556 result.setRange(0, length, this, start);
1501 return result; 1557 return result;
1502 } 1558 }
1503 1559
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 1591
1536 class _ExternalUint64Array extends _ByteArrayBase implements Uint64List { 1592 class _ExternalUint64Array extends _ByteArrayBase implements Uint64List {
1537 int operator[](int index) { 1593 int operator[](int index) {
1538 return _getIndexed(index); 1594 return _getIndexed(index);
1539 } 1595 }
1540 1596
1541 int operator[]=(int index, int value) { 1597 int operator[]=(int index, int value) {
1542 _setIndexed(index, _toUint64(value)); 1598 _setIndexed(index, _toUint64(value));
1543 } 1599 }
1544 1600
1545 Iterator<int> iterator() { 1601 Iterator<int> get iterator {
1546 return new _ByteArrayIterator<int>(this); 1602 return new _ByteArrayIterator<int>(this);
1547 } 1603 }
1548 1604
1549 List<int> getRange(int start, int length) { 1605 List<int> getRange(int start, int length) {
1550 _rangeCheck(this.length, start, length); 1606 _rangeCheck(this.length, start, length);
1551 List<int> result = new Uint64List(length); 1607 List<int> result = new Uint64List(length);
1552 result.setRange(0, length, this, start); 1608 result.setRange(0, length, this, start);
1553 return result; 1609 return result;
1554 } 1610 }
1555 1611
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 1643
1588 class _ExternalFloat32Array extends _ByteArrayBase implements Float32List { 1644 class _ExternalFloat32Array extends _ByteArrayBase implements Float32List {
1589 double operator[](int index) { 1645 double operator[](int index) {
1590 return _getIndexed(index); 1646 return _getIndexed(index);
1591 } 1647 }
1592 1648
1593 int operator[]=(int index, double value) { 1649 int operator[]=(int index, double value) {
1594 _setIndexed(index, value); 1650 _setIndexed(index, value);
1595 } 1651 }
1596 1652
1597 Iterator<double> iterator() { 1653 Iterator<double> get iterator {
1598 return new _ByteArrayIterator<double>(this); 1654 return new _ByteArrayIterator<double>(this);
1599 } 1655 }
1600 1656
1601 List<double> getRange(int start, int length) { 1657 List<double> getRange(int start, int length) {
1602 _rangeCheck(this.length, start, length); 1658 _rangeCheck(this.length, start, length);
1603 List<double> result = new Float32List(length); 1659 List<double> result = new Float32List(length);
1604 result.setRange(0, length, this, start); 1660 result.setRange(0, length, this, start);
1605 return result; 1661 return result;
1606 } 1662 }
1607 1663
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 1695
1640 class _ExternalFloat64Array extends _ByteArrayBase implements Float64List { 1696 class _ExternalFloat64Array extends _ByteArrayBase implements Float64List {
1641 double operator[](int index) { 1697 double operator[](int index) {
1642 return _getIndexed(index); 1698 return _getIndexed(index);
1643 } 1699 }
1644 1700
1645 int operator[]=(int index, double value) { 1701 int operator[]=(int index, double value) {
1646 _setIndexed(index, value); 1702 _setIndexed(index, value);
1647 } 1703 }
1648 1704
1649 Iterator<double> iterator() { 1705 Iterator<double> get iterator {
1650 return new _ByteArrayIterator<double>(this); 1706 return new _ByteArrayIterator<double>(this);
1651 } 1707 }
1652 1708
1653 List<double> getRange(int start, int length) { 1709 List<double> getRange(int start, int length) {
1654 _rangeCheck(this.length, start, length); 1710 _rangeCheck(this.length, start, length);
1655 List<double> result = new Float64List(length); 1711 List<double> result = new Float64List(length);
1656 result.setRange(0, length, this, start); 1712 result.setRange(0, length, this, start);
1657 return result; 1713 return result;
1658 } 1714 }
1659 1715
(...skipping 23 matching lines...) Expand all
1683 static const int _BYTES_PER_ELEMENT = 8; 1739 static const int _BYTES_PER_ELEMENT = 8;
1684 1740
1685 double _getIndexed(int index) 1741 double _getIndexed(int index)
1686 native "ExternalFloat64Array_getIndexed"; 1742 native "ExternalFloat64Array_getIndexed";
1687 int _setIndexed(int index, double value) 1743 int _setIndexed(int index, double value)
1688 native "ExternalFloat64Array_setIndexed"; 1744 native "ExternalFloat64Array_setIndexed";
1689 } 1745 }
1690 1746
1691 1747
1692 class _ByteArrayIterator<E> implements Iterator<E> { 1748 class _ByteArrayIterator<E> implements Iterator<E> {
1749 final List<E> _array;
1750 final int _length;
1751 int _position;
1752 E _current;
1753
1693 _ByteArrayIterator(List array) 1754 _ByteArrayIterator(List array)
1694 : _array = array, _length = array.length, _pos = 0 { 1755 : _array = array, _length = array.length, _position = -1 {
1695 assert(array is _ByteArrayBase || array is _ByteArrayViewBase); 1756 assert(array is _ByteArrayBase || array is _ByteArrayViewBase);
1696 } 1757 }
1697 1758
1698 bool get hasNext { 1759 bool moveNext() {
1699 return _length > _pos; 1760 int nextPosition = _position + 1;
1761 if (nextPosition < _length) {
1762 _current = _array[nextPosition];
1763 _position = nextPosition;
1764 return true;
1765 }
1766 _position = _length;
1767 _current = null;
1768 return false;
1700 } 1769 }
1701 1770
1702 E next() { 1771 E get current => _current;
1703 if (!hasNext) {
1704 throw new StateError("No more elements");
1705 }
1706 return _array[_pos++];
1707 }
1708
1709 final List<E> _array;
1710 final int _length;
1711 int _pos;
1712 } 1772 }
1713 1773
1714 1774
1715 class _ByteArrayView implements ByteArray { 1775 class _ByteArrayView implements ByteArray {
1716 _ByteArrayView(this._array, this._offset, this._length) { 1776 _ByteArrayView(this._array, this._offset, this._length) {
1717 _rangeCheck(_array.lengthInBytes(), _offset, _length); 1777 _rangeCheck(_array.lengthInBytes(), _offset, _length);
1718 } 1778 }
1719 1779
1720 int lengthInBytes() { 1780 int lengthInBytes() {
1721 return _length; 1781 return _length;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 int setFloat64(int byteOffset, double value) { 1860 int setFloat64(int byteOffset, double value) {
1801 return _array._setFloat64(_offset + byteOffset, value); 1861 return _array._setFloat64(_offset + byteOffset, value);
1802 } 1862 }
1803 1863
1804 final _ByteArrayBase _array; 1864 final _ByteArrayBase _array;
1805 final int _offset; 1865 final int _offset;
1806 final int _length; 1866 final int _length;
1807 } 1867 }
1808 1868
1809 1869
1810 class _ByteArrayViewBase { 1870 // TODO(floitsch): extending the collection adds extra cost (because of type
1871 // parameters). Consider copying the functions from Collection into this class
1872 // and just implementing Collection<int>.
1873 class _ByteArrayViewBase extends Collection<int> {
1811 num operator[](int index); 1874 num operator[](int index);
1812 1875
1813 // Methods implementing the Collection interface. 1876 // Methods implementing the Collection interface.
1814 1877
1815 void forEach(void f(element)) { 1878 void forEach(void f(element)) {
1816 var len = this.length; 1879 var len = this.length;
1817 for (var i = 0; i < len; i++) { 1880 for (var i = 0; i < len; i++) {
1818 f(this[i]); 1881 f(this[i]);
1819 } 1882 }
1820 } 1883 }
1821 1884
1822 Collection map(f(element)) {
1823 return Collections.map(this, new List(), f);
1824 }
1825
1826 dynamic reduce(dynamic initialValue,
1827 dynamic combine(dynamic initialValue, element)) {
1828 return Collections.reduce(this, initialValue, combine);
1829 }
1830
1831 Collection filter(bool f(element)) {
1832 return Collections.filter(this, new List(), f);
1833 }
1834
1835 bool every(bool f(element)) {
1836 return Collections.every(this, f);
1837 }
1838
1839 bool some(bool f(element)) {
1840 return Collections.some(this, f);;
1841 }
1842
1843 bool get isEmpty { 1885 bool get isEmpty {
1844 return this.length == 0; 1886 return this.length == 0;
1845 } 1887 }
1846 1888
1847 int get length; 1889 int get length;
1848 1890
1849 // Methods implementing the List interface. 1891 // Methods implementing the List interface.
1850 1892
1851 set length(newLength) { 1893 set length(newLength) {
1852 throw new UnsupportedError( 1894 throw new UnsupportedError(
1853 "Cannot resize a non-extendable array"); 1895 "Cannot resize a non-extendable array");
1854 } 1896 }
1855 1897
1856 void add(value) { 1898 void add(value) {
1857 throw new UnsupportedError( 1899 throw new UnsupportedError(
1858 "Cannot add to a non-extendable array"); 1900 "Cannot add to a non-extendable array");
1859 } 1901 }
1860 1902
1861 void addLast(value) { 1903 void addLast(value) {
1862 throw new UnsupportedError( 1904 throw new UnsupportedError(
1863 "Cannot add to a non-extendable array"); 1905 "Cannot add to a non-extendable array");
1864 } 1906 }
1865 1907
1866 void addAll(Collection value) { 1908 void addAll(Iterable value) {
1867 throw new UnsupportedError( 1909 throw new UnsupportedError(
1868 "Cannot add to a non-extendable array"); 1910 "Cannot add to a non-extendable array");
1869 } 1911 }
1870 1912
1871 void sort([int compare(var a, var b)]) { 1913 void sort([int compare(var a, var b)]) {
1872 if (compare == null) compare = Comparable.compare; 1914 if (compare == null) compare = Comparable.compare;
1873 coreSort(this, compare); 1915 coreSort(this, compare);
1874 } 1916 }
1875 1917
1876 int indexOf(element, [int start = 0]) { 1918 int indexOf(element, [int start = 0]) {
1877 return Arrays.indexOf(this, element, start, this.length); 1919 return Arrays.indexOf(this, element, start, this.length);
1878 } 1920 }
1879 1921
1880 int lastIndexOf(element, [int start = null]) { 1922 int lastIndexOf(element, [int start = null]) {
1881 if (start == null) start = length - 1; 1923 if (start == null) start = length - 1;
1882 return Arrays.lastIndexOf(this, element, start); 1924 return Arrays.lastIndexOf(this, element, start);
1883 } 1925 }
1884 1926
1885 void clear() { 1927 void clear() {
1886 throw new UnsupportedError( 1928 throw new UnsupportedError(
1887 "Cannot remove from a non-extendable array"); 1929 "Cannot remove from a non-extendable array");
1888 } 1930 }
1889 1931
1890 int removeLast() { 1932 int removeLast() {
1891 throw new UnsupportedError( 1933 throw new UnsupportedError(
1892 "Cannot remove from a non-extendable array"); 1934 "Cannot remove from a non-extendable array");
1893 } 1935 }
1894 1936
1895 get first { 1937 int get first {
1896 return this[0]; 1938 if (length > 0) return this[0];
1939 throw new StateError("No elements");
1897 } 1940 }
1898 1941
1899 get last { 1942 int get last {
1900 return this[length - 1]; 1943 if (length > 0) return this[length - 1];
1944 throw new StateError("No elements");
1945 }
1946
1947 int get single {
1948 if (length == 1) return this[0];
1949 if (length == 0) throw new StateError("No elements");
1950 throw new StateError("More than one element");
1901 } 1951 }
1902 1952
1903 void removeRange(int start, int length) { 1953 void removeRange(int start, int length) {
1904 throw new UnsupportedError( 1954 throw new UnsupportedError(
1905 "Cannot remove from a non-extendable array"); 1955 "Cannot remove from a non-extendable array");
1906 } 1956 }
1907 1957
1908 void insertRange(int start, int length, [initialValue]) { 1958 void insertRange(int start, int length, [initialValue]) {
1909 throw new UnsupportedError( 1959 throw new UnsupportedError(
1910 "Cannot add to a non-extendable array"); 1960 "Cannot add to a non-extendable array");
(...skipping 24 matching lines...) Expand all
1935 } 1985 }
1936 1986
1937 void operator[]=(int index, int value) { 1987 void operator[]=(int index, int value) {
1938 if (index < 0 || index >= _length) { 1988 if (index < 0 || index >= _length) {
1939 String message = "$index must be in the range [0..$_length)"; 1989 String message = "$index must be in the range [0..$_length)";
1940 throw new RangeError(message); 1990 throw new RangeError(message);
1941 } 1991 }
1942 _array.setInt8(_offset + (index * _BYTES_PER_ELEMENT), _toInt8(value)); 1992 _array.setInt8(_offset + (index * _BYTES_PER_ELEMENT), _toInt8(value));
1943 } 1993 }
1944 1994
1945 Iterator<int> iterator() { 1995 Iterator<int> get iterator {
1946 return new _ByteArrayIterator<int>(this); 1996 return new _ByteArrayIterator<int>(this);
1947 } 1997 }
1948 1998
1949 List<int> getRange(int start, int length) { 1999 List<int> getRange(int start, int length) {
1950 _rangeCheck(this.length, start, length); 2000 _rangeCheck(this.length, start, length);
1951 List<int> result = new Int8List(length); 2001 List<int> result = new Int8List(length);
1952 result.setRange(0, length, this, start); 2002 result.setRange(0, length, this, start);
1953 return result; 2003 return result;
1954 } 2004 }
1955 2005
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 } 2057 }
2008 2058
2009 void operator[]=(int index, int value) { 2059 void operator[]=(int index, int value) {
2010 if (index < 0 || index >= _length) { 2060 if (index < 0 || index >= _length) {
2011 String message = "$index must be in the range [0..$_length)"; 2061 String message = "$index must be in the range [0..$_length)";
2012 throw new RangeError(message); 2062 throw new RangeError(message);
2013 } 2063 }
2014 _array.setUint8(_offset + (index * _BYTES_PER_ELEMENT), _toUint8(value)); 2064 _array.setUint8(_offset + (index * _BYTES_PER_ELEMENT), _toUint8(value));
2015 } 2065 }
2016 2066
2017 Iterator<int> iterator() { 2067 Iterator<int> get iterator {
2018 return new _ByteArrayIterator<int>(this); 2068 return new _ByteArrayIterator<int>(this);
2019 } 2069 }
2020 2070
2021 List<int> getRange(int start, int length) { 2071 List<int> getRange(int start, int length) {
2022 _rangeCheck(this.length, start, length); 2072 _rangeCheck(this.length, start, length);
2023 List<int> result = new Uint8List(length); 2073 List<int> result = new Uint8List(length);
2024 result.setRange(0, length, this, start); 2074 result.setRange(0, length, this, start);
2025 return result; 2075 return result;
2026 } 2076 }
2027 2077
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 } 2129 }
2080 2130
2081 void operator[]=(int index, int value) { 2131 void operator[]=(int index, int value) {
2082 if (index < 0 || index >= _length) { 2132 if (index < 0 || index >= _length) {
2083 String message = "$index must be in the range [0..$_length)"; 2133 String message = "$index must be in the range [0..$_length)";
2084 throw new RangeError(message); 2134 throw new RangeError(message);
2085 } 2135 }
2086 _array.setInt16(_offset + (index * _BYTES_PER_ELEMENT), _toInt16(value)); 2136 _array.setInt16(_offset + (index * _BYTES_PER_ELEMENT), _toInt16(value));
2087 } 2137 }
2088 2138
2089 Iterator<int> iterator() { 2139 Iterator<int> get iterator {
2090 return new _ByteArrayIterator<int>(this); 2140 return new _ByteArrayIterator<int>(this);
2091 } 2141 }
2092 2142
2093 List<int> getRange(int start, int length) { 2143 List<int> getRange(int start, int length) {
2094 _rangeCheck(this.length, start, length); 2144 _rangeCheck(this.length, start, length);
2095 List<int> result = new Int16List(length); 2145 List<int> result = new Int16List(length);
2096 result.setRange(0, length, this, start); 2146 result.setRange(0, length, this, start);
2097 return result; 2147 return result;
2098 } 2148 }
2099 2149
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 } 2201 }
2152 2202
2153 void operator[]=(int index, int value) { 2203 void operator[]=(int index, int value) {
2154 if (index < 0 || index >= _length) { 2204 if (index < 0 || index >= _length) {
2155 String message = "$index must be in the range [0..$_length)"; 2205 String message = "$index must be in the range [0..$_length)";
2156 throw new RangeError(message); 2206 throw new RangeError(message);
2157 } 2207 }
2158 _array.setUint16(_offset + (index * _BYTES_PER_ELEMENT), _toUint16(value)); 2208 _array.setUint16(_offset + (index * _BYTES_PER_ELEMENT), _toUint16(value));
2159 } 2209 }
2160 2210
2161 Iterator<int> iterator() { 2211 Iterator<int> get iterator {
2162 return new _ByteArrayIterator<int>(this); 2212 return new _ByteArrayIterator<int>(this);
2163 } 2213 }
2164 2214
2165 List<int> getRange(int start, int length) { 2215 List<int> getRange(int start, int length) {
2166 _rangeCheck(this.length, start, length); 2216 _rangeCheck(this.length, start, length);
2167 List<int> result = new Uint16List(length); 2217 List<int> result = new Uint16List(length);
2168 result.setRange(0, length, this, start); 2218 result.setRange(0, length, this, start);
2169 return result; 2219 return result;
2170 } 2220 }
2171 2221
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 } 2273 }
2224 2274
2225 void operator[]=(int index, int value) { 2275 void operator[]=(int index, int value) {
2226 if (index < 0 || index >= _length) { 2276 if (index < 0 || index >= _length) {
2227 String message = "$index must be in the range [0..$_length)"; 2277 String message = "$index must be in the range [0..$_length)";
2228 throw new RangeError(message); 2278 throw new RangeError(message);
2229 } 2279 }
2230 _array.setInt32(_offset + (index * _BYTES_PER_ELEMENT), _toInt32(value)); 2280 _array.setInt32(_offset + (index * _BYTES_PER_ELEMENT), _toInt32(value));
2231 } 2281 }
2232 2282
2233 Iterator<int> iterator() { 2283 Iterator<int> get iterator {
2234 return new _ByteArrayIterator<int>(this); 2284 return new _ByteArrayIterator<int>(this);
2235 } 2285 }
2236 2286
2237 List<int> getRange(int start, int length) { 2287 List<int> getRange(int start, int length) {
2238 _rangeCheck(this.length, start, length); 2288 _rangeCheck(this.length, start, length);
2239 List<int> result = new Int32List(length); 2289 List<int> result = new Int32List(length);
2240 result.setRange(0, length, this, start); 2290 result.setRange(0, length, this, start);
2241 return result; 2291 return result;
2242 } 2292 }
2243 2293
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 } 2345 }
2296 2346
2297 void operator[]=(int index, int value) { 2347 void operator[]=(int index, int value) {
2298 if (index < 0 || index >= _length) { 2348 if (index < 0 || index >= _length) {
2299 String message = "$index must be in the range [0..$_length)"; 2349 String message = "$index must be in the range [0..$_length)";
2300 throw new RangeError(message); 2350 throw new RangeError(message);
2301 } 2351 }
2302 _array.setUint32(_offset + (index * _BYTES_PER_ELEMENT), _toUint32(value)); 2352 _array.setUint32(_offset + (index * _BYTES_PER_ELEMENT), _toUint32(value));
2303 } 2353 }
2304 2354
2305 Iterator<int> iterator() { 2355 Iterator<int> get iterator {
2306 return new _ByteArrayIterator<int>(this); 2356 return new _ByteArrayIterator<int>(this);
2307 } 2357 }
2308 2358
2309 List<int> getRange(int start, int length) { 2359 List<int> getRange(int start, int length) {
2310 _rangeCheck(this.length, start, length); 2360 _rangeCheck(this.length, start, length);
2311 List<int> result = new Uint32List(length); 2361 List<int> result = new Uint32List(length);
2312 result.setRange(0, length, this, start); 2362 result.setRange(0, length, this, start);
2313 return result; 2363 return result;
2314 } 2364 }
2315 2365
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2367 } 2417 }
2368 2418
2369 void operator[]=(int index, int value) { 2419 void operator[]=(int index, int value) {
2370 if (index < 0 || index >= _length) { 2420 if (index < 0 || index >= _length) {
2371 String message = "$index must be in the range [0..$_length)"; 2421 String message = "$index must be in the range [0..$_length)";
2372 throw new RangeError(message); 2422 throw new RangeError(message);
2373 } 2423 }
2374 _array.setInt64(_offset + (index * _BYTES_PER_ELEMENT), _toInt64(value)); 2424 _array.setInt64(_offset + (index * _BYTES_PER_ELEMENT), _toInt64(value));
2375 } 2425 }
2376 2426
2377 Iterator<int> iterator() { 2427 Iterator<int> get iterator {
2378 return new _ByteArrayIterator<int>(this); 2428 return new _ByteArrayIterator<int>(this);
2379 } 2429 }
2380 2430
2381 List<int> getRange(int start, int length) { 2431 List<int> getRange(int start, int length) {
2382 _rangeCheck(this.length, start, length); 2432 _rangeCheck(this.length, start, length);
2383 List<int> result = new Int64List(length); 2433 List<int> result = new Int64List(length);
2384 result.setRange(0, length, this, start); 2434 result.setRange(0, length, this, start);
2385 return result; 2435 return result;
2386 } 2436 }
2387 2437
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2439 } 2489 }
2440 2490
2441 void operator[]=(int index, int value) { 2491 void operator[]=(int index, int value) {
2442 if (index < 0 || index >= _length) { 2492 if (index < 0 || index >= _length) {
2443 String message = "$index must be in the range [0..$_length)"; 2493 String message = "$index must be in the range [0..$_length)";
2444 throw new RangeError(message); 2494 throw new RangeError(message);
2445 } 2495 }
2446 _array.setUint64(_offset + (index * _BYTES_PER_ELEMENT), _toUint64(value)); 2496 _array.setUint64(_offset + (index * _BYTES_PER_ELEMENT), _toUint64(value));
2447 } 2497 }
2448 2498
2449 Iterator<int> iterator() { 2499 Iterator<int> get iterator {
2450 return new _ByteArrayIterator<int>(this); 2500 return new _ByteArrayIterator<int>(this);
2451 } 2501 }
2452 2502
2453 List<int> getRange(int start, int length) { 2503 List<int> getRange(int start, int length) {
2454 _rangeCheck(this.length, start, length); 2504 _rangeCheck(this.length, start, length);
2455 List<int> result = new Uint64List(length); 2505 List<int> result = new Uint64List(length);
2456 result.setRange(0, length, this, start); 2506 result.setRange(0, length, this, start);
2457 return result; 2507 return result;
2458 } 2508 }
2459 2509
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 } 2561 }
2512 2562
2513 void operator[]=(int index, double value) { 2563 void operator[]=(int index, double value) {
2514 if (index < 0 || index >= _length) { 2564 if (index < 0 || index >= _length) {
2515 String message = "$index must be in the range [0..$_length)"; 2565 String message = "$index must be in the range [0..$_length)";
2516 throw new RangeError(message); 2566 throw new RangeError(message);
2517 } 2567 }
2518 _array.setFloat32(_offset + (index * _BYTES_PER_ELEMENT), value); 2568 _array.setFloat32(_offset + (index * _BYTES_PER_ELEMENT), value);
2519 } 2569 }
2520 2570
2521 Iterator<double> iterator() { 2571 Iterator<double> get iterator {
2522 return new _ByteArrayIterator<double>(this); 2572 return new _ByteArrayIterator<double>(this);
2523 } 2573 }
2524 2574
2525 List<double> getRange(int start, int length) { 2575 List<double> getRange(int start, int length) {
2526 _rangeCheck(this.length, start, length); 2576 _rangeCheck(this.length, start, length);
2527 List<double> result = new Float32List(length); 2577 List<double> result = new Float32List(length);
2528 result.setRange(0, length, this, start); 2578 result.setRange(0, length, this, start);
2529 return result; 2579 return result;
2530 } 2580 }
2531 2581
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 } 2633 }
2584 2634
2585 void operator[]=(int index, double value) { 2635 void operator[]=(int index, double value) {
2586 if (index < 0 || index >= _length) { 2636 if (index < 0 || index >= _length) {
2587 String message = "$index must be in the range [0..$_length)"; 2637 String message = "$index must be in the range [0..$_length)";
2588 throw new RangeError(message); 2638 throw new RangeError(message);
2589 } 2639 }
2590 _array.setFloat64(_offset + (index * _BYTES_PER_ELEMENT), value); 2640 _array.setFloat64(_offset + (index * _BYTES_PER_ELEMENT), value);
2591 } 2641 }
2592 2642
2593 Iterator<double> iterator() { 2643 Iterator<double> get iterator {
2594 return new _ByteArrayIterator<double>(this); 2644 return new _ByteArrayIterator<double>(this);
2595 } 2645 }
2596 2646
2597 List<double> getRange(int start, int length) { 2647 List<double> getRange(int start, int length) {
2598 _rangeCheck(this.length, start, length); 2648 _rangeCheck(this.length, start, length);
2599 List<double> result = new Float64List(length); 2649 List<double> result = new Float64List(length);
2600 result.setRange(0, length, this, start); 2650 result.setRange(0, length, this, start);
2601 return result; 2651 return result;
2602 } 2652 }
2603 2653
(...skipping 19 matching lines...) Expand all
2623 } 2673 }
2624 _rangeCheck(this.length, start, length); 2674 _rangeCheck(this.length, start, length);
2625 return _array.subByteArray(_offset + start, length); 2675 return _array.subByteArray(_offset + start, length);
2626 } 2676 }
2627 2677
2628 static const int _BYTES_PER_ELEMENT = 8; 2678 static const int _BYTES_PER_ELEMENT = 8;
2629 final ByteArray _array; 2679 final ByteArray _array;
2630 final int _offset; 2680 final int _offset;
2631 final int _length; 2681 final int _length;
2632 } 2682 }
OLDNEW
« no previous file with comments | « runtime/lib/async_sources.gypi ('k') | runtime/lib/double.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698