Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // TODO(asiva): Remove this import of dart:scalarlist when we are ready to | |
| 6 // drop scalarlist and move this implementation as the default. | |
| 7 import "dart:scalarlist" as sl; | |
| 8 | |
| 9 // patch classes for Int8List ..... Float64List and ByteData implementations. | |
| 10 | |
| 11 patch class Int8List { | |
| 12 /* patch */ factory Int8List(int length) { | |
| 13 return new _Int8Array(length); | |
| 14 } | |
| 15 | |
| 16 /* patch */ factory Int8List.transferable(int length) { | |
| 17 return _newTransferable(length); | |
| 18 } | |
| 19 | |
| 20 /* patch */ factory Int8List.view(ByteBuffer buffer, | |
| 21 [int offsetInBytes = 0, int length]) { | |
| 22 return new _Int8ArrayView(buffer, offsetInBytes, length); | |
| 23 } | |
| 24 | |
| 25 static _ExternalInt8Array _newTransferable(int length) { | |
| 26 return new _ExternalInt8Array(length); | |
| 27 } | |
| 28 } | |
| 29 | |
| 30 | |
| 31 patch class Uint8List { | |
| 32 /* patch */ factory Uint8List(int length) { | |
| 33 return new _Uint8Array(length); | |
| 34 } | |
| 35 | |
| 36 /* patch */ factory Uint8List.transferable(int length) { | |
| 37 return _newTransferable(length); | |
| 38 } | |
| 39 | |
| 40 /* patch */ factory Uint8List.view(ByteBuffer buffer, | |
| 41 [int offsetInBytes = 0, int length]) { | |
| 42 return new _Uint8ArrayView(buffer, offsetInBytes, length); | |
| 43 } | |
| 44 | |
| 45 static _ExternalUint8Array _newTransferable(int length) { | |
| 46 return new _ExternalUint8Array(length); | |
| 47 } | |
| 48 } | |
| 49 | |
| 50 | |
| 51 patch class Uint8ClampedList { | |
| 52 /* patch */ factory Uint8ClampedList(int length) { | |
| 53 return new _Uint8ClampedArray(length); | |
| 54 } | |
| 55 | |
| 56 /* patch */ factory Uint8ClampedList.transferable(int length) { | |
| 57 return _newTransferable(length); | |
| 58 } | |
| 59 | |
| 60 /* patch */ factory Uint8ClampedList.view(ByteBuffer buffer, | |
| 61 [int offsetInBytes = 0, | |
| 62 int length]) { | |
| 63 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); | |
| 64 } | |
| 65 | |
| 66 static _ExternalUint8ClampedArray _newTransferable(int length) { | |
| 67 return new _ExternalUint8ClampedArray(length); | |
| 68 } | |
| 69 } | |
| 70 | |
| 71 | |
| 72 patch class Int16List { | |
| 73 /* patch */ factory Int16List(int length) { | |
| 74 return new _Int16Array(length); | |
| 75 } | |
| 76 | |
| 77 /* patch */ factory Int16List.transferable(int length) { | |
| 78 return _newTransferable(length); | |
| 79 } | |
| 80 | |
| 81 /* patch */ factory Int16List.view(ByteBuffer buffer, | |
| 82 [int offsetInBytes = 0, int length]) { | |
| 83 return new _Int16ArrayView(buffer, offsetInBytes, length); | |
| 84 } | |
| 85 | |
| 86 static _ExternalInt16Array _newTransferable(int length) { | |
| 87 return new _ExternalInt16Array(length); | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 | |
| 92 patch class Uint16List { | |
| 93 /* patch */ factory Uint16List(int length) { | |
| 94 return new _Uint16Array(length); | |
| 95 } | |
| 96 | |
| 97 /* patch */ factory Uint16List.transferable(int length) { | |
| 98 return _newTransferable(length); | |
| 99 } | |
| 100 | |
| 101 /* patch */ factory Uint16List.view(ByteBuffer buffer, | |
| 102 [int offsetInBytes = 0, int length]) { | |
| 103 return new _Uint16ArrayView(buffer, offsetInBytes, length); | |
| 104 } | |
| 105 | |
| 106 static _ExternalUint16Array _newTransferable(int length) { | |
| 107 return new _ExternalUint16Array(length); | |
| 108 } | |
| 109 } | |
| 110 | |
| 111 | |
| 112 patch class Int32List { | |
| 113 /* patch */ factory Int32List(int length) { | |
| 114 return new _Int32Array(length); | |
| 115 } | |
| 116 | |
| 117 /* patch */ factory Int32List.transferable(int length) { | |
| 118 return _newTransferable(length); | |
| 119 } | |
| 120 | |
| 121 /* patch */ factory Int32List.view(ByteBuffer buffer, | |
| 122 [int offsetInBytes = 0, int length]) { | |
| 123 return new _Int32ArrayView(buffer, offsetInBytes, length); | |
| 124 } | |
| 125 | |
| 126 static _ExternalInt32Array _newTransferable(int length) { | |
| 127 return new _ExternalInt32Array(length); | |
| 128 } | |
| 129 } | |
| 130 | |
| 131 | |
| 132 patch class Uint32List { | |
| 133 /* patch */ factory Uint32List(int length) { | |
| 134 return new _Uint32Array(length); | |
| 135 } | |
| 136 | |
| 137 /* patch */ factory Uint32List.transferable(int length) { | |
| 138 return _newTransferable(length); | |
| 139 } | |
| 140 | |
| 141 /* patch */ factory Uint32List.view(ByteBuffer buffer, | |
| 142 [int offsetInBytes = 0, int length]) { | |
| 143 return new _Uint32ArrayView(buffer, offsetInBytes, length); | |
| 144 } | |
| 145 | |
| 146 static _ExternalUint32Array _newTransferable(int length) { | |
| 147 return new _ExternalUint32Array(length); | |
| 148 } | |
| 149 } | |
| 150 | |
| 151 | |
| 152 patch class Int64List { | |
| 153 /* patch */ factory Int64List(int length) { | |
| 154 return new _Int64Array(length); | |
| 155 } | |
| 156 | |
| 157 /* patch */ factory Int64List.transferable(int length) { | |
| 158 return _newTransferable(length); | |
| 159 } | |
| 160 | |
| 161 /* patch */ factory Int64List.view(ByteBuffer buffer, | |
| 162 [int offsetInBytes = 0, int length]) { | |
| 163 return new _Int64ArrayView(buffer, offsetInBytes, length); | |
| 164 } | |
| 165 | |
| 166 static _ExternalInt64Array _newTransferable(int length) { | |
| 167 return new _ExternalInt64Array(length); | |
| 168 } | |
| 169 } | |
| 170 | |
| 171 | |
| 172 patch class Uint64List { | |
| 173 /* patch */ factory Uint64List(int length) { | |
| 174 return new _Uint64Array(length); | |
| 175 } | |
| 176 | |
| 177 /* patch */ factory Uint64List.transferable(int length) { | |
| 178 return _newTransferable(length); | |
| 179 } | |
| 180 | |
| 181 /* patch */ factory Uint64List.view(ByteBuffer buffer, | |
| 182 [int offsetInBytes = 0, int length]) { | |
| 183 return new _Uint64ArrayView(buffer, offsetInBytes, length); | |
| 184 } | |
| 185 | |
| 186 static _ExternalUint64Array _newTransferable(int length) { | |
| 187 return new _ExternalUint64Array(length); | |
| 188 } | |
| 189 } | |
| 190 | |
| 191 | |
| 192 patch class Float32List { | |
| 193 /* patch */ factory Float32List(int length) { | |
| 194 return new _Float32Array(length); | |
| 195 } | |
| 196 | |
| 197 /* patch */ factory Float32List.transferable(int length) { | |
| 198 return _newTransferable(length); | |
| 199 } | |
| 200 | |
| 201 /* patch */ factory Float32List.view(ByteBuffer buffer, | |
| 202 [int offsetInBytes = 0, int length]) { | |
| 203 return new _Float32ArrayView(buffer, offsetInBytes, length); | |
| 204 } | |
| 205 | |
| 206 static _ExternalFloat32Array _newTransferable(int length) { | |
| 207 return new _ExternalFloat32Array(length); | |
| 208 } | |
| 209 } | |
| 210 | |
| 211 | |
| 212 patch class Float64List { | |
| 213 /* patch */ factory Float64List(int length) { | |
| 214 return new _Float64Array(length); | |
| 215 } | |
| 216 | |
| 217 /* patch */ factory Float64List.transferable(int length) { | |
| 218 return _newTransferable(length); | |
| 219 } | |
| 220 | |
| 221 /* patch */ factory Float64List.view(ByteBuffer buffer, | |
| 222 [int offsetInBytes = 0, int length]) { | |
| 223 return new _Float64ArrayView(buffer, offsetInBytes, length); | |
| 224 } | |
| 225 | |
| 226 static _ExternalFloat64Array _newTransferable(int length) { | |
| 227 return new _ExternalFloat64Array(length); | |
| 228 } | |
| 229 } | |
| 230 | |
| 231 | |
| 232 patch class ByteData { | |
| 233 /* patch */ factory ByteData(int length) { | |
| 234 var list = new _Uint8Array(length); | |
| 235 return new _ByteDataView(list.buffer); | |
| 236 } | |
| 237 | |
| 238 /* patch */ factory ByteData.transferable(int length) { | |
| 239 var list = new _Uint8Array.transferable(length); | |
| 240 return new _ByteDataView(list.buffer); | |
| 241 } | |
| 242 | |
| 243 /* patch */ factory ByteData.view(ByteBuffer buffer, | |
| 244 [int offsetInBytes = 0, int length]) { | |
| 245 if (length == null) { | |
| 246 length = buffer.lengthInBytes; | |
| 247 } | |
| 248 return new _ByteDataView(buffer, offsetInBytes, length); | |
| 249 } | |
| 250 } | |
| 251 | |
| 252 | |
| 253 // Based class for _TypedList that provides common methods for implementing | |
| 254 // the collection and list interfaces. | |
| 255 | |
| 256 abstract class _TypedListBase { | |
| 257 // Method(s) implementing the Collection interface. | |
| 258 bool contains(element) => IterableMixinWorkaround.contains(this, element); | |
| 259 | |
| 260 void forEach(void f(element)) { | |
| 261 var len = this.length; | |
| 262 for (var i = 0; i < len; i++) { | |
| 263 f(this[i]); | |
| 264 } | |
| 265 } | |
| 266 | |
| 267 Iterable map(f(int element)) { | |
| 268 return IterableMixinWorkaround.mapList(this, f); | |
| 269 } | |
| 270 | |
| 271 String join([String separator]) { | |
| 272 return IterableMixinWorkaround.join(this, separator); | |
| 273 } | |
| 274 | |
| 275 dynamic reduce(dynamic initialValue, | |
| 276 dynamic combine(dynamic initialValue, element)) { | |
| 277 return IterableMixinWorkaround.reduce(this, initialValue, combine); | |
| 278 } | |
| 279 | |
| 280 Collection where(bool f(int element)) { | |
| 281 return IterableMixinWorkaround.where(this, f); | |
| 282 } | |
| 283 | |
| 284 Iterable expand(Iterable f(int element)) { | |
| 285 return IterableMixinWorkaround.expand(this, f); | |
| 286 } | |
| 287 | |
| 288 Iterable<int> take(int n) { | |
| 289 return IterableMixinWorkaround.takeList(this, n); | |
| 290 } | |
| 291 | |
| 292 Iterable<int> takeWhile(bool test(int value)) { | |
| 293 return IterableMixinWorkaround.takeWhile(this, test); | |
| 294 } | |
| 295 | |
| 296 Iterable<int> skip(int n) { | |
| 297 return IterableMixinWorkaround.skipList(this, n); | |
| 298 } | |
| 299 | |
| 300 Iterable<int> skipWhile(bool test(int value)) { | |
| 301 return IterableMixinWorkaround.skipWhile(this, test); | |
| 302 } | |
| 303 | |
| 304 bool every(bool f(element)) { | |
| 305 return IterableMixinWorkaround.every(this, f); | |
| 306 } | |
| 307 | |
| 308 bool any(bool f(element)) { | |
| 309 return IterableMixinWorkaround.any(this, f); | |
| 310 } | |
| 311 | |
| 312 int firstMatching(bool test(int value), {int orElse()}) { | |
| 313 return IterableMixinWorkaround.firstMatching(this, test, orElse); | |
| 314 } | |
| 315 | |
| 316 int lastMatching(bool test(int value), {int orElse()}) { | |
| 317 return IterableMixinWorkaround.lastMatchingInList(this, test, orElse); | |
| 318 } | |
| 319 | |
| 320 int singleMatching(bool test(int value)) { | |
| 321 return IterableMixinWorkaround.singleMatching(this, test); | |
| 322 } | |
| 323 | |
| 324 int elementAt(int index) { | |
| 325 return this[index]; | |
| 326 } | |
| 327 | |
| 328 bool get isEmpty { | |
| 329 return this.length == 0; | |
| 330 } | |
| 331 | |
| 332 // Method(s) implementing the List interface. | |
| 333 | |
| 334 set length(newLength) { | |
| 335 throw new UnsupportedError( | |
| 336 "Cannot resize a non-extendable array"); | |
| 337 } | |
| 338 | |
| 339 void add(value) { | |
| 340 throw new UnsupportedError( | |
| 341 "Cannot add to a non-extendable array"); | |
| 342 } | |
| 343 | |
| 344 void addLast(value) { | |
| 345 throw new UnsupportedError( | |
| 346 "Cannot add to a non-extendable array"); | |
| 347 } | |
| 348 | |
| 349 void addAll(Iterable value) { | |
| 350 throw new UnsupportedError( | |
| 351 "Cannot add to a non-extendable array"); | |
| 352 } | |
| 353 | |
| 354 void sort([int compare(var a, var b)]) { | |
| 355 return IterableMixinWorkaround.sortList(this, compare); | |
| 356 } | |
| 357 | |
| 358 int indexOf(element, [int start = 0]) { | |
| 359 return IterableMixinWorkaround.indexOfList(this, element, start); | |
| 360 } | |
| 361 | |
| 362 int lastIndexOf(element, [int start = null]) { | |
| 363 return IterableMixinWorkaround.lastIndexOfList(this, element, start); | |
| 364 } | |
| 365 | |
| 366 void clear() { | |
| 367 throw new UnsupportedError( | |
| 368 "Cannot remove from a non-extendable array"); | |
| 369 } | |
| 370 | |
| 371 int removeLast() { | |
| 372 throw new UnsupportedError( | |
| 373 "Cannot remove from a non-extendable array"); | |
| 374 } | |
| 375 | |
| 376 void remove(Object element) { | |
| 377 throw new UnsupportedError( | |
| 378 "Cannot remove from a non-extendable array"); | |
| 379 } | |
| 380 | |
| 381 void removeAll(Iterable elements) { | |
| 382 throw new UnsupportedError( | |
| 383 "Cannot remove from a non-extendable array"); | |
| 384 } | |
| 385 | |
| 386 void retainAll(Iterable elements) { | |
| 387 throw new UnsupportedError( | |
| 388 "Cannot remove from a non-extendable array"); | |
| 389 } | |
| 390 | |
| 391 void removeMatching(bool test(int element)) { | |
| 392 throw new UnsupportedError( | |
| 393 "Cannot remove from a non-extendable array"); | |
| 394 } | |
| 395 | |
| 396 void retainMatching(bool test(int element)) { | |
| 397 throw new UnsupportedError( | |
| 398 "Cannot remove from a non-extendable array"); | |
| 399 } | |
| 400 | |
| 401 int get first { | |
| 402 if (length > 0) return this[0]; | |
| 403 throw new StateError("No elements"); | |
| 404 } | |
| 405 | |
| 406 int get last { | |
| 407 if (length > 0) return this[length - 1]; | |
| 408 throw new StateError("No elements"); | |
| 409 } | |
| 410 | |
| 411 int get single { | |
| 412 if (length == 1) return this[0]; | |
| 413 if (length == 0) throw new StateError("No elements"); | |
| 414 throw new StateError("More than one element"); | |
| 415 } | |
| 416 | |
| 417 int min([int compare(int a, int b)]) => | |
| 418 IterableMixinWorkaround.min(this, compare); | |
| 419 | |
| 420 int max([int compare(int a, int b)]) => | |
| 421 IterableMixinWorkaround.max(this, compare); | |
| 422 | |
| 423 void removeRange(int start, int length) { | |
| 424 throw new UnsupportedError( | |
| 425 "Cannot remove from a non-extendable array"); | |
| 426 } | |
| 427 | |
| 428 void insertRange(int start, int length, [initialValue]) { | |
| 429 throw new UnsupportedError( | |
| 430 "Cannot add to a non-extendable array"); | |
| 431 } | |
| 432 | |
| 433 List<int> toList() { | |
| 434 return new List<int>.from(this); | |
| 435 } | |
| 436 | |
| 437 Set<int> toSet() { | |
| 438 return new Set<int>.from(this); | |
| 439 } | |
| 440 } | |
| 441 | |
| 442 | |
| 443 abstract class _TypedList extends _TypedListBase implements ByteBuffer { | |
| 444 // Default method implementing parts of the TypedData interface. | |
| 445 int get offsetInBytes { | |
| 446 return 0; | |
| 447 } | |
| 448 | |
| 449 int get lengthInBytes { | |
| 450 return _length() * elementSizeInBytes; | |
| 451 } | |
| 452 | |
| 453 ByteBuffer get buffer { | |
| 454 return this; | |
| 455 } | |
| 456 | |
| 457 | |
| 458 // Methods implementing the collection interface. | |
| 459 | |
| 460 int get length { | |
| 461 return _length(); | |
| 462 } | |
| 463 | |
| 464 | |
| 465 // Internal utility methods. | |
| 466 | |
| 467 int _length() { | |
| 468 return _array.length; | |
| 469 } | |
| 470 | |
| 471 sl.ByteArrayViewable _array; | |
| 472 } | |
| 473 | |
| 474 | |
| 475 class _Int8Array extends _TypedList implements Int8List { | |
| 476 // Factory constructors. | |
| 477 | |
| 478 _Int8Array(int length) { | |
| 479 _array = new sl.Int8List(length); | |
| 480 } | |
| 481 | |
| 482 factory _Int8Array.view(ByteBuffer buffer, | |
| 483 [int offsetInBytes = 0, int length]) { | |
| 484 if (length == null) { | |
| 485 length = buffer.lengthInBytes; | |
| 486 } | |
| 487 return new _Int8ArrayView(buffer, offsetInBytes, length); | |
| 488 } | |
| 489 | |
| 490 | |
| 491 // Method(s) implementing List interface. | |
| 492 | |
| 493 int operator[](int index) { | |
| 494 return _getIndexed(index); | |
| 495 } | |
| 496 | |
| 497 void operator[]=(int index, int value) { | |
| 498 _setIndexed(index, _toInt8(value)); | |
| 499 } | |
| 500 | |
| 501 Iterator<int> get iterator { | |
| 502 return new _TypedListIterator<int>(this); | |
| 503 } | |
| 504 | |
| 505 List<int> getRange(int start, int length) { | |
| 506 _rangeCheck(this.length, start, length); | |
| 507 List<int> result = _new(length); | |
| 508 result.setRange(0, length, this, start); | |
| 509 return result; | |
| 510 } | |
| 511 | |
| 512 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 513 /** | |
| 514 if (from is _Int8Array) { | |
| 515 _setRange(start * Int8List.BYTES_PER_ELEMENT, | |
| 516 length * Int8List.BYTES_PER_ELEMENT, | |
| 517 from, | |
| 518 startFrom * Int8List.BYTES_PER_ELEMENT); | |
| 519 } else { | |
| 520 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 521 from, startFrom); | |
| 522 } | |
| 523 */ | |
| 524 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 525 } | |
| 526 | |
| 527 | |
| 528 // Method(s) implementing Object interface. | |
| 529 | |
| 530 String toString() { | |
| 531 return Collections.collectionToString(this); | |
| 532 } | |
| 533 | |
| 534 | |
| 535 // Method(s) implementing TypedData interface. | |
| 536 | |
| 537 int get elementSizeInBytes { | |
| 538 return Int8List.BYTES_PER_ELEMENT; | |
| 539 } | |
| 540 | |
| 541 | |
| 542 // Internal utility methods. | |
| 543 | |
| 544 int _getIndexed(int index) { | |
| 545 return _array[index]; | |
| 546 } | |
| 547 void _setIndexed(int index, int value) { | |
| 548 _array[index] = value; | |
| 549 } | |
| 550 } | |
| 551 | |
| 552 | |
| 553 class _Uint8Array extends _TypedList implements Uint8List { | |
| 554 // Factory constructors. | |
| 555 | |
| 556 _Uint8Array(int length) { | |
| 557 _array = new sl.Uint8List(length); | |
| 558 } | |
| 559 | |
| 560 factory _Uint8Array.view(ByteBuffer buffer, | |
| 561 [int offsetInBytes = 0, int length]) { | |
| 562 if (length == null) { | |
| 563 length = buffer.lengthInBytes; | |
| 564 } | |
| 565 return new _Uint8ArrayView(buffer, offsetInBytes, length); | |
| 566 } | |
| 567 | |
| 568 // Methods implementing List interface. | |
| 569 int operator[](int index) { | |
| 570 return _getIndexed(index); | |
| 571 } | |
| 572 | |
| 573 void operator[]=(int index, int value) { | |
| 574 _setIndexed(index, _toUint8(value)); | |
| 575 } | |
| 576 | |
| 577 Iterator<int> get iterator { | |
| 578 return new _TypedListIterator<int>(this); | |
| 579 } | |
| 580 | |
| 581 List<int> getRange(int start, int length) { | |
| 582 _rangeCheck(this.length, start, length); | |
| 583 List<int> result = _new(length); | |
| 584 result.setRange(0, length, this, start); | |
| 585 return result; | |
| 586 } | |
| 587 | |
| 588 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 589 /** | |
| 590 if (from is _Uint8Array || from is _ExternalUint8Array || | |
| 591 from is _Uint8ClampedArray || from is _ExternalUint8ClampedArray) { | |
| 592 _setRange(start * Uint8List.BYTES_PER_ELEMENT, | |
| 593 length * Uint8List.BYTES_PER_ELEMENT, | |
| 594 from, | |
| 595 startFrom * Uint8List.BYTES_PER_ELEMENT); | |
| 596 } else { | |
| 597 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 598 from, startFrom); | |
| 599 } | |
| 600 */ | |
| 601 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 602 } | |
| 603 | |
| 604 // Methods implementing Object interface. | |
| 605 String toString() { | |
| 606 return Collections.collectionToString(this); | |
| 607 } | |
| 608 | |
| 609 // Methods implementing TypedData interface. | |
| 610 int get elementSizeInBytes { | |
| 611 return Uint8List.BYTES_PER_ELEMENT; | |
| 612 } | |
| 613 | |
| 614 // Internal utility methods. | |
| 615 | |
| 616 int _getIndexed(int index) { | |
| 617 return _array[index]; | |
| 618 } | |
| 619 void _setIndexed(int index, int value) { | |
| 620 _array[index] = value; | |
| 621 } | |
| 622 } | |
| 623 | |
| 624 | |
| 625 class _Uint8ClampedArray extends _TypedList implements Uint8ClampedList { | |
| 626 // Factory constructors. | |
| 627 | |
| 628 _Uint8ClampedArray(int length) { | |
| 629 _array = new sl.Uint8ClampedList(length); | |
| 630 } | |
| 631 | |
| 632 factory _Uint8ClampedArray.view(ByteBuffer buffer, | |
| 633 [int offsetInBytes = 0, int length]) { | |
| 634 if (length == null) { | |
| 635 length = buffer.lengthInBytes; | |
| 636 } | |
| 637 return new _Uint8ClampedArrayView(buffer, offsetInBytes, length); | |
| 638 } | |
| 639 | |
| 640 // Methods implementing List interface. | |
| 641 int operator[](int index) { | |
| 642 return _getIndexed(index); | |
| 643 } | |
| 644 | |
| 645 void operator[]=(int index, int value) { | |
| 646 _setIndexed(index, _toClampedUint8(value)); | |
| 647 } | |
| 648 | |
| 649 Iterator<int> get iterator { | |
| 650 return new _TypedListIterator<int>(this); | |
| 651 } | |
| 652 | |
| 653 List<int> getRange(int start, int length) { | |
| 654 _rangeCheck(this.length, start, length); | |
| 655 List<int> result = _new(length); | |
| 656 result.setRange(0, length, this, start); | |
| 657 return result; | |
| 658 } | |
| 659 | |
| 660 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 661 /** | |
| 662 if (from is _Uint8Array || from is _ExternalUint8Array || | |
| 663 from is _Uint8ClampedArray || from is _ExternalUint8ClampedArray) { | |
| 664 _setRange(start * Uint8List.BYTES_PER_ELEMENT, | |
| 665 length * Uint8List.BYTES_PER_ELEMENT, | |
| 666 from, | |
| 667 startFrom * Uint8List.BYTES_PER_ELEMENT); | |
| 668 } else { | |
| 669 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 670 from, startFrom); | |
| 671 } | |
| 672 */ | |
| 673 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 674 } | |
| 675 | |
| 676 // Methods implementing Object interface. | |
| 677 String toString() { | |
| 678 return Collections.collectionToString(this); | |
| 679 } | |
| 680 | |
| 681 // Methods implementing TypedData interface. | |
| 682 int get elementSizeInBytes { | |
| 683 return Uint8List.BYTES_PER_ELEMENT; | |
| 684 } | |
| 685 | |
| 686 // Internal utility methods. | |
| 687 | |
| 688 int _getIndexed(int index) { | |
| 689 return _array[index]; | |
| 690 } | |
| 691 void _setIndexed(int index, int value) { | |
| 692 _array[index] = value; | |
| 693 } | |
| 694 } | |
| 695 | |
| 696 | |
| 697 class _Int16Array extends _TypedList implements Int16List { | |
| 698 // Factory constructors. | |
| 699 | |
| 700 _Int16Array(int length) { | |
| 701 _array = new sl.Int16List(length); | |
| 702 } | |
| 703 | |
| 704 factory _Int16Array.view(ByteBuffer buffer, | |
| 705 [int offsetInBytes = 0, int length]) { | |
| 706 if (length == null) { | |
| 707 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 708 Int16List.BYTES_PER_ELEMENT; | |
| 709 } | |
| 710 return new _Int16ArrayView(buffer, offsetInBytes, length); | |
| 711 } | |
| 712 | |
| 713 | |
| 714 // Method(s) implementing List interface. | |
| 715 | |
| 716 int operator[](int index) { | |
| 717 return _getIndexed(index); | |
| 718 } | |
| 719 | |
| 720 void operator[]=(int index, int value) { | |
| 721 _setIndexed(index, _toInt16(value)); | |
| 722 } | |
| 723 | |
| 724 Iterator<int> get iterator { | |
| 725 return new _TypedListIterator<int>(this); | |
| 726 } | |
| 727 | |
| 728 List<int> getRange(int start, int length) { | |
| 729 _rangeCheck(this.length, start, length); | |
| 730 List<int> result = _new(length); | |
| 731 result.setRange(0, length, this, start); | |
| 732 return result; | |
| 733 } | |
| 734 | |
| 735 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 736 /** | |
| 737 if (from is _Int16Array) { | |
| 738 _setRange(start * Int16List.BYTES_PER_ELEMENT, | |
| 739 length * Int16List.BYTES_PER_ELEMENT, | |
| 740 from, | |
| 741 startFrom * Int16List.BYTES_PER_ELEMENT); | |
| 742 } else { | |
| 743 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 744 from, startFrom); | |
| 745 } | |
| 746 */ | |
| 747 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 748 } | |
| 749 | |
| 750 | |
| 751 // Method(s) implementing Object interface. | |
| 752 | |
| 753 String toString() { | |
| 754 return Collections.collectionToString(this); | |
| 755 } | |
| 756 | |
| 757 | |
| 758 // Method(s) implementing TypedData interface. | |
| 759 | |
| 760 int get elementSizeInBytes { | |
| 761 return Int16List.BYTES_PER_ELEMENT; | |
| 762 } | |
| 763 | |
| 764 | |
| 765 // Internal utility methods. | |
| 766 | |
| 767 int _getIndexed(int index) { | |
| 768 return _array[index]; | |
| 769 } | |
| 770 void _setIndexed(int index, int value) { | |
| 771 _array[index] = value; | |
| 772 } | |
| 773 } | |
| 774 | |
| 775 | |
| 776 class _Uint16Array extends _TypedList implements Uint16List { | |
| 777 // Factory constructors. | |
| 778 | |
| 779 _Uint16Array(int length) { | |
| 780 _array = new sl.Uint16List(length); | |
| 781 } | |
| 782 | |
| 783 factory _Uint16Array.view(ByteBuffer buffer, | |
| 784 [int offsetInBytes = 0, int length]) { | |
| 785 if (length == null) { | |
| 786 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 787 Uint16List.BYTES_PER_ELEMENT; | |
| 788 } | |
| 789 return new _Uint16ArrayView(buffer, offsetInBytes, length); | |
| 790 } | |
| 791 | |
| 792 | |
| 793 // Method(s) implementing the List interface. | |
| 794 | |
| 795 int operator[](int index) { | |
| 796 return _getIndexed(index); | |
| 797 } | |
| 798 | |
| 799 void operator[]=(int index, int value) { | |
| 800 _setIndexed(index, _toUint16(value)); | |
| 801 } | |
| 802 | |
| 803 Iterator<int> get iterator { | |
| 804 return new _TypedListIterator<int>(this); | |
| 805 } | |
| 806 | |
| 807 List<int> getRange(int start, int length) { | |
| 808 _rangeCheck(this.length, start, length); | |
| 809 List<int> result = _new(length); | |
| 810 result.setRange(0, length, this, start); | |
| 811 return result; | |
| 812 } | |
| 813 | |
| 814 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 815 /** | |
| 816 if (from is _Uint16Array) { | |
| 817 _setRange(start * Uint16List.BYTES_PER_ELEMENT, | |
| 818 length * Uint16List.BYTES_PER_ELEMENT, | |
| 819 from, | |
| 820 startFrom * Uint16List.BYTES_PER_ELEMENT); | |
| 821 } else { | |
| 822 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 823 from, startFrom); | |
| 824 } | |
| 825 */ | |
| 826 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 827 } | |
| 828 | |
| 829 | |
| 830 // Method(s) implementing the Object interface. | |
| 831 | |
| 832 String toString() { | |
| 833 return Collections.collectionToString(this); | |
| 834 } | |
| 835 | |
| 836 | |
| 837 // Method(s) implementing the TypedData interface. | |
| 838 | |
| 839 int get elementSizeInBytes { | |
| 840 return Uint16List.BYTES_PER_ELEMENT; | |
| 841 } | |
| 842 | |
| 843 | |
| 844 // Internal utility methods. | |
| 845 | |
| 846 int _getIndexed(int index) { | |
| 847 return _array[index]; | |
| 848 } | |
| 849 void _setIndexed(int index, int value) { | |
| 850 _array[index] = value; | |
| 851 } | |
| 852 } | |
| 853 | |
| 854 | |
| 855 class _Int32Array extends _TypedList implements Int32List { | |
| 856 // Factory constructors. | |
| 857 | |
| 858 _Int32Array(int length) { | |
| 859 _array = new sl.Int32List(length); | |
| 860 } | |
| 861 | |
| 862 factory _Int32Array.view(ByteBuffer buffer, | |
| 863 [int offsetInBytes = 0, int length]) { | |
| 864 if (length == null) { | |
| 865 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 866 Int32List.BYTES_PER_ELEMENT; | |
| 867 } | |
| 868 return new _Int32ArrayView(buffer, offsetInBytes, length); | |
| 869 } | |
| 870 | |
| 871 | |
| 872 // Method(s) implementing the List interface. | |
| 873 | |
| 874 int operator[](int index) { | |
| 875 return _getIndexed(index); | |
| 876 } | |
| 877 | |
| 878 void operator[]=(int index, int value) { | |
| 879 _setIndexed(index, _toInt32(value)); | |
| 880 } | |
| 881 | |
| 882 Iterator<int> get iterator { | |
| 883 return new _TypedListIterator<int>(this); | |
| 884 } | |
| 885 | |
| 886 List<int> getRange(int start, int length) { | |
| 887 _rangeCheck(this.length, start, length); | |
| 888 List<int> result = _new(length); | |
| 889 result.setRange(0, length, this, start); | |
| 890 return result; | |
| 891 } | |
| 892 | |
| 893 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 894 /** | |
| 895 if (from is _Int32Array) { | |
| 896 _setRange(start * Int32List.BYTES_PER_ELEMENT, | |
| 897 length * Int32List.BYTES_PER_ELEMENT, | |
| 898 from, | |
| 899 startFrom * Int32List.BYTES_PER_ELEMENT); | |
| 900 } else { | |
| 901 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 902 from, startFrom); | |
| 903 } | |
| 904 */ | |
| 905 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 906 } | |
| 907 | |
| 908 | |
| 909 // Method(s) implementing Object interface. | |
| 910 | |
| 911 String toString() { | |
| 912 return Collections.collectionToString(this); | |
| 913 } | |
| 914 | |
| 915 | |
| 916 // Method(s) implementing TypedData interface. | |
| 917 | |
| 918 int get elementSizeInBytes { | |
| 919 return Int32List.BYTES_PER_ELEMENT; | |
| 920 } | |
| 921 | |
| 922 | |
| 923 // Internal utility methods. | |
| 924 | |
| 925 int _getIndexed(int index) { | |
| 926 return _array[index]; | |
| 927 } | |
| 928 void _setIndexed(int index, int value) { | |
| 929 _array[index] = value; | |
| 930 } | |
| 931 } | |
| 932 | |
| 933 | |
| 934 class _Uint32Array extends _TypedList implements Uint32List { | |
| 935 // Factory constructors. | |
| 936 | |
| 937 _Uint32Array(int length) { | |
| 938 _array = new sl.Uint32List(length); | |
| 939 } | |
| 940 | |
| 941 factory _Uint32Array.view(ByteBuffer buffer, | |
| 942 [int offsetInBytes = 0, int length]) { | |
| 943 if (length == null) { | |
| 944 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 945 Uint32List.BYTES_PER_ELEMENT; | |
| 946 } | |
| 947 return new _Uint32ArrayView(buffer, offsetInBytes, length); | |
| 948 } | |
| 949 | |
| 950 | |
| 951 // Method(s) implementing the List interface. | |
| 952 | |
| 953 int operator[](int index) { | |
| 954 return _getIndexed(index); | |
| 955 } | |
| 956 | |
| 957 void operator[]=(int index, int value) { | |
| 958 _setIndexed(index, _toUint32(value)); | |
| 959 } | |
| 960 | |
| 961 Iterator<int> get iterator { | |
| 962 return new _TypedListIterator<int>(this); | |
| 963 } | |
| 964 | |
| 965 List<int> getRange(int start, int length) { | |
| 966 _rangeCheck(this.length, start, length); | |
| 967 List<int> result = _new(length); | |
| 968 result.setRange(0, length, this, start); | |
| 969 return result; | |
| 970 } | |
| 971 | |
| 972 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 973 /** | |
| 974 if (from is _Uint32Array) { | |
| 975 _setRange(start * Uint32List.BYTES_PER_ELEMENT, | |
| 976 length * Uint32List.BYTES_PER_ELEMENT, | |
| 977 from, | |
| 978 startFrom * Uint32List.BYTES_PER_ELEMENT); | |
| 979 } else { | |
| 980 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 981 from, startFrom); | |
| 982 } | |
| 983 */ | |
| 984 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 985 } | |
| 986 | |
| 987 | |
| 988 // Method(s) implementing the Object interface. | |
| 989 | |
| 990 String toString() { | |
| 991 return Collections.collectionToString(this); | |
| 992 } | |
| 993 | |
| 994 | |
| 995 // Method(s) implementing the TypedData interface. | |
| 996 | |
| 997 int get elementSizeInBytes { | |
| 998 return Uint32List.BYTES_PER_ELEMENT; | |
| 999 } | |
| 1000 | |
| 1001 | |
| 1002 // Internal utility methods. | |
| 1003 | |
| 1004 int _getIndexed(int index) { | |
| 1005 return _array[index]; | |
| 1006 } | |
| 1007 void _setIndexed(int index, int value) { | |
| 1008 _array[index] = value; | |
| 1009 } | |
| 1010 } | |
| 1011 | |
| 1012 | |
| 1013 class _Int64Array extends _TypedList implements Int64List { | |
| 1014 // Factory constructors. | |
| 1015 | |
| 1016 _Int64Array(int length) { | |
| 1017 _array = new sl.Int64List(length); | |
| 1018 } | |
| 1019 | |
| 1020 factory _Int64Array.view(ByteBuffer buffer, | |
| 1021 [int offsetInBytes = 0, int length]) { | |
| 1022 if (length == null) { | |
| 1023 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1024 Int32List.BYTES_PER_ELEMENT; | |
| 1025 } | |
| 1026 return new _Int64ArrayView(buffer, offsetInBytes, length); | |
| 1027 } | |
| 1028 | |
| 1029 | |
| 1030 // Method(s) implementing the List interface. | |
| 1031 | |
| 1032 int operator[](int index) { | |
| 1033 return _getIndexed(index); | |
| 1034 } | |
| 1035 | |
| 1036 void operator[]=(int index, int value) { | |
| 1037 _setIndexed(index, _toInt64(value)); | |
| 1038 } | |
| 1039 | |
| 1040 Iterator<int> get iterator { | |
| 1041 return new _TypedListIterator<int>(this); | |
| 1042 } | |
| 1043 | |
| 1044 List<int> getRange(int start, int length) { | |
| 1045 _rangeCheck(this.length, start, length); | |
| 1046 List<int> result = _new(length); | |
| 1047 result.setRange(0, length, this, start); | |
| 1048 return result; | |
| 1049 } | |
| 1050 | |
| 1051 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1052 /** | |
| 1053 if (from is _Int64Array) { | |
| 1054 _setRange(start * Int64List.BYTES_PER_ELEMENT, | |
| 1055 length * Int64List.BYTES_PER_ELEMENT, | |
| 1056 from, | |
| 1057 startFrom * Int64List.BYTES_PER_ELEMENT); | |
| 1058 } else { | |
| 1059 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1060 from, startFrom); | |
| 1061 } | |
| 1062 */ | |
| 1063 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1064 } | |
| 1065 | |
| 1066 | |
| 1067 // Method(s) implementing the Object interface. | |
| 1068 | |
| 1069 String toString() { | |
| 1070 return Collections.collectionToString(this); | |
| 1071 } | |
| 1072 | |
| 1073 | |
| 1074 // Method(s) implementing the TypedData interface. | |
| 1075 | |
| 1076 int get elementSizeInBytes { | |
| 1077 return Int64List.BYTES_PER_ELEMENT; | |
| 1078 } | |
| 1079 | |
| 1080 | |
| 1081 // Internal utility methods. | |
| 1082 | |
| 1083 int _getIndexed(int index) { | |
| 1084 return _array[index]; | |
| 1085 } | |
| 1086 void _setIndexed(int index, int value) { | |
| 1087 _array[index] = value; | |
| 1088 } | |
| 1089 } | |
| 1090 | |
| 1091 | |
| 1092 class _Uint64Array extends _TypedList implements Uint64List { | |
| 1093 // Factory constructors. | |
| 1094 | |
| 1095 _Uint64Array(int length) { | |
| 1096 _array = new sl.Uint64List(length); | |
| 1097 } | |
| 1098 | |
| 1099 factory _Uint64Array.view(ByteBuffer buffer, | |
| 1100 [int offsetInBytes = 0, int length]) { | |
| 1101 if (length == null) { | |
| 1102 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1103 Uint64List.BYTES_PER_ELEMENT; | |
| 1104 } | |
| 1105 return new _Uint64ArrayView(buffer, offsetInBytes, length); | |
| 1106 } | |
| 1107 | |
| 1108 | |
| 1109 // Method(s) implementing the List interface. | |
| 1110 | |
| 1111 int operator[](int index) { | |
| 1112 return _getIndexed(index); | |
| 1113 } | |
| 1114 | |
| 1115 void operator[]=(int index, int value) { | |
| 1116 _setIndexed(index, _toUint64(value)); | |
| 1117 } | |
| 1118 | |
| 1119 Iterator<int> get iterator { | |
| 1120 return new _TypedListIterator<int>(this); | |
| 1121 } | |
| 1122 | |
| 1123 List<int> getRange(int start, int length) { | |
| 1124 _rangeCheck(this.length, start, length); | |
| 1125 List<int> result = _new(length); | |
| 1126 result.setRange(0, length, this, start); | |
| 1127 return result; | |
| 1128 } | |
| 1129 | |
| 1130 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1131 /** | |
| 1132 if (from is _Uint64Array) { | |
| 1133 _setRange(start * Uint64List.BYTES_PER_ELEMENT, | |
| 1134 length * Uint64List.BYTES_PER_ELEMENT, | |
| 1135 from, | |
| 1136 startFrom * Uint64List.BYTES_PER_ELEMENT); | |
| 1137 } else { | |
| 1138 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1139 from, startFrom); | |
| 1140 } | |
| 1141 */ | |
| 1142 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1143 } | |
| 1144 | |
| 1145 | |
| 1146 // Method(s) implementing the Object interface. | |
| 1147 | |
| 1148 String toString() { | |
| 1149 return Collections.collectionToString(this); | |
| 1150 } | |
| 1151 | |
| 1152 | |
| 1153 // Method(s) implementing the TypedData interface. | |
| 1154 | |
| 1155 int get elementSizeInBytes { | |
| 1156 return Uint64List.BYTES_PER_ELEMENT; | |
| 1157 } | |
| 1158 | |
| 1159 | |
| 1160 // Internal utility methods. | |
| 1161 | |
| 1162 int _getIndexed(int index) { | |
| 1163 return _array[index]; | |
| 1164 } | |
| 1165 void _setIndexed(int index, int value) { | |
| 1166 _array[index] = value; | |
| 1167 } | |
| 1168 } | |
| 1169 | |
| 1170 | |
| 1171 class _Float32Array extends _TypedList implements Float32List { | |
| 1172 // Factory constructors. | |
| 1173 | |
| 1174 _Float32Array(int length) { | |
| 1175 _array = new sl.Float32List(length); | |
| 1176 } | |
| 1177 | |
| 1178 factory _Float32Array.view(ByteBuffer buffer, | |
| 1179 [int offsetInBytes = 0, int length]) { | |
| 1180 if (length == null) { | |
| 1181 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1182 Float32List.BYTES_PER_ELEMENT; | |
| 1183 } | |
| 1184 return new _Float32ArrayView(buffer, offsetInBytes, length); | |
| 1185 } | |
| 1186 | |
| 1187 | |
| 1188 // Method(s) implementing the List interface. | |
| 1189 | |
| 1190 double operator[](int index) { | |
| 1191 return _getIndexed(index); | |
| 1192 } | |
| 1193 | |
| 1194 void operator[]=(int index, double value) { | |
| 1195 _setIndexed(index, value); | |
| 1196 } | |
| 1197 | |
| 1198 Iterator<double> get iterator { | |
| 1199 return new _TypedListIterator<double>(this); | |
| 1200 } | |
| 1201 | |
| 1202 List<double> getRange(int start, int length) { | |
| 1203 _rangeCheck(this.length, start, length); | |
| 1204 List<double> result = _new(length); | |
| 1205 result.setRange(0, length, this, start); | |
| 1206 return result; | |
| 1207 } | |
| 1208 | |
| 1209 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { | |
| 1210 /** | |
| 1211 if (from is _Float32Array) { | |
| 1212 _setRange(start * Float32List.BYTES_PER_ELEMENT, | |
| 1213 length * Float32List.BYTES_PER_ELEMENT, | |
| 1214 from, | |
| 1215 startFrom * Float32List.BYTES_PER_ELEMENT); | |
| 1216 } else { | |
| 1217 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1218 from, startFrom); | |
| 1219 } | |
| 1220 */ | |
| 1221 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1222 } | |
| 1223 | |
| 1224 | |
| 1225 // Method(s) implementing the Object interface. | |
| 1226 | |
| 1227 String toString() { | |
| 1228 return Collections.collectionToString(this); | |
| 1229 } | |
| 1230 | |
| 1231 | |
| 1232 // Method(s) implementing the TypedData interface. | |
| 1233 | |
| 1234 int get elementSizeInBytes { | |
| 1235 return Float32List.BYTES_PER_ELEMENT; | |
| 1236 } | |
| 1237 | |
| 1238 | |
| 1239 // Internal utility methods. | |
| 1240 | |
| 1241 double _getIndexed(int index) { | |
| 1242 return _array[index]; | |
| 1243 } | |
| 1244 void _setIndexed(int index, double value) { | |
| 1245 _array[index] = value; | |
| 1246 } | |
| 1247 } | |
| 1248 | |
| 1249 | |
| 1250 class _Float64Array extends _TypedList implements Float64List { | |
| 1251 // Factory constructors. | |
| 1252 | |
| 1253 _Float64Array(int length) { | |
| 1254 _array = new sl.Float64List(length); | |
| 1255 } | |
| 1256 | |
| 1257 factory _Float64Array.view(ByteBuffer buffer, | |
| 1258 [int offsetInBytes = 0, int length]) { | |
| 1259 if (length == null) { | |
| 1260 length = (buffer.lengthInBytes - offsetInBytes) ~/ | |
| 1261 Float64List.BYTES_PER_ELEMENT; | |
| 1262 } | |
| 1263 return new _Float64ArrayView(buffer, offsetInBytes, length); | |
| 1264 } | |
| 1265 | |
| 1266 | |
| 1267 // Method(s) implementing the List interface. | |
| 1268 | |
| 1269 double operator[](int index) { | |
| 1270 return _getIndexed(index); | |
| 1271 } | |
| 1272 | |
| 1273 void operator[]=(int index, double value) { | |
| 1274 _setIndexed(index, value); | |
| 1275 } | |
| 1276 | |
| 1277 Iterator<double> get iterator { | |
| 1278 return new _TypedListIterator<double>(this); | |
| 1279 } | |
| 1280 | |
| 1281 List<double> getRange(int start, int length) { | |
| 1282 _rangeCheck(this.length, start, length); | |
| 1283 List<double> result = _new(length); | |
| 1284 result.setRange(0, length, this, start); | |
| 1285 return result; | |
| 1286 } | |
| 1287 | |
| 1288 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { | |
| 1289 /** | |
| 1290 if (from is _Float64Array) { | |
| 1291 _setRange(start * Float64List.BYTES_PER_ELEMENT, | |
| 1292 length * Float64List.BYTES_PER_ELEMENT, | |
| 1293 from, | |
| 1294 startFrom * Float64List.BYTES_PER_ELEMENT); | |
| 1295 } else { | |
| 1296 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1297 from, startFrom); | |
| 1298 } | |
| 1299 */ | |
| 1300 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1301 } | |
| 1302 | |
| 1303 | |
| 1304 // Method(s) implementing the Object interface. | |
| 1305 | |
| 1306 String toString() { | |
| 1307 return Collections.collectionToString(this); | |
| 1308 } | |
| 1309 | |
| 1310 | |
| 1311 // Method(s) implementing the TypedData interface. | |
| 1312 | |
| 1313 int get elementSizeInBytes { | |
| 1314 return Float64List.BYTES_PER_ELEMENT; | |
| 1315 } | |
| 1316 | |
| 1317 | |
| 1318 // Internal utility methods. | |
| 1319 | |
| 1320 double _getIndexed(int index) { | |
| 1321 return _array[index]; | |
| 1322 } | |
| 1323 void _setIndexed(int index, double value) { | |
| 1324 _array[index] = value; | |
| 1325 } | |
| 1326 } | |
| 1327 | |
| 1328 | |
| 1329 class _ExternalInt8Array extends _TypedList implements Int8List { | |
| 1330 // Factory constructors. | |
| 1331 | |
| 1332 _ExternalInt8Array(int length) { | |
| 1333 _array = new sl.Int8List.transferable(length); | |
| 1334 } | |
| 1335 | |
| 1336 | |
| 1337 // Method(s) implementing the List interface. | |
| 1338 int operator[](int index) { | |
| 1339 return _getIndexed(index); | |
| 1340 } | |
| 1341 | |
| 1342 void operator[]=(int index, int value) { | |
| 1343 _setIndexed(index, _toInt8(value)); | |
| 1344 } | |
| 1345 | |
| 1346 Iterator<int> get iterator { | |
| 1347 return new _TypedListIterator<int>(this); | |
| 1348 } | |
| 1349 | |
| 1350 List<int> getRange(int start, int length) { | |
| 1351 _rangeCheck(this.length, start, length); | |
| 1352 List<int> result = new Int8List(length); | |
| 1353 result.setRange(0, length, this, start); | |
| 1354 return result; | |
| 1355 } | |
| 1356 | |
| 1357 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1358 /** | |
| 1359 if (from is _ExternalInt8Array) { | |
| 1360 _setRange(start * Int8List.BYTES_PER_ELEMENT, | |
| 1361 length * Int8List.BYTES_PER_ELEMENT, | |
| 1362 from, | |
| 1363 startFrom * Int8List.BYTES_PER_ELEMENT); | |
| 1364 } else { | |
| 1365 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1366 from, startFrom); | |
| 1367 } | |
| 1368 */ | |
| 1369 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1370 } | |
| 1371 | |
| 1372 | |
| 1373 // Method(s) implementing the Object interface. | |
| 1374 | |
| 1375 String toString() { | |
| 1376 return Collections.collectionToString(this); | |
| 1377 } | |
| 1378 | |
| 1379 | |
| 1380 // Method(s) implementing the TypedData interface. | |
| 1381 | |
| 1382 int get elementSizeInBytes { | |
| 1383 return Int8List.BYTES_PER_ELEMENT; | |
| 1384 } | |
| 1385 | |
| 1386 | |
| 1387 // Internal utility methods. | |
| 1388 | |
| 1389 int _getIndexed(int index) { | |
| 1390 return _array[index]; | |
| 1391 } | |
| 1392 void _setIndexed(int index, int value) { | |
| 1393 _array[index] = value; | |
| 1394 } | |
| 1395 } | |
| 1396 | |
| 1397 | |
| 1398 class _ExternalUint8Array extends _TypedList implements Uint8List { | |
| 1399 // Factory constructors. | |
| 1400 | |
| 1401 _ExternalUint8Array(int length) { | |
| 1402 _array = new sl.Uint8List.transferable(length); | |
| 1403 } | |
| 1404 | |
| 1405 | |
| 1406 // Method(s) implementing the List interface. | |
| 1407 | |
| 1408 int operator[](int index) { | |
| 1409 return _getIndexed(index); | |
| 1410 } | |
| 1411 | |
| 1412 void operator[]=(int index, int value) { | |
| 1413 _setIndexed(index, _toUint8(value)); | |
| 1414 } | |
| 1415 | |
| 1416 Iterator<int> get iterator { | |
| 1417 return new _TypedListIterator<int>(this); | |
| 1418 } | |
| 1419 | |
| 1420 List<int> getRange(int start, int length) { | |
| 1421 _rangeCheck(this.length, start, length); | |
| 1422 List<int> result = new Uint8List(length); | |
| 1423 result.setRange(0, length, this, start); | |
| 1424 return result; | |
| 1425 } | |
| 1426 | |
| 1427 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1428 /** | |
| 1429 if (from is _ExternalUint8Array || from is _Uint8Array) { | |
| 1430 _setRange(start * Uint8List.BYTES_PER_ELEMENT, | |
| 1431 length * Uint8List.BYTES_PER_ELEMENT, | |
| 1432 from, | |
| 1433 startFrom * Uint8List.BYTES_PER_ELEMENT); | |
| 1434 } else { | |
| 1435 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1436 from, startFrom); | |
| 1437 } | |
| 1438 */ | |
| 1439 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1440 } | |
| 1441 | |
| 1442 | |
| 1443 // Method(s) implementing the Object interface. | |
| 1444 | |
| 1445 String toString() { | |
| 1446 return Collections.collectionToString(this); | |
| 1447 } | |
| 1448 | |
| 1449 | |
| 1450 // Method(s) implementing the TypedData interface. | |
| 1451 | |
| 1452 int get elementSizeInBytes { | |
| 1453 return Uint8List.BYTES_PER_ELEMENT; | |
| 1454 } | |
| 1455 | |
| 1456 | |
| 1457 // Internal utility methods. | |
| 1458 | |
| 1459 int _getIndexed(int index) { | |
| 1460 return _array[index]; | |
| 1461 } | |
| 1462 void _setIndexed(int index, int value) { | |
| 1463 _array[index] = value; | |
| 1464 } | |
| 1465 } | |
| 1466 | |
| 1467 | |
| 1468 class _ExternalUint8ClampedArray extends _TypedList implements Uint8ClampedList { | |
| 1469 // Factory constructors. | |
| 1470 | |
| 1471 _ExternalUint8ClampedArray(int length) { | |
| 1472 _array = new sl.Uint8ClampedList.transferable(length); | |
| 1473 } | |
| 1474 | |
| 1475 | |
| 1476 // Method(s) implementing the List interface. | |
| 1477 | |
| 1478 int operator[](int index) { | |
| 1479 return _getIndexed(index); | |
| 1480 } | |
| 1481 | |
| 1482 void operator[]=(int index, int value) { | |
| 1483 _setIndexed(index, _toClampedUint8(value)); | |
| 1484 } | |
| 1485 | |
| 1486 Iterator<int> get iterator { | |
| 1487 return new _TypedListIterator<int>(this); | |
| 1488 } | |
| 1489 | |
| 1490 List<int> getRange(int start, int length) { | |
| 1491 _rangeCheck(this.length, start, length); | |
| 1492 List<int> result = new Uint8ClampedList(length); | |
| 1493 result.setRange(0, length, this, start); | |
| 1494 return result; | |
| 1495 } | |
| 1496 | |
| 1497 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1498 /** | |
| 1499 if (from is _ExternalUint8ClampedArray || from is _Uint8ClampedArray) { | |
| 1500 _setRange(start * Uint8List.BYTES_PER_ELEMENT, | |
| 1501 length * Uint8List.BYTES_PER_ELEMENT, | |
| 1502 from, | |
| 1503 startFrom * Uint8List.BYTES_PER_ELEMENT); | |
| 1504 } else { | |
| 1505 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1506 from, startFrom); | |
| 1507 } | |
| 1508 */ | |
| 1509 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1510 } | |
| 1511 | |
| 1512 | |
| 1513 // Method(s) implementing the Object interface. | |
| 1514 | |
| 1515 String toString() { | |
| 1516 return Collections.collectionToString(this); | |
| 1517 } | |
| 1518 | |
| 1519 | |
| 1520 // Method(s) implementing the TypedData interface. | |
| 1521 | |
| 1522 int get elementSizeInBytes { | |
| 1523 return Uint8List.BYTES_PER_ELEMENT; | |
| 1524 } | |
| 1525 | |
| 1526 | |
| 1527 // Internal utility methods. | |
| 1528 | |
| 1529 int _getIndexed(int index) { | |
| 1530 return _array[index]; | |
| 1531 } | |
| 1532 void _setIndexed(int index, int value) { | |
| 1533 _array[index] = value; | |
| 1534 } | |
| 1535 } | |
| 1536 | |
| 1537 | |
| 1538 class _ExternalInt16Array extends _TypedList implements Int16List { | |
| 1539 // Factory constructors. | |
| 1540 | |
| 1541 _ExternalInt16Array(int length) { | |
| 1542 _array = new sl.Int16List.transferable(length); | |
| 1543 } | |
| 1544 | |
| 1545 | |
| 1546 // Method(s) implementing the List interface. | |
| 1547 | |
| 1548 int operator[](int index) { | |
| 1549 return _getIndexed(index); | |
| 1550 } | |
| 1551 | |
| 1552 void operator[]=(int index, int value) { | |
| 1553 _setIndexed(index, _toInt16(value)); | |
| 1554 } | |
| 1555 | |
| 1556 Iterator<int> get iterator { | |
| 1557 return new _TypedListIterator<int>(this); | |
| 1558 } | |
| 1559 | |
| 1560 List<int> getRange(int start, int length) { | |
| 1561 _rangeCheck(this.length, start, length); | |
| 1562 List<int> result = new Int16List(length); | |
| 1563 result.setRange(0, length, this, start); | |
| 1564 return result; | |
| 1565 } | |
| 1566 | |
| 1567 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1568 /** | |
| 1569 if (from is _ExternalInt16Array) { | |
| 1570 _setRange(start * Int16List.BYTES_PER_ELEMENT, | |
| 1571 length * Int16List.BYTES_PER_ELEMENT, | |
| 1572 from, | |
| 1573 startFrom * Int16List.BYTES_PER_ELEMENT); | |
| 1574 } else { | |
| 1575 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1576 from, startFrom); | |
| 1577 } | |
| 1578 */ | |
| 1579 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1580 } | |
| 1581 | |
| 1582 | |
| 1583 // Method(s) implementing the Object interface. | |
| 1584 | |
| 1585 String toString() { | |
| 1586 return Collections.collectionToString(this); | |
| 1587 } | |
| 1588 | |
| 1589 | |
| 1590 // Method(s) implementing the TypedData interface. | |
| 1591 | |
| 1592 int get elementSizeInBytes { | |
| 1593 return Int16List.BYTES_PER_ELEMENT; | |
| 1594 } | |
| 1595 | |
| 1596 | |
| 1597 // Internal utility methods. | |
| 1598 | |
| 1599 int _getIndexed(int index) { | |
| 1600 return _array[index]; | |
| 1601 } | |
| 1602 void _setIndexed(int index, int value) { | |
| 1603 _array[index] = value; | |
| 1604 } | |
| 1605 } | |
| 1606 | |
| 1607 | |
| 1608 class _ExternalUint16Array extends _TypedList implements Uint16List { | |
| 1609 // Factory constructors. | |
| 1610 | |
| 1611 _ExternalUint16Array(int length) { | |
| 1612 _array = new sl.Uint16List.transferable(length); | |
| 1613 } | |
| 1614 | |
| 1615 | |
| 1616 // Method(s) implementing the List interface. | |
| 1617 | |
| 1618 int operator[](int index) { | |
| 1619 return _getIndexed(index); | |
| 1620 } | |
| 1621 | |
| 1622 void operator[]=(int index, int value) { | |
| 1623 _setIndexed(index, _toUint16(value)); | |
| 1624 } | |
| 1625 | |
| 1626 Iterator<int> get iterator { | |
| 1627 return new _TypedListIterator<int>(this); | |
| 1628 } | |
| 1629 | |
| 1630 List<int> getRange(int start, int length) { | |
| 1631 _rangeCheck(this.length, start, length); | |
| 1632 List<int> result = new Uint16List(length); | |
| 1633 result.setRange(0, length, this, start); | |
| 1634 return result; | |
| 1635 } | |
| 1636 | |
| 1637 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1638 /** | |
| 1639 if (from is _ExternalUint16Array) { | |
| 1640 _setRange(start * Uint16List.BYTES_PER_ELEMENT, | |
| 1641 length * Uint16List.BYTES_PER_ELEMENT, | |
| 1642 from, | |
| 1643 startFrom * Uint16List.BYTES_PER_ELEMENT); | |
| 1644 } else { | |
| 1645 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1646 from, startFrom); | |
| 1647 } | |
| 1648 */ | |
| 1649 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1650 } | |
| 1651 | |
| 1652 | |
| 1653 // Method(s) implementing the Object interface. | |
| 1654 | |
| 1655 String toString() { | |
| 1656 return Collections.collectionToString(this); | |
| 1657 } | |
| 1658 | |
| 1659 | |
| 1660 // Method(s) implementing the TypedData interface. | |
| 1661 | |
| 1662 int get elementSizeInBytes { | |
| 1663 return Uint16List.BYTES_PER_ELEMENT; | |
| 1664 } | |
| 1665 | |
| 1666 | |
| 1667 // Internal utility methods. | |
| 1668 | |
| 1669 int _getIndexed(int index) { | |
| 1670 return _array[index]; | |
| 1671 } | |
| 1672 void _setIndexed(int index, int value) { | |
| 1673 _array[index] = value; | |
| 1674 } | |
| 1675 } | |
| 1676 | |
| 1677 | |
| 1678 class _ExternalInt32Array extends _TypedList implements Int32List { | |
| 1679 // Factory constructors. | |
| 1680 | |
| 1681 _ExternalInt32Array(int length) { | |
| 1682 _array = new sl.Int32List.transferable(length); | |
| 1683 } | |
| 1684 | |
| 1685 | |
| 1686 // Method(s) implementing the List interface. | |
| 1687 | |
| 1688 int operator[](int index) { | |
| 1689 return _getIndexed(index); | |
| 1690 } | |
| 1691 | |
| 1692 void operator[]=(int index, int value) { | |
| 1693 _setIndexed(index, _toInt32(value)); | |
| 1694 } | |
| 1695 | |
| 1696 Iterator<int> get iterator { | |
| 1697 return new _TypedListIterator<int>(this); | |
| 1698 } | |
| 1699 | |
| 1700 List<int> getRange(int start, int length) { | |
| 1701 _rangeCheck(this.length, start, length); | |
| 1702 List<int> result = new Int32List(length); | |
| 1703 result.setRange(0, length, this, start); | |
| 1704 return result; | |
| 1705 } | |
| 1706 | |
| 1707 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1708 /** | |
| 1709 if (from is _ExternalInt32Array) { | |
| 1710 _setRange(start * Int32List.BYTES_PER_ELEMENT, | |
| 1711 length * Int32List.BYTES_PER_ELEMENT, | |
| 1712 from, | |
| 1713 startFrom * Int32List.BYTES_PER_ELEMENT); | |
| 1714 } else { | |
| 1715 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1716 from, startFrom); | |
| 1717 } | |
| 1718 */ | |
| 1719 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1720 } | |
| 1721 | |
| 1722 | |
| 1723 // Method(s) implementing the Object interface. | |
| 1724 | |
| 1725 String toString() { | |
| 1726 return Collections.collectionToString(this); | |
| 1727 } | |
| 1728 | |
| 1729 | |
| 1730 // Method(s) implementing the TypedData interface. | |
| 1731 | |
| 1732 int get elementSizeInBytes { | |
| 1733 return Int32List.BYTES_PER_ELEMENT; | |
| 1734 } | |
| 1735 | |
| 1736 | |
| 1737 // Internal utility methods. | |
| 1738 | |
| 1739 int _getIndexed(int index) { | |
| 1740 return _array[index]; | |
| 1741 } | |
| 1742 void _setIndexed(int index, int value) { | |
| 1743 _array[index] = value; | |
| 1744 } | |
| 1745 } | |
| 1746 | |
| 1747 | |
| 1748 class _ExternalUint32Array extends _TypedList implements Uint32List { | |
| 1749 // Factory constructors. | |
| 1750 | |
| 1751 _ExternalUint32Array(int length) { | |
| 1752 _array = new sl.Uint32List.transferable(length); | |
| 1753 } | |
| 1754 | |
| 1755 | |
| 1756 // Method(s) implementing the List interface. | |
| 1757 | |
| 1758 int operator[](int index) { | |
| 1759 return _getIndexed(index); | |
| 1760 } | |
| 1761 | |
| 1762 void operator[]=(int index, int value) { | |
| 1763 _setIndexed(index, _toUint32(value)); | |
| 1764 } | |
| 1765 | |
| 1766 Iterator<int> get iterator { | |
| 1767 return new _TypedListIterator<int>(this); | |
| 1768 } | |
| 1769 | |
| 1770 List<int> getRange(int start, int length) { | |
| 1771 _rangeCheck(this.length, start, length); | |
| 1772 List<int> result = new Uint32List(length); | |
| 1773 result.setRange(0, length, this, start); | |
| 1774 return result; | |
| 1775 } | |
| 1776 | |
| 1777 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1778 /** | |
| 1779 if (from is _ExternalUint32Array) { | |
| 1780 _setRange(start * Uint32List.BYTES_PER_ELEMENT, | |
| 1781 length * Uint32List.BYTES_PER_ELEMENT, | |
| 1782 from, | |
| 1783 startFrom * Uint32List.BYTES_PER_ELEMENT); | |
| 1784 } else { | |
| 1785 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1786 from, startFrom); | |
| 1787 } | |
| 1788 */ | |
| 1789 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1790 } | |
| 1791 | |
| 1792 | |
| 1793 // Method(s) implementing the Object interface. | |
| 1794 | |
| 1795 String toString() { | |
| 1796 return Collections.collectionToString(this); | |
| 1797 } | |
| 1798 | |
| 1799 | |
| 1800 // Method(s) implementing the TypedData interface. | |
| 1801 | |
| 1802 int get elementSizeInBytes { | |
| 1803 return Uint32List.BYTES_PER_ELEMENT; | |
| 1804 } | |
| 1805 | |
| 1806 | |
| 1807 // Internal utility methods. | |
| 1808 | |
| 1809 int _getIndexed(int index) { | |
| 1810 return _array[index]; | |
| 1811 } | |
| 1812 void _setIndexed(int index, int value) { | |
| 1813 _array[index] = value; | |
| 1814 } | |
| 1815 } | |
| 1816 | |
| 1817 | |
| 1818 class _ExternalInt64Array extends _TypedList implements Int64List { | |
| 1819 // Factory constructors. | |
| 1820 | |
| 1821 _ExternalInt64Array(int length) { | |
| 1822 _array = new sl.Int64List.transferable(length); | |
| 1823 } | |
| 1824 | |
| 1825 | |
| 1826 // Method(s) implementing the List interface. | |
| 1827 | |
| 1828 int operator[](int index) { | |
| 1829 return _getIndexed(index); | |
| 1830 } | |
| 1831 | |
| 1832 void operator[]=(int index, int value) { | |
| 1833 _setIndexed(index, _toInt64(value)); | |
| 1834 } | |
| 1835 | |
| 1836 Iterator<int> get iterator { | |
| 1837 return new _TypedListIterator<int>(this); | |
| 1838 } | |
| 1839 | |
| 1840 List<int> getRange(int start, int length) { | |
| 1841 _rangeCheck(this.length, start, length); | |
| 1842 List<int> result = new Int64List(length); | |
| 1843 result.setRange(0, length, this, start); | |
| 1844 return result; | |
| 1845 } | |
| 1846 | |
| 1847 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1848 /** | |
| 1849 if (from is _ExternalInt64Array) { | |
| 1850 _setRange(start * Int64List.BYTES_PER_ELEMENT, | |
| 1851 length * Int64List.BYTES_PER_ELEMENT, | |
| 1852 from, | |
| 1853 startFrom * Int64List.BYTES_PER_ELEMENT); | |
| 1854 } else { | |
| 1855 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1856 from, startFrom); | |
| 1857 } | |
| 1858 */ | |
| 1859 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1860 } | |
| 1861 | |
| 1862 | |
| 1863 // Method(s) implementing the Object interface. | |
| 1864 | |
| 1865 String toString() { | |
| 1866 return Collections.collectionToString(this); | |
| 1867 } | |
| 1868 | |
| 1869 | |
| 1870 // Method(s) implementing the TypedData interface. | |
| 1871 | |
| 1872 int get elementSizeInBytes { | |
| 1873 return Int64List.BYTES_PER_ELEMENT; | |
| 1874 } | |
| 1875 | |
| 1876 | |
| 1877 // Internal utility methods. | |
| 1878 | |
| 1879 int _getIndexed(int index) { | |
| 1880 return _array[index]; | |
| 1881 } | |
| 1882 void _setIndexed(int index, int value) { | |
| 1883 _array[index] = value; | |
| 1884 } | |
| 1885 } | |
| 1886 | |
| 1887 | |
| 1888 class _ExternalUint64Array extends _TypedList implements Uint64List { | |
| 1889 // Factory constructors. | |
| 1890 | |
| 1891 _ExternalUint64Array(int length) { | |
| 1892 _array = new sl.Uint64List.transferable(length); | |
| 1893 } | |
| 1894 | |
| 1895 | |
| 1896 // Method(s) implementing the List interface. | |
| 1897 | |
| 1898 int operator[](int index) { | |
| 1899 return _getIndexed(index); | |
| 1900 } | |
| 1901 | |
| 1902 void operator[]=(int index, int value) { | |
| 1903 _setIndexed(index, _toUint64(value)); | |
| 1904 } | |
| 1905 | |
| 1906 Iterator<int> get iterator { | |
| 1907 return new _TypedListIterator<int>(this); | |
| 1908 } | |
| 1909 | |
| 1910 List<int> getRange(int start, int length) { | |
| 1911 _rangeCheck(this.length, start, length); | |
| 1912 List<int> result = new Uint64List(length); | |
| 1913 result.setRange(0, length, this, start); | |
| 1914 return result; | |
| 1915 } | |
| 1916 | |
| 1917 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 1918 /** | |
| 1919 if (from is _ExternalUint64Array) { | |
| 1920 _setRange(start * Uint64List.BYTES_PER_ELEMENT, | |
| 1921 length * Uint64List.BYTES_PER_ELEMENT, | |
| 1922 from, | |
| 1923 startFrom * Uint64List.BYTES_PER_ELEMENT); | |
| 1924 } else { | |
| 1925 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1926 from, startFrom); | |
| 1927 } | |
| 1928 */ | |
| 1929 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 1930 } | |
| 1931 | |
| 1932 | |
| 1933 // Method(s) implementing the Object interface. | |
| 1934 | |
| 1935 String toString() { | |
| 1936 return Collections.collectionToString(this); | |
| 1937 } | |
| 1938 | |
| 1939 | |
| 1940 // Method(s) implementing the TypedData interface. | |
| 1941 | |
| 1942 int get elementSizeInBytes { | |
| 1943 return Uint64List.BYTES_PER_ELEMENT; | |
| 1944 } | |
| 1945 | |
| 1946 | |
| 1947 // Internal utility methods. | |
| 1948 | |
| 1949 int _getIndexed(int index) { | |
| 1950 return _array[index]; | |
| 1951 } | |
| 1952 void _setIndexed(int index, int value) { | |
| 1953 _array[index] = value; | |
| 1954 } | |
| 1955 } | |
| 1956 | |
| 1957 | |
| 1958 class _ExternalFloat32Array extends _TypedList implements Float32List { | |
| 1959 // Factory constructors. | |
| 1960 | |
| 1961 _ExternalFloat32Array(int length) { | |
| 1962 _array = new sl.Float32List.transferable(length); | |
| 1963 } | |
| 1964 | |
| 1965 | |
| 1966 // Method(s) implementing the List interface. | |
| 1967 | |
| 1968 double operator[](int index) { | |
| 1969 return _getIndexed(index); | |
| 1970 } | |
| 1971 | |
| 1972 void operator[]=(int index, double value) { | |
| 1973 _setIndexed(index, value); | |
| 1974 } | |
| 1975 | |
| 1976 Iterator<double> get iterator { | |
| 1977 return new _TypedListIterator<double>(this); | |
| 1978 } | |
| 1979 | |
| 1980 List<double> getRange(int start, int length) { | |
| 1981 _rangeCheck(this.length, start, length); | |
| 1982 List<double> result = new Float32List(length); | |
| 1983 result.setRange(0, length, this, start); | |
| 1984 return result; | |
| 1985 } | |
| 1986 | |
| 1987 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { | |
| 1988 /** | |
| 1989 if (from is _ExternalFloat32Array) { | |
| 1990 _setRange(start * Float32List.BYTES_PER_ELEMENT, | |
| 1991 length * Float32List.BYTES_PER_ELEMENT, | |
| 1992 from, | |
| 1993 startFrom * Float32List.BYTES_PER_ELEMENT); | |
| 1994 } else { | |
| 1995 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 1996 from, startFrom); | |
| 1997 } | |
| 1998 */ | |
| 1999 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2000 } | |
| 2001 | |
| 2002 | |
| 2003 // Method(s) implementing the Object interface. | |
| 2004 | |
| 2005 String toString() { | |
| 2006 return Collections.collectionToString(this); | |
| 2007 } | |
| 2008 | |
| 2009 | |
| 2010 // Method(s) implementing the TypedData interface. | |
| 2011 | |
| 2012 int get elementSizeInBytes { | |
| 2013 return Float32List.BYTES_PER_ELEMENT; | |
| 2014 } | |
| 2015 | |
| 2016 | |
| 2017 // Internal utility methods. | |
| 2018 | |
| 2019 double _getIndexed(int index) { | |
| 2020 return _array[index]; | |
| 2021 } | |
| 2022 void _setIndexed(int index, double value) { | |
| 2023 _array[index] = value; | |
| 2024 } | |
| 2025 } | |
| 2026 | |
| 2027 | |
| 2028 class _ExternalFloat64Array extends _TypedList implements Float64List { | |
| 2029 // Factory constructors. | |
| 2030 | |
| 2031 _ExternalFloat64Array(int length) { | |
| 2032 _array = new sl.Float64List.transferable(length); | |
| 2033 } | |
| 2034 | |
| 2035 | |
| 2036 // Method(s) implementing the List interface. | |
| 2037 | |
| 2038 double operator[](int index) { | |
| 2039 return _getIndexed(index); | |
| 2040 } | |
| 2041 | |
| 2042 void operator[]=(int index, double value) { | |
| 2043 _setIndexed(index, value); | |
| 2044 } | |
| 2045 | |
| 2046 Iterator<double> get iterator { | |
| 2047 return new _TypedListIterator<double>(this); | |
| 2048 } | |
| 2049 | |
| 2050 List<double> getRange(int start, int length) { | |
| 2051 _rangeCheck(this.length, start, length); | |
| 2052 List<double> result = new Float64List(length); | |
| 2053 result.setRange(0, length, this, start); | |
| 2054 return result; | |
| 2055 } | |
| 2056 | |
| 2057 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { | |
| 2058 /** | |
| 2059 if (from is _ExternalFloat64Array) { | |
| 2060 _setRange(start * Float64List.BYTES_PER_ELEMENT, | |
| 2061 length * Float64List.BYTES_PER_ELEMENT, | |
| 2062 from, | |
| 2063 startFrom * Float64List.BYTES_PER_ELEMENT); | |
| 2064 } else { | |
| 2065 IterableMixinWorkaround.setRangeList(this, start, length, | |
| 2066 from, startFrom); | |
| 2067 } | |
| 2068 */ | |
| 2069 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2070 } | |
| 2071 | |
| 2072 | |
| 2073 // Method(s) implementing the Object interface. | |
| 2074 | |
| 2075 String toString() { | |
| 2076 return Collections.collectionToString(this); | |
| 2077 } | |
| 2078 | |
| 2079 | |
| 2080 // Method(s) implementing the TypedData interface. | |
| 2081 | |
| 2082 int get elementSizeInBytes { | |
| 2083 return Float64List.BYTES_PER_ELEMENT; | |
| 2084 } | |
| 2085 | |
| 2086 | |
| 2087 // Internal utility methods. | |
| 2088 | |
| 2089 double _getIndexed(int index) { | |
| 2090 return _array[index]; | |
| 2091 } | |
| 2092 void _setIndexed(int index, double value) { | |
| 2093 _array[index] = value; | |
| 2094 } | |
| 2095 } | |
| 2096 | |
| 2097 | |
| 2098 class _TypedListIterator<E> implements Iterator<E> { | |
| 2099 final List<E> _array; | |
| 2100 final int _length; | |
| 2101 int _position; | |
| 2102 E _current; | |
| 2103 | |
| 2104 _TypedListIterator(List array) | |
| 2105 : _array = array, _length = array.length, _position = -1 { | |
| 2106 assert(array is _TypedList || array is _TypedListView); | |
| 2107 } | |
| 2108 | |
| 2109 bool moveNext() { | |
| 2110 int nextPosition = _position + 1; | |
| 2111 if (nextPosition < _length) { | |
| 2112 _current = _array[nextPosition]; | |
| 2113 _position = nextPosition; | |
| 2114 return true; | |
| 2115 } | |
| 2116 _position = _length; | |
| 2117 _current = null; | |
| 2118 return false; | |
| 2119 } | |
| 2120 | |
| 2121 E get current => _current; | |
| 2122 } | |
| 2123 | |
| 2124 | |
| 2125 class _TypedListView extends _TypedListBase implements TypedData { | |
| 2126 _TypedListView(ByteBuffer _buffer, int _offset, int _length) | |
| 2127 : _typeddata = _buffer, // This assignment is type safe. | |
| 2128 offsetInBytes = _offset, | |
| 2129 length = _length { | |
| 2130 } | |
| 2131 | |
| 2132 | |
| 2133 // Method(s) implementing the TypedData interface. | |
| 2134 | |
| 2135 int get lengthInBytes { | |
| 2136 return length * elementSizeInBytes; | |
| 2137 } | |
| 2138 | |
| 2139 ByteBuffer get buffer { | |
| 2140 return _typeddata.buffer; | |
| 2141 } | |
| 2142 | |
| 2143 final TypedData _typeddata; | |
| 2144 final int offsetInBytes; | |
| 2145 final int length; | |
| 2146 } | |
| 2147 | |
| 2148 | |
| 2149 class _Int8ArrayView extends _TypedListView implements Int8List { | |
| 2150 // Constructor. | |
| 2151 _Int8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2152 : super(buffer, _offsetInBytes, | |
| 2153 _defaultIfNull(_length, | |
| 2154 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2155 Int8List.BYTES_PER_ELEMENT))) { | |
| 2156 _rangeCheck(buffer.lengthInBytes, | |
| 2157 offsetInBytes, | |
| 2158 length * Int8List.BYTES_PER_ELEMENT); | |
| 2159 } | |
| 2160 | |
| 2161 | |
| 2162 // Method(s) implementing List interface. | |
| 2163 | |
| 2164 int operator[](int index) { | |
| 2165 if (index < 0 || index >= length) { | |
| 2166 String message = "$index must be in the range [0..$length)"; | |
| 2167 throw new RangeError(message); | |
| 2168 } | |
| 2169 return _typeddata.getInt8(offsetInBytes + | |
| 2170 (index * Int8List.BYTES_PER_ELEMENT)); | |
| 2171 } | |
| 2172 | |
| 2173 void operator[]=(int index, int value) { | |
| 2174 if (index < 0 || index >= length) { | |
| 2175 String message = "$index must be in the range [0..$length)"; | |
| 2176 throw new RangeError(message); | |
| 2177 } | |
| 2178 _typeddata.setInt8(offsetInBytes + (index * Int8List.BYTES_PER_ELEMENT), | |
| 2179 _toInt8(value)); | |
| 2180 } | |
| 2181 | |
| 2182 Iterator<int> get iterator { | |
| 2183 return new _TypedListIterator<int>(this); | |
| 2184 } | |
| 2185 | |
| 2186 List<int> getRange(int start, int length) { | |
| 2187 _rangeCheck(this.length, start, length); | |
| 2188 List<int> result = new Int8List(length); | |
| 2189 result.setRange(0, length, this, start); | |
| 2190 return result; | |
| 2191 } | |
| 2192 | |
| 2193 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2194 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2195 } | |
| 2196 | |
| 2197 | |
| 2198 // Method(s) implementing Object interface. | |
| 2199 | |
| 2200 String toString() { | |
| 2201 return Collections.collectionToString(this); | |
| 2202 } | |
| 2203 | |
| 2204 | |
| 2205 // Method(s) implementing TypedData interface. | |
| 2206 | |
| 2207 int get elementSizeInBytes { | |
| 2208 return Int8List.BYTES_PER_ELEMENT; | |
| 2209 } | |
| 2210 } | |
| 2211 | |
| 2212 | |
| 2213 class _Uint8ArrayView extends _TypedListView implements Uint8List { | |
| 2214 // Constructor. | |
| 2215 _Uint8ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2216 : super(buffer, _offsetInBytes, | |
| 2217 _defaultIfNull(_length, | |
| 2218 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2219 Uint8List.BYTES_PER_ELEMENT))) { | |
| 2220 _rangeCheck(buffer.lengthInBytes, | |
| 2221 offsetInBytes, | |
| 2222 length * Uint8List.BYTES_PER_ELEMENT); | |
| 2223 } | |
| 2224 | |
| 2225 | |
| 2226 // Method(s) implementing List interface. | |
| 2227 | |
| 2228 int operator[](int index) { | |
| 2229 if (index < 0 || index >= length) { | |
| 2230 String message = "$index must be in the range [0..$length)"; | |
| 2231 throw new RangeError(message); | |
| 2232 } | |
| 2233 return _typeddata.getUint8(offsetInBytes + | |
| 2234 (index * Uint8List.BYTES_PER_ELEMENT)); | |
| 2235 } | |
| 2236 | |
| 2237 void operator[]=(int index, int value) { | |
| 2238 if (index < 0 || index >= length) { | |
| 2239 String message = "$index must be in the range [0..$length)"; | |
| 2240 throw new RangeError(message); | |
| 2241 } | |
| 2242 _typeddata.setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), | |
| 2243 _toUint8(value)); | |
| 2244 } | |
| 2245 | |
| 2246 Iterator<int> get iterator { | |
| 2247 return new _TypedListIterator<int>(this); | |
| 2248 } | |
| 2249 | |
| 2250 List<int> getRange(int start, int length) { | |
| 2251 _rangeCheck(this.length, start, length); | |
| 2252 List<int> result = new Uint8List(length); | |
| 2253 result.setRange(0, length, this, start); | |
| 2254 return result; | |
| 2255 } | |
| 2256 | |
| 2257 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2258 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2259 } | |
| 2260 | |
| 2261 | |
| 2262 // Method(s) implementing Object interface. | |
| 2263 | |
| 2264 String toString() { | |
| 2265 return Collections.collectionToString(this); | |
| 2266 } | |
| 2267 | |
| 2268 | |
| 2269 // Method(s) implementing TypedData interface. | |
| 2270 | |
| 2271 int get elementSizeInBytes { | |
| 2272 return Uint8List.BYTES_PER_ELEMENT; | |
| 2273 } | |
| 2274 } | |
| 2275 | |
| 2276 | |
| 2277 class _Uint8ClampedArrayView extends _TypedListView implements Uint8List { | |
| 2278 // Constructor. | |
| 2279 _Uint8ClampedArrayView(ByteBuffer buffer, | |
| 2280 [int _offsetInBytes = 0, int _length]) | |
| 2281 : super(buffer, _offsetInBytes, | |
| 2282 _defaultIfNull(_length, | |
| 2283 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2284 Uint8List.BYTES_PER_ELEMENT))) { | |
| 2285 _rangeCheck(buffer.lengthInBytes, | |
| 2286 offsetInBytes, | |
| 2287 length * Uint8List.BYTES_PER_ELEMENT); | |
| 2288 } | |
| 2289 | |
| 2290 | |
| 2291 // Method(s) implementing List interface. | |
| 2292 | |
| 2293 int operator[](int index) { | |
| 2294 if (index < 0 || index >= length) { | |
| 2295 String message = "$index must be in the range [0..$length)"; | |
| 2296 throw new RangeError(message); | |
| 2297 } | |
| 2298 return _typeddata.getUint8(offsetInBytes + | |
| 2299 (index * Uint8List.BYTES_PER_ELEMENT)); | |
| 2300 } | |
| 2301 | |
| 2302 void operator[]=(int index, int value) { | |
| 2303 if (index < 0 || index >= length) { | |
| 2304 String message = "$index must be in the range [0..$length)"; | |
| 2305 throw new RangeError(message); | |
| 2306 } | |
| 2307 _typeddata.setUint8(offsetInBytes + (index * Uint8List.BYTES_PER_ELEMENT), | |
| 2308 _toClampedUint8(value)); | |
| 2309 } | |
| 2310 | |
| 2311 Iterator<int> get iterator { | |
| 2312 return new _TypedListIterator<int>(this); | |
| 2313 } | |
| 2314 | |
| 2315 List<int> getRange(int start, int length) { | |
| 2316 _rangeCheck(this.length, start, length); | |
| 2317 List<int> result = new Uint8List(length); | |
| 2318 result.setRange(0, length, this, start); | |
| 2319 return result; | |
| 2320 } | |
| 2321 | |
| 2322 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2323 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2324 } | |
| 2325 | |
| 2326 | |
| 2327 // Method(s) implementing Object interface. | |
| 2328 | |
| 2329 String toString() { | |
| 2330 return Collections.collectionToString(this); | |
| 2331 } | |
| 2332 | |
| 2333 | |
| 2334 // Method(s) implementing TypedData interface. | |
| 2335 | |
| 2336 int get elementSizeInBytes { | |
| 2337 return Uint8List.BYTES_PER_ELEMENT; | |
| 2338 } | |
| 2339 } | |
| 2340 | |
| 2341 | |
| 2342 class _Int16ArrayView extends _TypedListView implements Int16List { | |
| 2343 // Constructor. | |
| 2344 _Int16ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2345 : super(buffer, _offsetInBytes, | |
| 2346 _defaultIfNull(_length, | |
| 2347 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2348 Int16List.BYTES_PER_ELEMENT))) { | |
| 2349 _rangeCheck(buffer.lengthInBytes, | |
| 2350 offsetInBytes, | |
| 2351 length * Int16List.BYTES_PER_ELEMENT); | |
| 2352 } | |
| 2353 | |
| 2354 | |
| 2355 // Method(s) implementing List interface. | |
| 2356 | |
| 2357 int operator[](int index) { | |
| 2358 if (index < 0 || index >= length) { | |
| 2359 String message = "$index must be in the range [0..$length)"; | |
| 2360 throw new RangeError(message); | |
| 2361 } | |
| 2362 return _typeddata.getInt16(offsetInBytes + | |
| 2363 (index * Int16List.BYTES_PER_ELEMENT)); | |
| 2364 } | |
| 2365 | |
| 2366 void operator[]=(int index, int value) { | |
| 2367 if (index < 0 || index >= length) { | |
| 2368 String message = "$index must be in the range [0..$length)"; | |
| 2369 throw new RangeError(message); | |
| 2370 } | |
| 2371 _typeddata.setInt16(offsetInBytes + (index * Int16List.BYTES_PER_ELEMENT), | |
| 2372 _toInt16(value)); | |
| 2373 } | |
| 2374 | |
| 2375 Iterator<int> get iterator { | |
| 2376 return new _TypedListIterator<int>(this); | |
| 2377 } | |
| 2378 | |
| 2379 List<int> getRange(int start, int length) { | |
| 2380 _rangeCheck(this.length, start, length); | |
| 2381 List<int> result = new Int16List(length); | |
| 2382 result.setRange(0, length, this, start); | |
| 2383 return result; | |
| 2384 } | |
| 2385 | |
| 2386 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2387 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2388 } | |
| 2389 | |
| 2390 | |
| 2391 // Method(s) implementing Object interface. | |
| 2392 | |
| 2393 String toString() { | |
| 2394 return Collections.collectionToString(this); | |
| 2395 } | |
| 2396 | |
| 2397 | |
| 2398 // Method(s) implementing TypedData interface. | |
| 2399 | |
| 2400 int get elementSizeInBytes { | |
| 2401 return Int16List.BYTES_PER_ELEMENT; | |
| 2402 } | |
| 2403 } | |
| 2404 | |
| 2405 | |
| 2406 class _Uint16ArrayView extends _TypedListView implements Uint16List { | |
| 2407 // Constructor. | |
| 2408 _Uint16ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2409 : super(buffer, _offsetInBytes, | |
| 2410 _defaultIfNull(_length, | |
| 2411 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2412 Uint16List.BYTES_PER_ELEMENT))) { | |
| 2413 _rangeCheck(buffer.lengthInBytes, | |
| 2414 offsetInBytes, | |
| 2415 length * Uint16List.BYTES_PER_ELEMENT); | |
| 2416 } | |
| 2417 | |
| 2418 | |
| 2419 // Method(s) implementing List interface. | |
| 2420 | |
| 2421 int operator[](int index) { | |
| 2422 if (index < 0 || index >= length) { | |
| 2423 String message = "$index must be in the range [0..$length)"; | |
| 2424 throw new RangeError(message); | |
| 2425 } | |
| 2426 return _typeddata.getUint16(offsetInBytes + | |
| 2427 (index * Uint16List.BYTES_PER_ELEMENT)); | |
| 2428 } | |
| 2429 | |
| 2430 void operator[]=(int index, int value) { | |
| 2431 if (index < 0 || index >= length) { | |
| 2432 String message = "$index must be in the range [0..$length)"; | |
| 2433 throw new RangeError(message); | |
| 2434 } | |
| 2435 _typeddata.setUint16(offsetInBytes + (index * Uint16List.BYTES_PER_ELEMENT), | |
| 2436 _toUint16(value)); | |
| 2437 } | |
| 2438 | |
| 2439 Iterator<int> get iterator { | |
| 2440 return new _TypedListIterator<int>(this); | |
| 2441 } | |
| 2442 | |
| 2443 List<int> getRange(int start, int length) { | |
| 2444 _rangeCheck(this.length, start, length); | |
| 2445 List<int> result = new Uint16List(length); | |
| 2446 result.setRange(0, length, this, start); | |
| 2447 return result; | |
| 2448 } | |
| 2449 | |
| 2450 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2451 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2452 } | |
| 2453 | |
| 2454 | |
| 2455 // Method(s) implementing Object interface. | |
| 2456 | |
| 2457 String toString() { | |
| 2458 return Collections.collectionToString(this); | |
| 2459 } | |
| 2460 | |
| 2461 | |
| 2462 // Method(s) implementing TypedData interface. | |
| 2463 | |
| 2464 int get elementSizeInBytes { | |
| 2465 return Uint16List.BYTES_PER_ELEMENT; | |
| 2466 } | |
| 2467 } | |
| 2468 | |
| 2469 | |
| 2470 class _Int32ArrayView extends _TypedListView implements Int32List { | |
| 2471 // Constructor. | |
| 2472 _Int32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2473 : super(buffer, _offsetInBytes, | |
| 2474 _defaultIfNull(_length, | |
| 2475 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2476 Int32List.BYTES_PER_ELEMENT))) { | |
| 2477 _rangeCheck(buffer.lengthInBytes, | |
| 2478 offsetInBytes, | |
| 2479 length * Int32List.BYTES_PER_ELEMENT); | |
| 2480 } | |
| 2481 | |
| 2482 | |
| 2483 // Method(s) implementing List interface. | |
| 2484 | |
| 2485 int operator[](int index) { | |
| 2486 if (index < 0 || index >= length) { | |
| 2487 String message = "$index must be in the range [0..$length)"; | |
| 2488 throw new RangeError(message); | |
| 2489 } | |
| 2490 return _typeddata.getInt32(offsetInBytes + | |
| 2491 (index * Int32List.BYTES_PER_ELEMENT)); | |
| 2492 } | |
| 2493 | |
| 2494 void operator[]=(int index, int value) { | |
| 2495 if (index < 0 || index >= length) { | |
| 2496 String message = "$index must be in the range [0..$length)"; | |
| 2497 throw new RangeError(message); | |
| 2498 } | |
| 2499 _typeddata.setInt32(offsetInBytes + (index * Int32List.BYTES_PER_ELEMENT), | |
| 2500 _toInt32(value)); | |
| 2501 } | |
| 2502 | |
| 2503 Iterator<int> get iterator { | |
| 2504 return new _TypedListIterator<int>(this); | |
| 2505 } | |
| 2506 | |
| 2507 List<int> getRange(int start, int length) { | |
| 2508 _rangeCheck(this.length, start, length); | |
| 2509 List<int> result = new Int32List(length); | |
| 2510 result.setRange(0, length, this, start); | |
| 2511 return result; | |
| 2512 } | |
| 2513 | |
| 2514 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2515 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2516 } | |
| 2517 | |
| 2518 | |
| 2519 // Method(s) implementing Object interface. | |
| 2520 | |
| 2521 String toString() { | |
| 2522 return Collections.collectionToString(this); | |
| 2523 } | |
| 2524 | |
| 2525 | |
| 2526 // Method(s) implementing TypedData interface. | |
| 2527 | |
| 2528 int get elementSizeInBytes { | |
| 2529 return Int32List.BYTES_PER_ELEMENT; | |
| 2530 } | |
| 2531 } | |
| 2532 | |
| 2533 | |
| 2534 class _Uint32ArrayView extends _TypedListView implements Uint32List { | |
| 2535 // Constructor. | |
| 2536 _Uint32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2537 : super(buffer, _offsetInBytes, | |
| 2538 _defaultIfNull(_length, | |
| 2539 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2540 Uint32List.BYTES_PER_ELEMENT))) { | |
| 2541 _rangeCheck(buffer.lengthInBytes, | |
| 2542 offsetInBytes, | |
| 2543 length * Uint32List.BYTES_PER_ELEMENT); | |
| 2544 } | |
| 2545 | |
| 2546 | |
| 2547 // Method(s) implementing List interface. | |
| 2548 | |
| 2549 int operator[](int index) { | |
| 2550 if (index < 0 || index >= length) { | |
| 2551 String message = "$index must be in the range [0..$length)"; | |
| 2552 throw new RangeError(message); | |
| 2553 } | |
| 2554 return _typeddata.getUint32(offsetInBytes + | |
| 2555 (index * Uint32List.BYTES_PER_ELEMENT)); | |
| 2556 } | |
| 2557 | |
| 2558 void operator[]=(int index, int value) { | |
| 2559 if (index < 0 || index >= length) { | |
| 2560 String message = "$index must be in the range [0..$length)"; | |
| 2561 throw new RangeError(message); | |
| 2562 } | |
| 2563 _typeddata.setUint32(offsetInBytes + (index * Uint32List.BYTES_PER_ELEMENT), | |
| 2564 _toUint32(value)); | |
| 2565 } | |
| 2566 | |
| 2567 Iterator<int> get iterator { | |
| 2568 return new _TypedListIterator<int>(this); | |
| 2569 } | |
| 2570 | |
| 2571 List<int> getRange(int start, int length) { | |
| 2572 _rangeCheck(this.length, start, length); | |
| 2573 List<int> result = new Uint32List(length); | |
| 2574 result.setRange(0, length, this, start); | |
| 2575 return result; | |
| 2576 } | |
| 2577 | |
| 2578 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2579 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2580 } | |
| 2581 | |
| 2582 | |
| 2583 // Method(s) implementing Object interface. | |
| 2584 | |
| 2585 String toString() { | |
| 2586 return Collections.collectionToString(this); | |
| 2587 } | |
| 2588 | |
| 2589 | |
| 2590 // Method(s) implementing TypedData interface. | |
| 2591 | |
| 2592 int get elementSizeInBytes { | |
| 2593 return Uint32List.BYTES_PER_ELEMENT; | |
| 2594 } | |
| 2595 } | |
| 2596 | |
| 2597 | |
| 2598 class _Int64ArrayView extends _TypedListView implements Int64List { | |
| 2599 // Constructor. | |
| 2600 _Int64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2601 : super(buffer, _offsetInBytes, | |
| 2602 _defaultIfNull(_length, | |
| 2603 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2604 Int64List.BYTES_PER_ELEMENT))) { | |
| 2605 _rangeCheck(buffer.lengthInBytes, | |
| 2606 offsetInBytes, | |
| 2607 length * Int64List.BYTES_PER_ELEMENT); | |
| 2608 } | |
| 2609 | |
| 2610 | |
| 2611 // Method(s) implementing List interface. | |
| 2612 | |
| 2613 int operator[](int index) { | |
| 2614 if (index < 0 || index >= length) { | |
| 2615 String message = "$index must be in the range [0..$length)"; | |
| 2616 throw new RangeError(message); | |
| 2617 } | |
| 2618 return _typeddata.getInt64(offsetInBytes + | |
| 2619 (index * Int64List.BYTES_PER_ELEMENT)); | |
| 2620 } | |
| 2621 | |
| 2622 void operator[]=(int index, int value) { | |
| 2623 if (index < 0 || index >= length) { | |
| 2624 String message = "$index must be in the range [0..$length)"; | |
| 2625 throw new RangeError(message); | |
| 2626 } | |
| 2627 _typeddata.setInt64(offsetInBytes + (index * Int64List.BYTES_PER_ELEMENT), | |
| 2628 _toInt64(value)); | |
| 2629 } | |
| 2630 | |
| 2631 Iterator<int> get iterator { | |
| 2632 return new _TypedListIterator<int>(this); | |
| 2633 } | |
| 2634 | |
| 2635 List<int> getRange(int start, int length) { | |
| 2636 _rangeCheck(this.length, start, length); | |
| 2637 List<int> result = new Int64List(length); | |
| 2638 result.setRange(0, length, this, start); | |
| 2639 return result; | |
| 2640 } | |
| 2641 | |
| 2642 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2643 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2644 } | |
| 2645 | |
| 2646 | |
| 2647 // Method(s) implementing Object interface. | |
| 2648 | |
| 2649 String toString() { | |
| 2650 return Collections.collectionToString(this); | |
| 2651 } | |
| 2652 | |
| 2653 | |
| 2654 // Method(s) implementing TypedData interface. | |
| 2655 | |
| 2656 int get elementSizeInBytes { | |
| 2657 return Int64List.BYTES_PER_ELEMENT; | |
| 2658 } | |
| 2659 } | |
| 2660 | |
| 2661 | |
| 2662 class _Uint64ArrayView extends _TypedListView implements Uint64List { | |
| 2663 // Constructor. | |
| 2664 _Uint64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2665 : super(buffer, _offsetInBytes, | |
| 2666 _defaultIfNull(_length, | |
| 2667 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2668 Uint64List.BYTES_PER_ELEMENT))) { | |
| 2669 _rangeCheck(buffer.lengthInBytes, | |
| 2670 offsetInBytes, | |
| 2671 length * Uint64List.BYTES_PER_ELEMENT); | |
| 2672 } | |
| 2673 | |
| 2674 | |
| 2675 // Method(s) implementing List interface. | |
| 2676 | |
| 2677 int operator[](int index) { | |
| 2678 if (index < 0 || index >= length) { | |
| 2679 String message = "$index must be in the range [0..$length)"; | |
| 2680 throw new RangeError(message); | |
| 2681 } | |
| 2682 return _typeddata.getUint64(offsetInBytes + | |
| 2683 (index * Uint64List.BYTES_PER_ELEMENT)); | |
| 2684 } | |
| 2685 | |
| 2686 void operator[]=(int index, int value) { | |
| 2687 if (index < 0 || index >= length) { | |
| 2688 String message = "$index must be in the range [0..$length)"; | |
| 2689 throw new RangeError(message); | |
| 2690 } | |
| 2691 _typeddata.setUint64(offsetInBytes + (index * Uint64List.BYTES_PER_ELEMENT), | |
| 2692 _toUint64(value)); | |
| 2693 } | |
| 2694 | |
| 2695 Iterator<int> get iterator { | |
| 2696 return new _TypedListIterator<int>(this); | |
| 2697 } | |
| 2698 | |
| 2699 List<int> getRange(int start, int length) { | |
| 2700 _rangeCheck(this.length, start, length); | |
| 2701 List<int> result = new Uint64List(length); | |
| 2702 result.setRange(0, length, this, start); | |
| 2703 return result; | |
| 2704 } | |
| 2705 | |
| 2706 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { | |
| 2707 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2708 } | |
| 2709 | |
| 2710 | |
| 2711 // Method(s) implementing Object interface. | |
| 2712 | |
| 2713 String toString() { | |
| 2714 return Collections.collectionToString(this); | |
| 2715 } | |
| 2716 | |
| 2717 | |
| 2718 // Method(s) implementing TypedData interface. | |
| 2719 | |
| 2720 int get elementSizeInBytes { | |
| 2721 return Uint64List.BYTES_PER_ELEMENT; | |
| 2722 } | |
| 2723 } | |
| 2724 | |
| 2725 | |
| 2726 class _Float32ArrayView extends _TypedListView implements Float32List { | |
| 2727 // Constructor. | |
| 2728 _Float32ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2729 : super(buffer, _offsetInBytes, | |
| 2730 _defaultIfNull(_length, | |
| 2731 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2732 Float32List.BYTES_PER_ELEMENT))) { | |
| 2733 _rangeCheck(buffer.lengthInBytes, | |
| 2734 offsetInBytes, | |
| 2735 length * Float32List.BYTES_PER_ELEMENT); | |
| 2736 } | |
| 2737 | |
| 2738 | |
| 2739 // Method(s) implementing List interface. | |
| 2740 | |
| 2741 double operator[](int index) { | |
| 2742 if (index < 0 || index >= length) { | |
| 2743 String message = "$index must be in the range [0..$length)"; | |
| 2744 throw new RangeError(message); | |
| 2745 } | |
| 2746 return _typeddata.getFloat32(offsetInBytes + | |
| 2747 (index * Float32List.BYTES_PER_ELEMENT)); | |
| 2748 } | |
| 2749 | |
| 2750 void operator[]=(int index, double value) { | |
| 2751 if (index < 0 || index >= length) { | |
| 2752 String message = "$index must be in the range [0..$length)"; | |
| 2753 throw new RangeError(message); | |
| 2754 } | |
| 2755 _typeddata.setFloat32(offsetInBytes + | |
| 2756 (index * Float32List.BYTES_PER_ELEMENT), value); | |
| 2757 } | |
| 2758 | |
| 2759 Iterator<double> get iterator { | |
| 2760 return new _TypedListIterator<double>(this); | |
| 2761 } | |
| 2762 | |
| 2763 List<double> getRange(int start, int length) { | |
| 2764 _rangeCheck(this.length, start, length); | |
| 2765 List<double> result = new Float32List(length); | |
| 2766 result.setRange(0, length, this, start); | |
| 2767 return result; | |
| 2768 } | |
| 2769 | |
| 2770 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { | |
| 2771 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2772 } | |
| 2773 | |
| 2774 | |
| 2775 // Method(s) implementing Object interface. | |
| 2776 | |
| 2777 String toString() { | |
| 2778 return Collections.collectionToString(this); | |
| 2779 } | |
| 2780 | |
| 2781 | |
| 2782 // Method(s) implementing TypedData interface. | |
| 2783 | |
| 2784 int get elementSizeInBytes { | |
| 2785 return Float32List.BYTES_PER_ELEMENT; | |
| 2786 } | |
| 2787 } | |
| 2788 | |
| 2789 | |
| 2790 class _Float64ArrayView extends _TypedListView implements Float64List { | |
| 2791 // Constructor. | |
| 2792 _Float64ArrayView(ByteBuffer buffer, [int _offsetInBytes = 0, int _length]) | |
| 2793 : super(buffer, _offsetInBytes, | |
| 2794 _defaultIfNull(_length, | |
| 2795 ((buffer.lengthInBytes - _offsetInBytes) ~/ | |
| 2796 Float64List.BYTES_PER_ELEMENT))) { | |
| 2797 _rangeCheck(buffer.lengthInBytes, | |
| 2798 offsetInBytes, | |
| 2799 length * Float64List.BYTES_PER_ELEMENT); | |
| 2800 } | |
| 2801 | |
| 2802 | |
| 2803 // Method(s) implementing List interface. | |
| 2804 | |
| 2805 double operator[](int index) { | |
| 2806 if (index < 0 || index >= length) { | |
| 2807 String message = "$index must be in the range [0..$length)"; | |
| 2808 throw new RangeError(message); | |
| 2809 } | |
| 2810 return _typeddata.getFloat64(offsetInBytes + | |
| 2811 (index * Float64List.BYTES_PER_ELEMENT)); | |
| 2812 } | |
| 2813 | |
| 2814 void operator[]=(int index, double value) { | |
| 2815 if (index < 0 || index >= length) { | |
| 2816 String message = "$index must be in the range [0..$length)"; | |
| 2817 throw new RangeError(message); | |
| 2818 } | |
| 2819 _typeddata.setFloat64(offsetInBytes + | |
| 2820 (index * Float64List.BYTES_PER_ELEMENT), value); | |
| 2821 } | |
| 2822 | |
| 2823 Iterator<double> get iterator { | |
| 2824 return new _TypedListIterator<double>(this); | |
| 2825 } | |
| 2826 | |
| 2827 List<double> getRange(int start, int length) { | |
| 2828 _rangeCheck(this.length, start, length); | |
| 2829 List<double> result = new Float64List(length); | |
| 2830 result.setRange(0, length, this, start); | |
| 2831 return result; | |
| 2832 } | |
| 2833 | |
| 2834 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { | |
| 2835 IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom); | |
| 2836 } | |
| 2837 | |
| 2838 | |
| 2839 // Method(s) implementing Object interface. | |
| 2840 | |
| 2841 String toString() { | |
| 2842 return Collections.collectionToString(this); | |
| 2843 } | |
| 2844 | |
| 2845 | |
| 2846 // Method(s) implementing TypedData interface. | |
| 2847 | |
| 2848 int get elementSizeInBytes { | |
| 2849 return Float64List.BYTES_PER_ELEMENT; | |
| 2850 } | |
| 2851 } | |
| 2852 | |
| 2853 | |
| 2854 class _ByteDataView implements ByteData { | |
| 2855 _ByteDataView(ByteBuffer _buffer, int _offsetInBytes, int _lengthInBytes) | |
| 2856 : _typeddata = _buffer as TypedData, | |
| 2857 _offset = _offsetInBytes, | |
| 2858 _length = _lengthInBytes { | |
| 2859 _rangeCheck(_buffer.lengthInBytes, _offset, _length); | |
| 2860 } | |
| 2861 | |
| 2862 | |
| 2863 // Method(s) implementing TypedData interface. | |
| 2864 | |
| 2865 ByteBuffer get buffer { | |
| 2866 return _typeddata.buffer; | |
| 2867 } | |
| 2868 | |
| 2869 int get lengthInBytes { | |
| 2870 return _length; | |
| 2871 } | |
| 2872 | |
| 2873 int offsetInBytes() { | |
| 2874 return _offset; | |
| 2875 } | |
| 2876 | |
| 2877 // Method(s) implementing ByteData interface. | |
| 2878 | |
| 2879 int getInt8(int byteOffset) { | |
| 2880 return _typeddata._getInt8(_offset + byteOffset); | |
| 2881 } | |
| 2882 void setInt8(int byteOffset, int value) { | |
| 2883 _typeddata._setInt8(_offset + byteOffset, value); | |
| 2884 } | |
| 2885 | |
| 2886 int getUint8(int byteOffset) { | |
| 2887 return _typeddata._getUint8(_offset + byteOffset); | |
| 2888 } | |
| 2889 void setUint8(int byteOffset, int value) { | |
| 2890 _typeddata._setUint8(_offset + byteOffset, value); | |
| 2891 } | |
| 2892 | |
| 2893 int getInt16(int byteOffset) { | |
| 2894 return _typeddata._getInt16(_offset + byteOffset); | |
| 2895 } | |
| 2896 void setInt16(int byteOffset, int value) { | |
| 2897 _typeddata._setInt16(_offset + byteOffset, value); | |
| 2898 } | |
| 2899 | |
| 2900 int getUint16(int byteOffset) { | |
| 2901 return _typeddata._getUint16(_offset + byteOffset); | |
| 2902 } | |
| 2903 void setUint16(int byteOffset, int value) { | |
| 2904 _typeddata._setUint16(_offset + byteOffset, value); | |
| 2905 } | |
| 2906 | |
| 2907 int getInt32(int byteOffset) { | |
| 2908 return _typeddata._getInt32(_offset + byteOffset); | |
| 2909 } | |
| 2910 void setInt32(int byteOffset, int value) { | |
| 2911 _typeddata._setInt32(_offset + byteOffset, value); | |
| 2912 } | |
| 2913 | |
| 2914 int getUint32(int byteOffset) { | |
| 2915 return _typeddata._getUint32(_offset + byteOffset); | |
| 2916 } | |
| 2917 void setUint32(int byteOffset, int value) { | |
| 2918 _typedata._setUint32(_offset + byteOffset, value); | |
|
Florian Schneider
2013/03/12 14:42:27
s/_typedata/_typeddata/g
here and below. This se
| |
| 2919 } | |
| 2920 | |
| 2921 int getInt64(int byteOffset) { | |
| 2922 return _typedata._getInt64(_offset + byteOffset); | |
| 2923 } | |
| 2924 void setInt64(int byteOffset, int value) { | |
| 2925 _typedata._setInt64(_offset + byteOffset, value); | |
| 2926 } | |
| 2927 | |
| 2928 int getUint64(int byteOffset) { | |
| 2929 return _typedata._getUint64(_offset + byteOffset); | |
| 2930 } | |
| 2931 void setUint64(int byteOffset, int value) { | |
| 2932 _typedata._setUint64(_offset + byteOffset, value); | |
| 2933 } | |
| 2934 | |
| 2935 double getFloat32(int byteOffset) { | |
| 2936 return _typedata._getFloat32(_offset + byteOffset); | |
| 2937 } | |
| 2938 void setFloat32(int byteOffset, double value) { | |
| 2939 _typedata._setFloat32(_offset + byteOffset, value); | |
| 2940 } | |
| 2941 | |
| 2942 double getFloat64(int byteOffset) { | |
| 2943 return _typedata._getFloat64(_offset + byteOffset); | |
| 2944 } | |
| 2945 void setFloat64(int byteOffset, double value) { | |
| 2946 _typedata._setFloat64(_offset + byteOffset, value); | |
| 2947 } | |
| 2948 | |
| 2949 final TypedData _typeddata; | |
| 2950 final int _offset; | |
| 2951 final int _length; | |
| 2952 } | |
| 2953 | |
| 2954 | |
| 2955 // Top level utility methods. | |
| 2956 int _toInt(int value, int mask) { | |
| 2957 value &= mask; | |
| 2958 if (value > (mask >> 1)) value -= mask + 1; | |
| 2959 return value; | |
| 2960 } | |
| 2961 | |
| 2962 | |
| 2963 int _toInt8(int value) { | |
| 2964 return _toInt(value, 0xFF); | |
| 2965 } | |
| 2966 | |
| 2967 | |
| 2968 int _toUint8(int value) { | |
| 2969 return value & 0xFF; | |
| 2970 } | |
| 2971 | |
| 2972 | |
| 2973 int _toClampedUint8(int value) { | |
| 2974 if (value < 0) return 0; | |
| 2975 if (value > 0xFF) return 0xFF; | |
| 2976 return value; | |
| 2977 } | |
| 2978 | |
| 2979 | |
| 2980 int _toInt16(int value) { | |
| 2981 return _toInt(value, 0xFFFF); | |
| 2982 } | |
| 2983 | |
| 2984 | |
| 2985 int _toUint16(int value) { | |
| 2986 return value & 0xFFFF; | |
| 2987 } | |
| 2988 | |
| 2989 | |
| 2990 int _toInt32(int value) { | |
| 2991 return _toInt(value, 0xFFFFFFFF); | |
| 2992 } | |
| 2993 | |
| 2994 | |
| 2995 int _toUint32(int value) { | |
| 2996 return value & 0xFFFFFFFF; | |
| 2997 } | |
| 2998 | |
| 2999 | |
| 3000 int _toInt64(int value) { | |
| 3001 return _toInt(value, 0xFFFFFFFFFFFFFFFF); | |
| 3002 } | |
| 3003 | |
| 3004 | |
| 3005 int _toUint64(int value) { | |
| 3006 return value & 0xFFFFFFFFFFFFFFFF; | |
| 3007 } | |
| 3008 | |
| 3009 | |
| 3010 void _rangeCheck(int listLength, int start, int length) { | |
| 3011 if (length < 0) { | |
| 3012 throw new RangeError.value(length); | |
| 3013 } | |
| 3014 if (start < 0) { | |
| 3015 throw new RangeError.value(start); | |
| 3016 } | |
| 3017 if (start + length > listLength) { | |
| 3018 throw new RangeError.value(start + length); | |
| 3019 } | |
| 3020 } | |
| 3021 | |
| 3022 | |
| 3023 int _defaultIfNull(object, value) { | |
| 3024 if (object == null) { | |
| 3025 return value; | |
| 3026 } | |
| 3027 } | |
| OLD | NEW |