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