OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Lists that efficiently handle fixed sized data | 5 /// Lists that efficiently handle fixed sized data |
6 /// (for example, unsigned 8 byte integers) and SIMD numeric types. | 6 /// (for example, unsigned 8 byte integers) and SIMD numeric types. |
7 /// | 7 /// |
8 /// To use this library in your code: | 8 /// To use this library in your code: |
9 /// | 9 /// |
10 /// import 'dart:typed_data'; | 10 /// import 'dart:typed_data'; |
11 library dart.typed_data; | 11 library dart.typed_data; |
12 | 12 |
13 import 'dart:collection'; | 13 import 'dart:collection'; |
14 | 14 |
15 /** | 15 /** |
16 * A sequence of bytes underlying a typed data object. | 16 * A sequence of bytes underlying a typed data object. |
17 * | 17 * |
18 * Used to process large quantities of binary or numerical data | 18 * Used to process large quantities of binary or numerical data |
19 * more efficiently using a typed view. | 19 * more efficiently using a typed view. |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 * | 352 * |
353 * The start index and length must describe a valid range of the buffer: | 353 * The start index and length must describe a valid range of the buffer: |
354 * | 354 * |
355 * * `offsetInBytes` must not be negative, | 355 * * `offsetInBytes` must not be negative, |
356 * * `length` must not be negative, and | 356 * * `length` must not be negative, and |
357 * * `offsetInBytes + length` must not be greater than [lengthInBytes]. | 357 * * `offsetInBytes + length` must not be greater than [lengthInBytes]. |
358 */ | 358 */ |
359 ByteData asByteData([int offsetInBytes = 0, int length]); | 359 ByteData asByteData([int offsetInBytes = 0, int length]); |
360 } | 360 } |
361 | 361 |
362 | |
363 /** | 362 /** |
364 * A typed view of a sequence of bytes. | 363 * A typed view of a sequence of bytes. |
365 */ | 364 */ |
366 abstract class TypedData { | 365 abstract class TypedData { |
367 /** | 366 /** |
368 * Returns the number of bytes in the representation of each element in this | 367 * Returns the number of bytes in the representation of each element in this |
369 * list. | 368 * list. |
370 */ | 369 */ |
371 int get elementSizeInBytes; | 370 int get elementSizeInBytes; |
372 | 371 |
373 /** | 372 /** |
374 * Returns the offset in bytes into the underlying byte buffer of this view. | 373 * Returns the offset in bytes into the underlying byte buffer of this view. |
375 */ | 374 */ |
376 int get offsetInBytes; | 375 int get offsetInBytes; |
377 | 376 |
378 /** | 377 /** |
379 * Returns the length of this view, in bytes. | 378 * Returns the length of this view, in bytes. |
380 */ | 379 */ |
381 int get lengthInBytes; | 380 int get lengthInBytes; |
382 | 381 |
383 /** | 382 /** |
384 * Returns the byte buffer associated with this object. | 383 * Returns the byte buffer associated with this object. |
385 */ | 384 */ |
386 ByteBuffer get buffer; | 385 ByteBuffer get buffer; |
387 } | 386 } |
388 | 387 |
389 | |
390 /** | 388 /** |
391 * Describes endianness to be used when accessing or updating a | 389 * Describes endianness to be used when accessing or updating a |
392 * sequence of bytes. | 390 * sequence of bytes. |
393 */ | 391 */ |
394 class Endianness { | 392 class Endianness { |
395 const Endianness._(this._littleEndian); | 393 const Endianness._(this._littleEndian); |
396 | 394 |
397 static const Endianness BIG_ENDIAN = const Endianness._(false); | 395 static const Endianness BIG_ENDIAN = const Endianness._(false); |
398 static const Endianness LITTLE_ENDIAN = const Endianness._(true); | 396 static const Endianness LITTLE_ENDIAN = const Endianness._(true); |
399 static final Endianness HOST_ENDIAN = | 397 static final Endianness HOST_ENDIAN = |
400 (new ByteData.view(new Uint16List.fromList([1]).buffer)).getInt8(0) == 1 ? | 398 (new ByteData.view(new Uint16List.fromList([1]).buffer)).getInt8(0) == 1 |
401 LITTLE_ENDIAN : BIG_ENDIAN; | 399 ? LITTLE_ENDIAN |
| 400 : BIG_ENDIAN; |
402 | 401 |
403 final bool _littleEndian; | 402 final bool _littleEndian; |
404 } | 403 } |
405 | 404 |
406 | |
407 /** | 405 /** |
408 * A fixed-length, random-access sequence of bytes that also provides random | 406 * A fixed-length, random-access sequence of bytes that also provides random |
409 * and unaligned access to the fixed-width integers and floating point | 407 * and unaligned access to the fixed-width integers and floating point |
410 * numbers represented by those bytes. | 408 * numbers represented by those bytes. |
411 * | 409 * |
412 * `ByteData` may be used to pack and unpack data from external sources | 410 * `ByteData` may be used to pack and unpack data from external sources |
413 * (such as networks or files systems), and to process large quantities | 411 * (such as networks or files systems), and to process large quantities |
414 * of numerical data more efficiently than would be possible | 412 * of numerical data more efficiently than would be possible |
415 * with ordinary [List] implementations. | 413 * with ordinary [List] implementations. |
416 * `ByteData` can save space, by eliminating the need for object headers, | 414 * `ByteData` can save space, by eliminating the need for object headers, |
(...skipping 23 matching lines...) Expand all Loading... |
440 * If the [offsetInBytes] index of the region is not specified, | 438 * If the [offsetInBytes] index of the region is not specified, |
441 * it defaults to zero (the first byte in the byte buffer). | 439 * it defaults to zero (the first byte in the byte buffer). |
442 * If the length is not specified, it defaults to `null`, | 440 * If the length is not specified, it defaults to `null`, |
443 * which indicates that the view extends to the end of the byte buffer. | 441 * which indicates that the view extends to the end of the byte buffer. |
444 * | 442 * |
445 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 443 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
446 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 444 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
447 * the length of [buffer]. | 445 * the length of [buffer]. |
448 */ | 446 */ |
449 factory ByteData.view(ByteBuffer buffer, | 447 factory ByteData.view(ByteBuffer buffer, |
450 [int offsetInBytes = 0, int length]) { | 448 [int offsetInBytes = 0, int length]) { |
451 return buffer.asByteData(offsetInBytes, length); | 449 return buffer.asByteData(offsetInBytes, length); |
452 } | 450 } |
453 | 451 |
454 /** | 452 /** |
455 * Returns the (possibly negative) integer represented by the byte at the | 453 * Returns the (possibly negative) integer represented by the byte at the |
456 * specified [byteOffset] in this object, in two's complement binary | 454 * specified [byteOffset] in this object, in two's complement binary |
457 * representation. | 455 * representation. |
458 * | 456 * |
459 * The return value will be between -128 and 127, inclusive. | 457 * The return value will be between -128 and 127, inclusive. |
460 * | 458 * |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 * Sets the two bytes starting at the specified [byteOffset] in this | 513 * Sets the two bytes starting at the specified [byteOffset] in this |
516 * object to the two's complement binary representation of the specified | 514 * object to the two's complement binary representation of the specified |
517 * [value], which must fit in two bytes. | 515 * [value], which must fit in two bytes. |
518 * | 516 * |
519 * In other words, [value] must lie | 517 * In other words, [value] must lie |
520 * between 2<sup>15</sup> and 2<sup>15</sup> - 1, inclusive. | 518 * between 2<sup>15</sup> and 2<sup>15</sup> - 1, inclusive. |
521 * | 519 * |
522 * Throws [RangeError] if [byteOffset] is negative, or | 520 * Throws [RangeError] if [byteOffset] is negative, or |
523 * `byteOffset + 2` is greater than the length of this object. | 521 * `byteOffset + 2` is greater than the length of this object. |
524 */ | 522 */ |
525 void setInt16(int byteOffset, | 523 void setInt16(int byteOffset, int value, |
526 int value, | 524 [Endianness endian = Endianness.BIG_ENDIAN]); |
527 [Endianness endian = Endianness.BIG_ENDIAN]); | |
528 | 525 |
529 /** | 526 /** |
530 * Returns the positive integer represented by the two bytes starting | 527 * Returns the positive integer represented by the two bytes starting |
531 * at the specified [byteOffset] in this object, in unsigned binary | 528 * at the specified [byteOffset] in this object, in unsigned binary |
532 * form. | 529 * form. |
533 * | 530 * |
534 * The return value will be between 0 and 2<sup>16</sup> - 1, inclusive. | 531 * The return value will be between 0 and 2<sup>16</sup> - 1, inclusive. |
535 * | 532 * |
536 * Throws [RangeError] if [byteOffset] is negative, or | 533 * Throws [RangeError] if [byteOffset] is negative, or |
537 * `byteOffset + 2` is greater than the length of this object. | 534 * `byteOffset + 2` is greater than the length of this object. |
538 */ | 535 */ |
539 int getUint16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); | 536 int getUint16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); |
540 | 537 |
541 /** | 538 /** |
542 * Sets the two bytes starting at the specified [byteOffset] in this object | 539 * Sets the two bytes starting at the specified [byteOffset] in this object |
543 * to the unsigned binary representation of the specified [value], | 540 * to the unsigned binary representation of the specified [value], |
544 * which must fit in two bytes. | 541 * which must fit in two bytes. |
545 * | 542 * |
546 * In other words, [value] must be between | 543 * In other words, [value] must be between |
547 * 0 and 2<sup>16</sup> - 1, inclusive. | 544 * 0 and 2<sup>16</sup> - 1, inclusive. |
548 * | 545 * |
549 * Throws [RangeError] if [byteOffset] is negative, or | 546 * Throws [RangeError] if [byteOffset] is negative, or |
550 * `byteOffset + 2` is greater than the length of this object. | 547 * `byteOffset + 2` is greater than the length of this object. |
551 */ | 548 */ |
552 void setUint16(int byteOffset, | 549 void setUint16(int byteOffset, int value, |
553 int value, | 550 [Endianness endian = Endianness.BIG_ENDIAN]); |
554 [Endianness endian = Endianness.BIG_ENDIAN]); | |
555 | 551 |
556 /** | 552 /** |
557 * Returns the (possibly negative) integer represented by the four bytes at | 553 * Returns the (possibly negative) integer represented by the four bytes at |
558 * the specified [byteOffset] in this object, in two's complement binary | 554 * the specified [byteOffset] in this object, in two's complement binary |
559 * form. | 555 * form. |
560 * | 556 * |
561 * The return value will be between 2<sup>31</sup> and 2<sup>31</sup> - 1, | 557 * The return value will be between 2<sup>31</sup> and 2<sup>31</sup> - 1, |
562 * inclusive. | 558 * inclusive. |
563 * | 559 * |
564 * Throws [RangeError] if [byteOffset] is negative, or | 560 * Throws [RangeError] if [byteOffset] is negative, or |
565 * `byteOffset + 4` is greater than the length of this object. | 561 * `byteOffset + 4` is greater than the length of this object. |
566 */ | 562 */ |
567 int getInt32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); | 563 int getInt32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); |
568 | 564 |
569 /** | 565 /** |
570 * Sets the four bytes starting at the specified [byteOffset] in this | 566 * Sets the four bytes starting at the specified [byteOffset] in this |
571 * object to the two's complement binary representation of the specified | 567 * object to the two's complement binary representation of the specified |
572 * [value], which must fit in four bytes. | 568 * [value], which must fit in four bytes. |
573 * | 569 * |
574 * In other words, [value] must lie | 570 * In other words, [value] must lie |
575 * between 2<sup>31</sup> and 2<sup>31</sup> - 1, inclusive. | 571 * between 2<sup>31</sup> and 2<sup>31</sup> - 1, inclusive. |
576 * | 572 * |
577 * Throws [RangeError] if [byteOffset] is negative, or | 573 * Throws [RangeError] if [byteOffset] is negative, or |
578 * `byteOffset + 4` is greater than the length of this object. | 574 * `byteOffset + 4` is greater than the length of this object. |
579 */ | 575 */ |
580 void setInt32(int byteOffset, | 576 void setInt32(int byteOffset, int value, |
581 int value, | 577 [Endianness endian = Endianness.BIG_ENDIAN]); |
582 [Endianness endian = Endianness.BIG_ENDIAN]); | |
583 | 578 |
584 /** | 579 /** |
585 * Returns the positive integer represented by the four bytes starting | 580 * Returns the positive integer represented by the four bytes starting |
586 * at the specified [byteOffset] in this object, in unsigned binary | 581 * at the specified [byteOffset] in this object, in unsigned binary |
587 * form. | 582 * form. |
588 * | 583 * |
589 * The return value will be between 0 and 2<sup>32</sup> - 1, inclusive. | 584 * The return value will be between 0 and 2<sup>32</sup> - 1, inclusive. |
590 * | 585 * |
591 * Throws [RangeError] if [byteOffset] is negative, or | 586 * Throws [RangeError] if [byteOffset] is negative, or |
592 * `byteOffset + 4` is greater than the length of this object. | 587 * `byteOffset + 4` is greater than the length of this object. |
593 */ | 588 */ |
594 int getUint32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); | 589 int getUint32(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); |
595 | 590 |
596 /** | 591 /** |
597 * Sets the four bytes starting at the specified [byteOffset] in this object | 592 * Sets the four bytes starting at the specified [byteOffset] in this object |
598 * to the unsigned binary representation of the specified [value], | 593 * to the unsigned binary representation of the specified [value], |
599 * which must fit in four bytes. | 594 * which must fit in four bytes. |
600 * | 595 * |
601 * In other words, [value] must be between | 596 * In other words, [value] must be between |
602 * 0 and 2<sup>32</sup> - 1, inclusive. | 597 * 0 and 2<sup>32</sup> - 1, inclusive. |
603 * | 598 * |
604 * Throws [RangeError] if [byteOffset] is negative, or | 599 * Throws [RangeError] if [byteOffset] is negative, or |
605 * `byteOffset + 4` is greater than the length of this object. | 600 * `byteOffset + 4` is greater than the length of this object. |
606 */ | 601 */ |
607 void setUint32(int byteOffset, | 602 void setUint32(int byteOffset, int value, |
608 int value, | 603 [Endianness endian = Endianness.BIG_ENDIAN]); |
609 [Endianness endian = Endianness.BIG_ENDIAN]); | |
610 | 604 |
611 /** | 605 /** |
612 * Returns the (possibly negative) integer represented by the eight bytes at | 606 * Returns the (possibly negative) integer represented by the eight bytes at |
613 * the specified [byteOffset] in this object, in two's complement binary | 607 * the specified [byteOffset] in this object, in two's complement binary |
614 * form. | 608 * form. |
615 * | 609 * |
616 * The return value will be between 2<sup>63</sup> and 2<sup>63</sup> - 1, | 610 * The return value will be between 2<sup>63</sup> and 2<sup>63</sup> - 1, |
617 * inclusive. | 611 * inclusive. |
618 * | 612 * |
619 * Throws [RangeError] if [byteOffset] is negative, or | 613 * Throws [RangeError] if [byteOffset] is negative, or |
620 * `byteOffset + 8` is greater than the length of this object. | 614 * `byteOffset + 8` is greater than the length of this object. |
621 */ | 615 */ |
622 int getInt64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); | 616 int getInt64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); |
623 | 617 |
624 /** | 618 /** |
625 * Sets the eight bytes starting at the specified [byteOffset] in this | 619 * Sets the eight bytes starting at the specified [byteOffset] in this |
626 * object to the two's complement binary representation of the specified | 620 * object to the two's complement binary representation of the specified |
627 * [value], which must fit in eight bytes. | 621 * [value], which must fit in eight bytes. |
628 * | 622 * |
629 * In other words, [value] must lie | 623 * In other words, [value] must lie |
630 * between 2<sup>63</sup> and 2<sup>63</sup> - 1, inclusive. | 624 * between 2<sup>63</sup> and 2<sup>63</sup> - 1, inclusive. |
631 * | 625 * |
632 * Throws [RangeError] if [byteOffset] is negative, or | 626 * Throws [RangeError] if [byteOffset] is negative, or |
633 * `byteOffset + 8` is greater than the length of this object. | 627 * `byteOffset + 8` is greater than the length of this object. |
634 */ | 628 */ |
635 void setInt64(int byteOffset, | 629 void setInt64(int byteOffset, int value, |
636 int value, | 630 [Endianness endian = Endianness.BIG_ENDIAN]); |
637 [Endianness endian = Endianness.BIG_ENDIAN]); | |
638 | 631 |
639 /** | 632 /** |
640 * Returns the positive integer represented by the eight bytes starting | 633 * Returns the positive integer represented by the eight bytes starting |
641 * at the specified [byteOffset] in this object, in unsigned binary | 634 * at the specified [byteOffset] in this object, in unsigned binary |
642 * form. | 635 * form. |
643 * | 636 * |
644 * The return value will be between 0 and 2<sup>64</sup> - 1, inclusive. | 637 * The return value will be between 0 and 2<sup>64</sup> - 1, inclusive. |
645 * | 638 * |
646 * Throws [RangeError] if [byteOffset] is negative, or | 639 * Throws [RangeError] if [byteOffset] is negative, or |
647 * `byteOffset + 8` is greater than the length of this object. | 640 * `byteOffset + 8` is greater than the length of this object. |
648 */ | 641 */ |
649 int getUint64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); | 642 int getUint64(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); |
650 | 643 |
651 /** | 644 /** |
652 * Sets the eight bytes starting at the specified [byteOffset] in this object | 645 * Sets the eight bytes starting at the specified [byteOffset] in this object |
653 * to the unsigned binary representation of the specified [value], | 646 * to the unsigned binary representation of the specified [value], |
654 * which must fit in eight bytes. | 647 * which must fit in eight bytes. |
655 * | 648 * |
656 * In other words, [value] must be between | 649 * In other words, [value] must be between |
657 * 0 and 2<sup>64</sup> - 1, inclusive. | 650 * 0 and 2<sup>64</sup> - 1, inclusive. |
658 * | 651 * |
659 * Throws [RangeError] if [byteOffset] is negative, or | 652 * Throws [RangeError] if [byteOffset] is negative, or |
660 * `byteOffset + 8` is greater than the length of this object. | 653 * `byteOffset + 8` is greater than the length of this object. |
661 */ | 654 */ |
662 void setUint64(int byteOffset, | 655 void setUint64(int byteOffset, int value, |
663 int value, | 656 [Endianness endian = Endianness.BIG_ENDIAN]); |
664 [Endianness endian = Endianness.BIG_ENDIAN]); | |
665 | 657 |
666 /** | 658 /** |
667 * Returns the floating point number represented by the four bytes at | 659 * Returns the floating point number represented by the four bytes at |
668 * the specified [byteOffset] in this object, in IEEE 754 | 660 * the specified [byteOffset] in this object, in IEEE 754 |
669 * single-precision binary floating-point format (binary32). | 661 * single-precision binary floating-point format (binary32). |
670 * | 662 * |
671 * Throws [RangeError] if [byteOffset] is negative, or | 663 * Throws [RangeError] if [byteOffset] is negative, or |
672 * `byteOffset + 4` is greater than the length of this object. | 664 * `byteOffset + 4` is greater than the length of this object. |
673 */ | 665 */ |
674 double getFloat32(int byteOffset, | 666 double getFloat32(int byteOffset, |
675 [Endianness endian = Endianness.BIG_ENDIAN]); | 667 [Endianness endian = Endianness.BIG_ENDIAN]); |
676 | 668 |
677 /** | 669 /** |
678 * Sets the four bytes starting at the specified [byteOffset] in this | 670 * Sets the four bytes starting at the specified [byteOffset] in this |
679 * object to the IEEE 754 single-precision binary floating-point | 671 * object to the IEEE 754 single-precision binary floating-point |
680 * (binary32) representation of the specified [value]. | 672 * (binary32) representation of the specified [value]. |
681 * | 673 * |
682 * **Note that this method can lose precision.** The input [value] is | 674 * **Note that this method can lose precision.** The input [value] is |
683 * a 64-bit floating point value, which will be converted to 32-bit | 675 * a 64-bit floating point value, which will be converted to 32-bit |
684 * floating point value by IEEE 754 rounding rules before it is stored. | 676 * floating point value by IEEE 754 rounding rules before it is stored. |
685 * If [value] cannot be represented exactly as a binary32, it will be | 677 * If [value] cannot be represented exactly as a binary32, it will be |
686 * converted to the nearest binary32 value. If two binary32 values are | 678 * converted to the nearest binary32 value. If two binary32 values are |
687 * equally close, the one whose least significant bit is zero will be used. | 679 * equally close, the one whose least significant bit is zero will be used. |
688 * Note that finite (but large) values can be converted to infinity, and | 680 * Note that finite (but large) values can be converted to infinity, and |
689 * small non-zero values can be converted to zero. | 681 * small non-zero values can be converted to zero. |
690 * | 682 * |
691 * Throws [RangeError] if [byteOffset] is negative, or | 683 * Throws [RangeError] if [byteOffset] is negative, or |
692 * `byteOffset + 4` is greater than the length of this object. | 684 * `byteOffset + 4` is greater than the length of this object. |
693 */ | 685 */ |
694 void setFloat32(int byteOffset, | 686 void setFloat32(int byteOffset, double value, |
695 double value, | 687 [Endianness endian = Endianness.BIG_ENDIAN]); |
696 [Endianness endian = Endianness.BIG_ENDIAN]); | |
697 | 688 |
698 /** | 689 /** |
699 * Returns the floating point number represented by the eight bytes at | 690 * Returns the floating point number represented by the eight bytes at |
700 * the specified [byteOffset] in this object, in IEEE 754 | 691 * the specified [byteOffset] in this object, in IEEE 754 |
701 * double-precision binary floating-point format (binary64). | 692 * double-precision binary floating-point format (binary64). |
702 * | 693 * |
703 * Throws [RangeError] if [byteOffset] is negative, or | 694 * Throws [RangeError] if [byteOffset] is negative, or |
704 * `byteOffset + 8` is greater than the length of this object. | 695 * `byteOffset + 8` is greater than the length of this object. |
705 */ | 696 */ |
706 double getFloat64(int byteOffset, | 697 double getFloat64(int byteOffset, |
707 [Endianness endian = Endianness.BIG_ENDIAN]); | 698 [Endianness endian = Endianness.BIG_ENDIAN]); |
708 | 699 |
709 /** | 700 /** |
710 * Sets the eight bytes starting at the specified [byteOffset] in this | 701 * Sets the eight bytes starting at the specified [byteOffset] in this |
711 * object to the IEEE 754 double-precision binary floating-point | 702 * object to the IEEE 754 double-precision binary floating-point |
712 * (binary64) representation of the specified [value]. | 703 * (binary64) representation of the specified [value]. |
713 * | 704 * |
714 * Throws [RangeError] if [byteOffset] is negative, or | 705 * Throws [RangeError] if [byteOffset] is negative, or |
715 * `byteOffset + 8` is greater than the length of this object. | 706 * `byteOffset + 8` is greater than the length of this object. |
716 */ | 707 */ |
717 void setFloat64(int byteOffset, | 708 void setFloat64(int byteOffset, double value, |
718 double value, | 709 [Endianness endian = Endianness.BIG_ENDIAN]); |
719 [Endianness endian = Endianness.BIG_ENDIAN]); | |
720 } | 710 } |
721 | 711 |
722 | |
723 /** | 712 /** |
724 * A fixed-length list of 8-bit signed integers. | 713 * A fixed-length list of 8-bit signed integers. |
725 * | 714 * |
726 * For long lists, this implementation can be considerably | 715 * For long lists, this implementation can be considerably |
727 * more space- and time-efficient than the default [List] implementation. | 716 * more space- and time-efficient than the default [List] implementation. |
728 * | 717 * |
729 * Integers stored in the list are truncated to their low eight bits, | 718 * Integers stored in the list are truncated to their low eight bits, |
730 * interpreted as a signed 8-bit two's complement integer with values in the | 719 * interpreted as a signed 8-bit two's complement integer with values in the |
731 * range -128 to +127. | 720 * range -128 to +127. |
732 */ | 721 */ |
(...skipping 21 matching lines...) Expand all Loading... |
754 * If the [offsetInBytes] index of the region is not specified, | 743 * If the [offsetInBytes] index of the region is not specified, |
755 * it defaults to zero (the first byte in the byte buffer). | 744 * it defaults to zero (the first byte in the byte buffer). |
756 * If the length is not specified, it defaults to `null`, | 745 * If the length is not specified, it defaults to `null`, |
757 * which indicates that the view extends to the end of the byte buffer. | 746 * which indicates that the view extends to the end of the byte buffer. |
758 * | 747 * |
759 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 748 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
760 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 749 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
761 * the length of [buffer]. | 750 * the length of [buffer]. |
762 */ | 751 */ |
763 factory Int8List.view(ByteBuffer buffer, | 752 factory Int8List.view(ByteBuffer buffer, |
764 [int offsetInBytes = 0, int length]) { | 753 [int offsetInBytes = 0, int length]) { |
765 return buffer.asInt8List(offsetInBytes, length); | 754 return buffer.asInt8List(offsetInBytes, length); |
766 } | 755 } |
767 | 756 |
768 static const int BYTES_PER_ELEMENT = 1; | 757 static const int BYTES_PER_ELEMENT = 1; |
769 } | 758 } |
770 | 759 |
771 | |
772 /** | 760 /** |
773 * A fixed-length list of 8-bit unsigned integers. | 761 * A fixed-length list of 8-bit unsigned integers. |
774 * | 762 * |
775 * For long lists, this implementation can be considerably | 763 * For long lists, this implementation can be considerably |
776 * more space- and time-efficient than the default [List] implementation. | 764 * more space- and time-efficient than the default [List] implementation. |
777 * | 765 * |
778 * Integers stored in the list are truncated to their low eight bits, | 766 * Integers stored in the list are truncated to their low eight bits, |
779 * interpreted as an unsigned 8-bit integer with values in the | 767 * interpreted as an unsigned 8-bit integer with values in the |
780 * range 0 to 255. | 768 * range 0 to 255. |
781 */ | 769 */ |
(...skipping 21 matching lines...) Expand all Loading... |
803 * If the [offsetInBytes] index of the region is not specified, | 791 * If the [offsetInBytes] index of the region is not specified, |
804 * it defaults to zero (the first byte in the byte buffer). | 792 * it defaults to zero (the first byte in the byte buffer). |
805 * If the length is not specified, it defaults to `null`, | 793 * If the length is not specified, it defaults to `null`, |
806 * which indicates that the view extends to the end of the byte buffer. | 794 * which indicates that the view extends to the end of the byte buffer. |
807 * | 795 * |
808 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 796 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
809 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 797 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
810 * the length of [buffer]. | 798 * the length of [buffer]. |
811 */ | 799 */ |
812 factory Uint8List.view(ByteBuffer buffer, | 800 factory Uint8List.view(ByteBuffer buffer, |
813 [int offsetInBytes = 0, int length]) { | 801 [int offsetInBytes = 0, int length]) { |
814 return buffer.asUint8List(offsetInBytes, length); | 802 return buffer.asUint8List(offsetInBytes, length); |
815 } | 803 } |
816 | 804 |
817 static const int BYTES_PER_ELEMENT = 1; | 805 static const int BYTES_PER_ELEMENT = 1; |
818 } | 806 } |
819 | 807 |
820 | |
821 /** | 808 /** |
822 * A fixed-length list of 8-bit unsigned integers. | 809 * A fixed-length list of 8-bit unsigned integers. |
823 * | 810 * |
824 * For long lists, this implementation can be considerably | 811 * For long lists, this implementation can be considerably |
825 * more space- and time-efficient than the default [List] implementation. | 812 * more space- and time-efficient than the default [List] implementation. |
826 * | 813 * |
827 * Integers stored in the list are clamped to an unsigned eight bit value. | 814 * Integers stored in the list are clamped to an unsigned eight bit value. |
828 * That is, all values below zero are stored as zero | 815 * That is, all values below zero are stored as zero |
829 * and all values above 255 are stored as 255. | 816 * and all values above 255 are stored as 255. |
830 */ | 817 */ |
(...skipping 22 matching lines...) Expand all Loading... |
853 * If the [offsetInBytes] index of the region is not specified, | 840 * If the [offsetInBytes] index of the region is not specified, |
854 * it defaults to zero (the first byte in the byte buffer). | 841 * it defaults to zero (the first byte in the byte buffer). |
855 * If the length is not specified, it defaults to `null`, | 842 * If the length is not specified, it defaults to `null`, |
856 * which indicates that the view extends to the end of the byte buffer. | 843 * which indicates that the view extends to the end of the byte buffer. |
857 * | 844 * |
858 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 845 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
859 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 846 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
860 * the length of [buffer]. | 847 * the length of [buffer]. |
861 */ | 848 */ |
862 factory Uint8ClampedList.view(ByteBuffer buffer, | 849 factory Uint8ClampedList.view(ByteBuffer buffer, |
863 [int offsetInBytes = 0, int length]) { | 850 [int offsetInBytes = 0, int length]) { |
864 return buffer.asUint8ClampedList(offsetInBytes, length); | 851 return buffer.asUint8ClampedList(offsetInBytes, length); |
865 } | 852 } |
866 | 853 |
867 static const int BYTES_PER_ELEMENT = 1; | 854 static const int BYTES_PER_ELEMENT = 1; |
868 } | 855 } |
869 | 856 |
870 | |
871 /** | 857 /** |
872 * A fixed-length list of 16-bit signed integers that is viewable as a | 858 * A fixed-length list of 16-bit signed integers that is viewable as a |
873 * [TypedData]. | 859 * [TypedData]. |
874 * | 860 * |
875 * For long lists, this implementation can be considerably | 861 * For long lists, this implementation can be considerably |
876 * more space- and time-efficient than the default [List] implementation. | 862 * more space- and time-efficient than the default [List] implementation. |
877 * | 863 * |
878 * Integers stored in the list are truncated to their low 16 bits, | 864 * Integers stored in the list are truncated to their low 16 bits, |
879 * interpreted as a signed 16-bit two's complement integer with values in the | 865 * interpreted as a signed 16-bit two's complement integer with values in the |
880 * range -32768 to +32767. | 866 * range -32768 to +32767. |
(...skipping 25 matching lines...) Expand all Loading... |
906 * which indicates that the view extends to the end of the byte buffer. | 892 * which indicates that the view extends to the end of the byte buffer. |
907 * | 893 * |
908 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 894 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
909 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 895 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
910 * the length of [buffer]. | 896 * the length of [buffer]. |
911 * | 897 * |
912 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 898 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
913 * [BYTES_PER_ELEMENT]. | 899 * [BYTES_PER_ELEMENT]. |
914 */ | 900 */ |
915 factory Int16List.view(ByteBuffer buffer, | 901 factory Int16List.view(ByteBuffer buffer, |
916 [int offsetInBytes = 0, int length]) { | 902 [int offsetInBytes = 0, int length]) { |
917 return buffer.asInt16List(offsetInBytes, length); | 903 return buffer.asInt16List(offsetInBytes, length); |
918 } | 904 } |
919 | 905 |
920 static const int BYTES_PER_ELEMENT = 2; | 906 static const int BYTES_PER_ELEMENT = 2; |
921 } | 907 } |
922 | 908 |
923 | |
924 /** | 909 /** |
925 * A fixed-length list of 16-bit unsigned integers that is viewable as a | 910 * A fixed-length list of 16-bit unsigned integers that is viewable as a |
926 * [TypedData]. | 911 * [TypedData]. |
927 * | 912 * |
928 * For long lists, this implementation can be considerably | 913 * For long lists, this implementation can be considerably |
929 * more space- and time-efficient than the default [List] implementation. | 914 * more space- and time-efficient than the default [List] implementation. |
930 * | 915 * |
931 * Integers stored in the list are truncated to their low 16 bits, | 916 * Integers stored in the list are truncated to their low 16 bits, |
932 * interpreted as an unsigned 16-bit integer with values in the | 917 * interpreted as an unsigned 16-bit integer with values in the |
933 * range 0 to 65536. | 918 * range 0 to 65536. |
(...skipping 26 matching lines...) Expand all Loading... |
960 * which indicates that the view extends to the end of the byte buffer. | 945 * which indicates that the view extends to the end of the byte buffer. |
961 * | 946 * |
962 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 947 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
963 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 948 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
964 * the length of [buffer]. | 949 * the length of [buffer]. |
965 * | 950 * |
966 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 951 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
967 * [BYTES_PER_ELEMENT]. | 952 * [BYTES_PER_ELEMENT]. |
968 */ | 953 */ |
969 factory Uint16List.view(ByteBuffer buffer, | 954 factory Uint16List.view(ByteBuffer buffer, |
970 [int offsetInBytes = 0, int length]) { | 955 [int offsetInBytes = 0, int length]) { |
971 return buffer.asUint16List(offsetInBytes, length); | 956 return buffer.asUint16List(offsetInBytes, length); |
972 } | 957 } |
973 | 958 |
974 static const int BYTES_PER_ELEMENT = 2; | 959 static const int BYTES_PER_ELEMENT = 2; |
975 } | 960 } |
976 | 961 |
977 | |
978 /** | 962 /** |
979 * A fixed-length list of 32-bit signed integers that is viewable as a | 963 * A fixed-length list of 32-bit signed integers that is viewable as a |
980 * [TypedData]. | 964 * [TypedData]. |
981 * | 965 * |
982 * For long lists, this implementation can be considerably | 966 * For long lists, this implementation can be considerably |
983 * more space- and time-efficient than the default [List] implementation. | 967 * more space- and time-efficient than the default [List] implementation. |
984 * | 968 * |
985 * Integers stored in the list are truncated to their low 32 bits, | 969 * Integers stored in the list are truncated to their low 32 bits, |
986 * interpreted as a signed 32-bit two's complement integer with values in the | 970 * interpreted as a signed 32-bit two's complement integer with values in the |
987 * range -2147483648 to 2147483647. | 971 * range -2147483648 to 2147483647. |
(...skipping 25 matching lines...) Expand all Loading... |
1013 * which indicates that the view extends to the end of the byte buffer. | 997 * which indicates that the view extends to the end of the byte buffer. |
1014 * | 998 * |
1015 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 999 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1016 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1000 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1017 * the length of [buffer]. | 1001 * the length of [buffer]. |
1018 * | 1002 * |
1019 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1003 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1020 * [BYTES_PER_ELEMENT]. | 1004 * [BYTES_PER_ELEMENT]. |
1021 */ | 1005 */ |
1022 factory Int32List.view(ByteBuffer buffer, | 1006 factory Int32List.view(ByteBuffer buffer, |
1023 [int offsetInBytes = 0, int length]) { | 1007 [int offsetInBytes = 0, int length]) { |
1024 return buffer.asInt32List(offsetInBytes, length); | 1008 return buffer.asInt32List(offsetInBytes, length); |
1025 } | 1009 } |
1026 | 1010 |
1027 static const int BYTES_PER_ELEMENT = 4; | 1011 static const int BYTES_PER_ELEMENT = 4; |
1028 } | 1012 } |
1029 | 1013 |
1030 | |
1031 /** | 1014 /** |
1032 * A fixed-length list of 32-bit unsigned integers that is viewable as a | 1015 * A fixed-length list of 32-bit unsigned integers that is viewable as a |
1033 * [TypedData]. | 1016 * [TypedData]. |
1034 * | 1017 * |
1035 * For long lists, this implementation can be considerably | 1018 * For long lists, this implementation can be considerably |
1036 * more space- and time-efficient than the default [List] implementation. | 1019 * more space- and time-efficient than the default [List] implementation. |
1037 * | 1020 * |
1038 * Integers stored in the list are truncated to their low 32 bits, | 1021 * Integers stored in the list are truncated to their low 32 bits, |
1039 * interpreted as an unsigned 32-bit integer with values in the | 1022 * interpreted as an unsigned 32-bit integer with values in the |
1040 * range 0 to 4294967295. | 1023 * range 0 to 4294967295. |
(...skipping 26 matching lines...) Expand all Loading... |
1067 * which indicates that the view extends to the end of the byte buffer. | 1050 * which indicates that the view extends to the end of the byte buffer. |
1068 * | 1051 * |
1069 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 1052 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1070 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1053 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1071 * the length of [buffer]. | 1054 * the length of [buffer]. |
1072 * | 1055 * |
1073 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1056 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1074 * [BYTES_PER_ELEMENT]. | 1057 * [BYTES_PER_ELEMENT]. |
1075 */ | 1058 */ |
1076 factory Uint32List.view(ByteBuffer buffer, | 1059 factory Uint32List.view(ByteBuffer buffer, |
1077 [int offsetInBytes = 0, int length]) { | 1060 [int offsetInBytes = 0, int length]) { |
1078 return buffer.asUint32List(offsetInBytes, length); | 1061 return buffer.asUint32List(offsetInBytes, length); |
1079 } | 1062 } |
1080 | 1063 |
1081 static const int BYTES_PER_ELEMENT = 4; | 1064 static const int BYTES_PER_ELEMENT = 4; |
1082 } | 1065 } |
1083 | 1066 |
1084 | |
1085 /** | 1067 /** |
1086 * A fixed-length list of 64-bit signed integers that is viewable as a | 1068 * A fixed-length list of 64-bit signed integers that is viewable as a |
1087 * [TypedData]. | 1069 * [TypedData]. |
1088 * | 1070 * |
1089 * For long lists, this implementation can be considerably | 1071 * For long lists, this implementation can be considerably |
1090 * more space- and time-efficient than the default [List] implementation. | 1072 * more space- and time-efficient than the default [List] implementation. |
1091 * | 1073 * |
1092 * Integers stored in the list are truncated to their low 64 bits, | 1074 * Integers stored in the list are truncated to their low 64 bits, |
1093 * interpreted as a signed 64-bit two's complement integer with values in the | 1075 * interpreted as a signed 64-bit two's complement integer with values in the |
1094 * range -9223372036854775808 to +9223372036854775807. | 1076 * range -9223372036854775808 to +9223372036854775807. |
(...skipping 25 matching lines...) Expand all Loading... |
1120 * which indicates that the view extends to the end of the byte buffer. | 1102 * which indicates that the view extends to the end of the byte buffer. |
1121 * | 1103 * |
1122 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 1104 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1123 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1105 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1124 * the length of [buffer]. | 1106 * the length of [buffer]. |
1125 * | 1107 * |
1126 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1108 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1127 * [BYTES_PER_ELEMENT]. | 1109 * [BYTES_PER_ELEMENT]. |
1128 */ | 1110 */ |
1129 factory Int64List.view(ByteBuffer buffer, | 1111 factory Int64List.view(ByteBuffer buffer, |
1130 [int offsetInBytes = 0, int length]) { | 1112 [int offsetInBytes = 0, int length]) { |
1131 return buffer.asInt64List(offsetInBytes, length); | 1113 return buffer.asInt64List(offsetInBytes, length); |
1132 } | 1114 } |
1133 | 1115 |
1134 static const int BYTES_PER_ELEMENT = 8; | 1116 static const int BYTES_PER_ELEMENT = 8; |
1135 } | 1117 } |
1136 | 1118 |
1137 | |
1138 /** | 1119 /** |
1139 * A fixed-length list of 64-bit unsigned integers that is viewable as a | 1120 * A fixed-length list of 64-bit unsigned integers that is viewable as a |
1140 * [TypedData]. | 1121 * [TypedData]. |
1141 * | 1122 * |
1142 * For long lists, this implementation can be considerably | 1123 * For long lists, this implementation can be considerably |
1143 * more space- and time-efficient than the default [List] implementation. | 1124 * more space- and time-efficient than the default [List] implementation. |
1144 * | 1125 * |
1145 * Integers stored in the list are truncated to their low 64 bits, | 1126 * Integers stored in the list are truncated to their low 64 bits, |
1146 * interpreted as an unsigned 64-bit integer with values in the | 1127 * interpreted as an unsigned 64-bit integer with values in the |
1147 * range 0 to 18446744073709551616. | 1128 * range 0 to 18446744073709551616. |
(...skipping 26 matching lines...) Expand all Loading... |
1174 * which indicates that the view extends to the end of the byte buffer. | 1155 * which indicates that the view extends to the end of the byte buffer. |
1175 * | 1156 * |
1176 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 1157 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1177 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1158 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1178 * the length of [buffer]. | 1159 * the length of [buffer]. |
1179 * | 1160 * |
1180 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1161 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1181 * [BYTES_PER_ELEMENT]. | 1162 * [BYTES_PER_ELEMENT]. |
1182 */ | 1163 */ |
1183 factory Uint64List.view(ByteBuffer buffer, | 1164 factory Uint64List.view(ByteBuffer buffer, |
1184 [int offsetInBytes = 0, int length]) { | 1165 [int offsetInBytes = 0, int length]) { |
1185 return buffer.asUint64List(offsetInBytes, length); | 1166 return buffer.asUint64List(offsetInBytes, length); |
1186 } | 1167 } |
1187 | 1168 |
1188 static const int BYTES_PER_ELEMENT = 8; | 1169 static const int BYTES_PER_ELEMENT = 8; |
1189 } | 1170 } |
1190 | 1171 |
1191 | |
1192 /** | 1172 /** |
1193 * A fixed-length list of IEEE 754 single-precision binary floating-point | 1173 * A fixed-length list of IEEE 754 single-precision binary floating-point |
1194 * numbers that is viewable as a [TypedData]. | 1174 * numbers that is viewable as a [TypedData]. |
1195 * | 1175 * |
1196 * For long lists, this | 1176 * For long lists, this |
1197 * implementation can be considerably more space- and time-efficient than | 1177 * implementation can be considerably more space- and time-efficient than |
1198 * the default [List] implementation. | 1178 * the default [List] implementation. |
1199 * | 1179 * |
1200 * Double values stored in the list are converted to the nearest | 1180 * Double values stored in the list are converted to the nearest |
1201 * single-precision value. Values read are converted to a double | 1181 * single-precision value. Values read are converted to a double |
(...skipping 26 matching lines...) Expand all Loading... |
1228 * which indicates that the view extends to the end of the byte buffer. | 1208 * which indicates that the view extends to the end of the byte buffer. |
1229 * | 1209 * |
1230 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 1210 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1231 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1211 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1232 * the length of [buffer]. | 1212 * the length of [buffer]. |
1233 * | 1213 * |
1234 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1214 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1235 * [BYTES_PER_ELEMENT]. | 1215 * [BYTES_PER_ELEMENT]. |
1236 */ | 1216 */ |
1237 factory Float32List.view(ByteBuffer buffer, | 1217 factory Float32List.view(ByteBuffer buffer, |
1238 [int offsetInBytes = 0, int length]) { | 1218 [int offsetInBytes = 0, int length]) { |
1239 return buffer.asFloat32List(offsetInBytes, length); | 1219 return buffer.asFloat32List(offsetInBytes, length); |
1240 } | 1220 } |
1241 | 1221 |
1242 static const int BYTES_PER_ELEMENT = 4; | 1222 static const int BYTES_PER_ELEMENT = 4; |
1243 } | 1223 } |
1244 | 1224 |
1245 | |
1246 /** | 1225 /** |
1247 * A fixed-length list of IEEE 754 double-precision binary floating-point | 1226 * A fixed-length list of IEEE 754 double-precision binary floating-point |
1248 * numbers that is viewable as a [TypedData]. | 1227 * numbers that is viewable as a [TypedData]. |
1249 * | 1228 * |
1250 * For long lists, this | 1229 * For long lists, this |
1251 * implementation can be considerably more space- and time-efficient than | 1230 * implementation can be considerably more space- and time-efficient than |
1252 * the default [List] implementation. | 1231 * the default [List] implementation. |
1253 */ | 1232 */ |
1254 abstract class Float64List implements List<double>, TypedData { | 1233 abstract class Float64List implements List<double>, TypedData { |
1255 /** | 1234 /** |
(...skipping 19 matching lines...) Expand all Loading... |
1275 * which indicates that the view extends to the end of the byte buffer. | 1254 * which indicates that the view extends to the end of the byte buffer. |
1276 * | 1255 * |
1277 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 1256 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1278 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1257 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1279 * the length of [buffer]. | 1258 * the length of [buffer]. |
1280 * | 1259 * |
1281 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1260 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1282 * [BYTES_PER_ELEMENT]. | 1261 * [BYTES_PER_ELEMENT]. |
1283 */ | 1262 */ |
1284 factory Float64List.view(ByteBuffer buffer, | 1263 factory Float64List.view(ByteBuffer buffer, |
1285 [int offsetInBytes = 0, int length]) { | 1264 [int offsetInBytes = 0, int length]) { |
1286 return buffer.asFloat64List(offsetInBytes, length); | 1265 return buffer.asFloat64List(offsetInBytes, length); |
1287 } | 1266 } |
1288 | 1267 |
1289 static const int BYTES_PER_ELEMENT = 8; | 1268 static const int BYTES_PER_ELEMENT = 8; |
1290 } | 1269 } |
1291 | 1270 |
1292 | |
1293 /** | 1271 /** |
1294 * A fixed-length list of Float32x4 numbers that is viewable as a | 1272 * A fixed-length list of Float32x4 numbers that is viewable as a |
1295 * [TypedData]. | 1273 * [TypedData]. |
1296 * | 1274 * |
1297 * For long lists, this implementation will be considerably more | 1275 * For long lists, this implementation will be considerably more |
1298 * space- and time-efficient than the default [List] implementation. | 1276 * space- and time-efficient than the default [List] implementation. |
1299 */ | 1277 */ |
1300 abstract class Float32x4List implements List<Float32x4>, TypedData { | 1278 abstract class Float32x4List implements List<Float32x4>, TypedData { |
1301 /** | 1279 /** |
1302 * Creates a [Float32x4List] of the specified length (in elements), | 1280 * Creates a [Float32x4List] of the specified length (in elements), |
(...skipping 18 matching lines...) Expand all Loading... |
1321 * which indicates that the view extends to the end of the byte buffer. | 1299 * which indicates that the view extends to the end of the byte buffer. |
1322 * | 1300 * |
1323 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 1301 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1324 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1302 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1325 * the length of [buffer]. | 1303 * the length of [buffer]. |
1326 * | 1304 * |
1327 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1305 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1328 * [BYTES_PER_ELEMENT]. | 1306 * [BYTES_PER_ELEMENT]. |
1329 */ | 1307 */ |
1330 factory Float32x4List.view(ByteBuffer buffer, | 1308 factory Float32x4List.view(ByteBuffer buffer, |
1331 [int offsetInBytes = 0, int length]) { | 1309 [int offsetInBytes = 0, int length]) { |
1332 return buffer.asFloat32x4List(offsetInBytes, length); | 1310 return buffer.asFloat32x4List(offsetInBytes, length); |
1333 } | 1311 } |
1334 | 1312 |
1335 static const int BYTES_PER_ELEMENT = 16; | 1313 static const int BYTES_PER_ELEMENT = 16; |
1336 } | 1314 } |
1337 | 1315 |
1338 | |
1339 /** | 1316 /** |
1340 * A fixed-length list of Int32x4 numbers that is viewable as a | 1317 * A fixed-length list of Int32x4 numbers that is viewable as a |
1341 * [TypedData]. | 1318 * [TypedData]. |
1342 * | 1319 * |
1343 * For long lists, this implementation will be considerably more | 1320 * For long lists, this implementation will be considerably more |
1344 * space- and time-efficient than the default [List] implementation. | 1321 * space- and time-efficient than the default [List] implementation. |
1345 */ | 1322 */ |
1346 abstract class Int32x4List implements List<Int32x4>, TypedData { | 1323 abstract class Int32x4List implements List<Int32x4>, TypedData { |
1347 /** | 1324 /** |
1348 * Creates a [Int32x4List] of the specified length (in elements), | 1325 * Creates a [Int32x4List] of the specified length (in elements), |
(...skipping 18 matching lines...) Expand all Loading... |
1367 * which indicates that the view extends to the end of the byte buffer. | 1344 * which indicates that the view extends to the end of the byte buffer. |
1368 * | 1345 * |
1369 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 1346 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1370 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1347 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1371 * the length of [buffer]. | 1348 * the length of [buffer]. |
1372 * | 1349 * |
1373 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1350 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1374 * [BYTES_PER_ELEMENT]. | 1351 * [BYTES_PER_ELEMENT]. |
1375 */ | 1352 */ |
1376 factory Int32x4List.view(ByteBuffer buffer, | 1353 factory Int32x4List.view(ByteBuffer buffer, |
1377 [int offsetInBytes = 0, int length]) { | 1354 [int offsetInBytes = 0, int length]) { |
1378 return buffer.asInt32x4List(offsetInBytes, length); | 1355 return buffer.asInt32x4List(offsetInBytes, length); |
1379 } | 1356 } |
1380 | 1357 |
1381 static const int BYTES_PER_ELEMENT = 16; | 1358 static const int BYTES_PER_ELEMENT = 16; |
1382 } | 1359 } |
1383 | 1360 |
1384 | |
1385 /** | 1361 /** |
1386 * A fixed-length list of Float64x2 numbers that is viewable as a | 1362 * A fixed-length list of Float64x2 numbers that is viewable as a |
1387 * [TypedData]. | 1363 * [TypedData]. |
1388 * | 1364 * |
1389 * For long lists, this implementation will be considerably more | 1365 * For long lists, this implementation will be considerably more |
1390 * space- and time-efficient than the default [List] implementation. | 1366 * space- and time-efficient than the default [List] implementation. |
1391 */ | 1367 */ |
1392 abstract class Float64x2List implements List<Float64x2>, TypedData { | 1368 abstract class Float64x2List implements List<Float64x2>, TypedData { |
1393 /** | 1369 /** |
1394 * Creates a [Float64x2List] of the specified length (in elements), | 1370 * Creates a [Float64x2List] of the specified length (in elements), |
(...skipping 18 matching lines...) Expand all Loading... |
1413 * which indicates that the view extends to the end of the byte buffer. | 1389 * which indicates that the view extends to the end of the byte buffer. |
1414 * | 1390 * |
1415 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or | 1391 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or |
1416 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than | 1392 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than |
1417 * the length of [buffer]. | 1393 * the length of [buffer]. |
1418 * | 1394 * |
1419 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of | 1395 * Throws [ArgumentError] if [offsetInBytes] is not a multiple of |
1420 * [BYTES_PER_ELEMENT]. | 1396 * [BYTES_PER_ELEMENT]. |
1421 */ | 1397 */ |
1422 factory Float64x2List.view(ByteBuffer buffer, | 1398 factory Float64x2List.view(ByteBuffer buffer, |
1423 [int offsetInBytes = 0, int length]) { | 1399 [int offsetInBytes = 0, int length]) { |
1424 return buffer.asFloat64x2List(offsetInBytes, length); | 1400 return buffer.asFloat64x2List(offsetInBytes, length); |
1425 } | 1401 } |
1426 | 1402 |
1427 static const int BYTES_PER_ELEMENT = 16; | 1403 static const int BYTES_PER_ELEMENT = 16; |
1428 } | 1404 } |
1429 | 1405 |
1430 | |
1431 /** | 1406 /** |
1432 * Float32x4 immutable value type and operations. | 1407 * Float32x4 immutable value type and operations. |
1433 * | 1408 * |
1434 * Float32x4 stores 4 32-bit floating point values in "lanes". | 1409 * Float32x4 stores 4 32-bit floating point values in "lanes". |
1435 * The lanes are "x", "y", "z", and "w" respectively. | 1410 * The lanes are "x", "y", "z", and "w" respectively. |
1436 */ | 1411 */ |
1437 abstract class Float32x4 { | 1412 abstract class Float32x4 { |
1438 external factory Float32x4(double x, double y, double z, double w); | 1413 external factory Float32x4(double x, double y, double z, double w); |
1439 external factory Float32x4.splat(double v); | 1414 external factory Float32x4.splat(double v); |
1440 external factory Float32x4.zero(); | 1415 external factory Float32x4.zero(); |
1441 external factory Float32x4.fromInt32x4Bits(Int32x4 x); | 1416 external factory Float32x4.fromInt32x4Bits(Int32x4 x); |
| 1417 |
1442 /// Sets the x and y lanes to their respective values in [v] and sets the z | 1418 /// Sets the x and y lanes to their respective values in [v] and sets the z |
1443 /// and w lanes to 0.0. | 1419 /// and w lanes to 0.0. |
1444 external factory Float32x4.fromFloat64x2(Float64x2 v); | 1420 external factory Float32x4.fromFloat64x2(Float64x2 v); |
1445 | 1421 |
1446 /// Addition operator. | 1422 /// Addition operator. |
1447 Float32x4 operator+(Float32x4 other); | 1423 Float32x4 operator +(Float32x4 other); |
| 1424 |
1448 /// Negate operator. | 1425 /// Negate operator. |
1449 Float32x4 operator-(); | 1426 Float32x4 operator -(); |
| 1427 |
1450 /// Subtraction operator. | 1428 /// Subtraction operator. |
1451 Float32x4 operator-(Float32x4 other); | 1429 Float32x4 operator -(Float32x4 other); |
| 1430 |
1452 /// Multiplication operator. | 1431 /// Multiplication operator. |
1453 Float32x4 operator*(Float32x4 other); | 1432 Float32x4 operator *(Float32x4 other); |
| 1433 |
1454 /// Division operator. | 1434 /// Division operator. |
1455 Float32x4 operator/(Float32x4 other); | 1435 Float32x4 operator /(Float32x4 other); |
1456 | 1436 |
1457 /// Relational less than. | 1437 /// Relational less than. |
1458 Int32x4 lessThan(Float32x4 other); | 1438 Int32x4 lessThan(Float32x4 other); |
| 1439 |
1459 /// Relational less than or equal. | 1440 /// Relational less than or equal. |
1460 Int32x4 lessThanOrEqual(Float32x4 other); | 1441 Int32x4 lessThanOrEqual(Float32x4 other); |
| 1442 |
1461 /// Relational greater than. | 1443 /// Relational greater than. |
1462 Int32x4 greaterThan(Float32x4 other); | 1444 Int32x4 greaterThan(Float32x4 other); |
| 1445 |
1463 /// Relational greater than or equal. | 1446 /// Relational greater than or equal. |
1464 Int32x4 greaterThanOrEqual(Float32x4 other); | 1447 Int32x4 greaterThanOrEqual(Float32x4 other); |
| 1448 |
1465 /// Relational equal. | 1449 /// Relational equal. |
1466 Int32x4 equal(Float32x4 other); | 1450 Int32x4 equal(Float32x4 other); |
| 1451 |
1467 /// Relational not-equal. | 1452 /// Relational not-equal. |
1468 Int32x4 notEqual(Float32x4 other); | 1453 Int32x4 notEqual(Float32x4 other); |
1469 | 1454 |
1470 /// Returns a copy of [this] each lane being scaled by [s]. | 1455 /// Returns a copy of [this] each lane being scaled by [s]. |
1471 /// Equivalent to this * new Float32x4.splat(s) | 1456 /// Equivalent to this * new Float32x4.splat(s) |
1472 Float32x4 scale(double s); | 1457 Float32x4 scale(double s); |
| 1458 |
1473 /// Returns the lane-wise absolute value of this [Float32x4]. | 1459 /// Returns the lane-wise absolute value of this [Float32x4]. |
1474 Float32x4 abs(); | 1460 Float32x4 abs(); |
| 1461 |
1475 /// Lane-wise clamp [this] to be in the range [lowerLimit]-[upperLimit]. | 1462 /// Lane-wise clamp [this] to be in the range [lowerLimit]-[upperLimit]. |
1476 Float32x4 clamp(Float32x4 lowerLimit, Float32x4 upperLimit); | 1463 Float32x4 clamp(Float32x4 lowerLimit, Float32x4 upperLimit); |
1477 | 1464 |
1478 /// Extracted x value. | 1465 /// Extracted x value. |
1479 double get x; | 1466 double get x; |
| 1467 |
1480 /// Extracted y value. | 1468 /// Extracted y value. |
1481 double get y; | 1469 double get y; |
| 1470 |
1482 /// Extracted z value. | 1471 /// Extracted z value. |
1483 double get z; | 1472 double get z; |
| 1473 |
1484 /// Extracted w value. | 1474 /// Extracted w value. |
1485 double get w; | 1475 double get w; |
1486 | 1476 |
1487 /// Extract the sign bits from each lane return them in the first 4 bits. | 1477 /// Extract the sign bits from each lane return them in the first 4 bits. |
1488 /// "x" lane is bit 0. | 1478 /// "x" lane is bit 0. |
1489 /// "y" lane is bit 1. | 1479 /// "y" lane is bit 1. |
1490 /// "z" lane is bit 2. | 1480 /// "z" lane is bit 2. |
1491 /// "w" lane is bit 3. | 1481 /// "w" lane is bit 3. |
1492 int get signMask; | 1482 int get signMask; |
1493 | 1483 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 /// Shuffle the lane values. [mask] must be one of the 256 shuffle constants. | 1742 /// Shuffle the lane values. [mask] must be one of the 256 shuffle constants. |
1753 Float32x4 shuffle(int mask); | 1743 Float32x4 shuffle(int mask); |
1754 | 1744 |
1755 /// Shuffle the lane values in [this] and [other]. The returned | 1745 /// Shuffle the lane values in [this] and [other]. The returned |
1756 /// Float32x4 will have XY lanes from [this] and ZW lanes from [other]. | 1746 /// Float32x4 will have XY lanes from [this] and ZW lanes from [other]. |
1757 /// Uses the same [mask] as [shuffle]. | 1747 /// Uses the same [mask] as [shuffle]. |
1758 Float32x4 shuffleMix(Float32x4 other, int mask); | 1748 Float32x4 shuffleMix(Float32x4 other, int mask); |
1759 | 1749 |
1760 /// Returns a new [Float32x4] copied from [this] with a new x value. | 1750 /// Returns a new [Float32x4] copied from [this] with a new x value. |
1761 Float32x4 withX(double x); | 1751 Float32x4 withX(double x); |
| 1752 |
1762 /// Returns a new [Float32x4] copied from [this] with a new y value. | 1753 /// Returns a new [Float32x4] copied from [this] with a new y value. |
1763 Float32x4 withY(double y); | 1754 Float32x4 withY(double y); |
| 1755 |
1764 /// Returns a new [Float32x4] copied from [this] with a new z value. | 1756 /// Returns a new [Float32x4] copied from [this] with a new z value. |
1765 Float32x4 withZ(double z); | 1757 Float32x4 withZ(double z); |
| 1758 |
1766 /// Returns a new [Float32x4] copied from [this] with a new w value. | 1759 /// Returns a new [Float32x4] copied from [this] with a new w value. |
1767 Float32x4 withW(double w); | 1760 Float32x4 withW(double w); |
1768 | 1761 |
1769 /// Returns the lane-wise minimum value in [this] or [other]. | 1762 /// Returns the lane-wise minimum value in [this] or [other]. |
1770 Float32x4 min(Float32x4 other); | 1763 Float32x4 min(Float32x4 other); |
1771 | 1764 |
1772 /// Returns the lane-wise maximum value in [this] or [other]. | 1765 /// Returns the lane-wise maximum value in [this] or [other]. |
1773 Float32x4 max(Float32x4 other); | 1766 Float32x4 max(Float32x4 other); |
1774 | 1767 |
1775 /// Returns the square root of [this]. | 1768 /// Returns the square root of [this]. |
1776 Float32x4 sqrt(); | 1769 Float32x4 sqrt(); |
1777 | 1770 |
1778 /// Returns the reciprocal of [this]. | 1771 /// Returns the reciprocal of [this]. |
1779 Float32x4 reciprocal(); | 1772 Float32x4 reciprocal(); |
1780 | 1773 |
1781 /// Returns the square root of the reciprocal of [this]. | 1774 /// Returns the square root of the reciprocal of [this]. |
1782 Float32x4 reciprocalSqrt(); | 1775 Float32x4 reciprocalSqrt(); |
1783 } | 1776 } |
1784 | 1777 |
1785 | |
1786 /** | 1778 /** |
1787 * Int32x4 and operations. | 1779 * Int32x4 and operations. |
1788 * | 1780 * |
1789 * Int32x4 stores 4 32-bit bit-masks in "lanes". | 1781 * Int32x4 stores 4 32-bit bit-masks in "lanes". |
1790 * The lanes are "x", "y", "z", and "w" respectively. | 1782 * The lanes are "x", "y", "z", and "w" respectively. |
1791 */ | 1783 */ |
1792 abstract class Int32x4 { | 1784 abstract class Int32x4 { |
1793 external factory Int32x4(int x, int y, int z, int w); | 1785 external factory Int32x4(int x, int y, int z, int w); |
1794 external factory Int32x4.bool(bool x, bool y, bool z, bool w); | 1786 external factory Int32x4.bool(bool x, bool y, bool z, bool w); |
1795 external factory Int32x4.fromFloat32x4Bits(Float32x4 x); | 1787 external factory Int32x4.fromFloat32x4Bits(Float32x4 x); |
1796 | 1788 |
1797 /// The bit-wise or operator. | 1789 /// The bit-wise or operator. |
1798 Int32x4 operator|(Int32x4 other); | 1790 Int32x4 operator |(Int32x4 other); |
| 1791 |
1799 /// The bit-wise and operator. | 1792 /// The bit-wise and operator. |
1800 Int32x4 operator&(Int32x4 other); | 1793 Int32x4 operator &(Int32x4 other); |
| 1794 |
1801 /// The bit-wise xor operator. | 1795 /// The bit-wise xor operator. |
1802 Int32x4 operator^(Int32x4 other); | 1796 Int32x4 operator ^(Int32x4 other); |
| 1797 |
1803 /// Addition operator. | 1798 /// Addition operator. |
1804 Int32x4 operator+(Int32x4 other); | 1799 Int32x4 operator +(Int32x4 other); |
| 1800 |
1805 /// Subtraction operator. | 1801 /// Subtraction operator. |
1806 Int32x4 operator-(Int32x4 other); | 1802 Int32x4 operator -(Int32x4 other); |
1807 | 1803 |
1808 /// Extract 32-bit mask from x lane. | 1804 /// Extract 32-bit mask from x lane. |
1809 int get x; | 1805 int get x; |
| 1806 |
1810 /// Extract 32-bit mask from y lane. | 1807 /// Extract 32-bit mask from y lane. |
1811 int get y; | 1808 int get y; |
| 1809 |
1812 /// Extract 32-bit mask from z lane. | 1810 /// Extract 32-bit mask from z lane. |
1813 int get z; | 1811 int get z; |
| 1812 |
1814 /// Extract 32-bit mask from w lane. | 1813 /// Extract 32-bit mask from w lane. |
1815 int get w; | 1814 int get w; |
1816 | 1815 |
1817 /// Extract the top bit from each lane return them in the first 4 bits. | 1816 /// Extract the top bit from each lane return them in the first 4 bits. |
1818 /// "x" lane is bit 0. | 1817 /// "x" lane is bit 0. |
1819 /// "y" lane is bit 1. | 1818 /// "y" lane is bit 1. |
1820 /// "z" lane is bit 2. | 1819 /// "z" lane is bit 2. |
1821 /// "w" lane is bit 3. | 1820 /// "w" lane is bit 3. |
1822 int get signMask; | 1821 int get signMask; |
1823 | 1822 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2082 /// Shuffle the lane values. [mask] must be one of the 256 shuffle constants. | 2081 /// Shuffle the lane values. [mask] must be one of the 256 shuffle constants. |
2083 Int32x4 shuffle(int mask); | 2082 Int32x4 shuffle(int mask); |
2084 | 2083 |
2085 /// Shuffle the lane values in [this] and [other]. The returned | 2084 /// Shuffle the lane values in [this] and [other]. The returned |
2086 /// Int32x4 will have XY lanes from [this] and ZW lanes from [other]. | 2085 /// Int32x4 will have XY lanes from [this] and ZW lanes from [other]. |
2087 /// Uses the same [mask] as [shuffle]. | 2086 /// Uses the same [mask] as [shuffle]. |
2088 Int32x4 shuffleMix(Int32x4 other, int mask); | 2087 Int32x4 shuffleMix(Int32x4 other, int mask); |
2089 | 2088 |
2090 /// Returns a new [Int32x4] copied from [this] with a new x value. | 2089 /// Returns a new [Int32x4] copied from [this] with a new x value. |
2091 Int32x4 withX(int x); | 2090 Int32x4 withX(int x); |
| 2091 |
2092 /// Returns a new [Int32x4] copied from [this] with a new y value. | 2092 /// Returns a new [Int32x4] copied from [this] with a new y value. |
2093 Int32x4 withY(int y); | 2093 Int32x4 withY(int y); |
| 2094 |
2094 /// Returns a new [Int32x4] copied from [this] with a new z value. | 2095 /// Returns a new [Int32x4] copied from [this] with a new z value. |
2095 Int32x4 withZ(int z); | 2096 Int32x4 withZ(int z); |
| 2097 |
2096 /// Returns a new [Int32x4] copied from [this] with a new w value. | 2098 /// Returns a new [Int32x4] copied from [this] with a new w value. |
2097 Int32x4 withW(int w); | 2099 Int32x4 withW(int w); |
2098 | 2100 |
2099 /// Extracted x value. Returns false for 0, true for any other value. | 2101 /// Extracted x value. Returns false for 0, true for any other value. |
2100 bool get flagX; | 2102 bool get flagX; |
| 2103 |
2101 /// Extracted y value. Returns false for 0, true for any other value. | 2104 /// Extracted y value. Returns false for 0, true for any other value. |
2102 bool get flagY; | 2105 bool get flagY; |
| 2106 |
2103 /// Extracted z value. Returns false for 0, true for any other value. | 2107 /// Extracted z value. Returns false for 0, true for any other value. |
2104 bool get flagZ; | 2108 bool get flagZ; |
| 2109 |
2105 /// Extracted w value. Returns false for 0, true for any other value. | 2110 /// Extracted w value. Returns false for 0, true for any other value. |
2106 bool get flagW; | 2111 bool get flagW; |
2107 | 2112 |
2108 /// Returns a new [Int32x4] copied from [this] with a new x value. | 2113 /// Returns a new [Int32x4] copied from [this] with a new x value. |
2109 Int32x4 withFlagX(bool x); | 2114 Int32x4 withFlagX(bool x); |
| 2115 |
2110 /// Returns a new [Int32x4] copied from [this] with a new y value. | 2116 /// Returns a new [Int32x4] copied from [this] with a new y value. |
2111 Int32x4 withFlagY(bool y); | 2117 Int32x4 withFlagY(bool y); |
| 2118 |
2112 /// Returns a new [Int32x4] copied from [this] with a new z value. | 2119 /// Returns a new [Int32x4] copied from [this] with a new z value. |
2113 Int32x4 withFlagZ(bool z); | 2120 Int32x4 withFlagZ(bool z); |
| 2121 |
2114 /// Returns a new [Int32x4] copied from [this] with a new w value. | 2122 /// Returns a new [Int32x4] copied from [this] with a new w value. |
2115 Int32x4 withFlagW(bool w); | 2123 Int32x4 withFlagW(bool w); |
2116 | 2124 |
2117 /// Merge [trueValue] and [falseValue] based on [this]' bit mask: | 2125 /// Merge [trueValue] and [falseValue] based on [this]' bit mask: |
2118 /// Select bit from [trueValue] when bit in [this] is on. | 2126 /// Select bit from [trueValue] when bit in [this] is on. |
2119 /// Select bit from [falseValue] when bit in [this] is off. | 2127 /// Select bit from [falseValue] when bit in [this] is off. |
2120 Float32x4 select(Float32x4 trueValue, Float32x4 falseValue); | 2128 Float32x4 select(Float32x4 trueValue, Float32x4 falseValue); |
2121 } | 2129 } |
2122 | 2130 |
2123 /** | 2131 /** |
2124 * Float64x2 immutable value type and operations. | 2132 * Float64x2 immutable value type and operations. |
2125 * | 2133 * |
2126 * Float64x2 stores 2 64-bit floating point values in "lanes". | 2134 * Float64x2 stores 2 64-bit floating point values in "lanes". |
2127 * The lanes are "x" and "y" respectively. | 2135 * The lanes are "x" and "y" respectively. |
2128 */ | 2136 */ |
2129 abstract class Float64x2 { | 2137 abstract class Float64x2 { |
2130 external factory Float64x2(double x, double y); | 2138 external factory Float64x2(double x, double y); |
2131 external factory Float64x2.splat(double v); | 2139 external factory Float64x2.splat(double v); |
2132 external factory Float64x2.zero(); | 2140 external factory Float64x2.zero(); |
| 2141 |
2133 /// Uses the "x" and "y" lanes from [v]. | 2142 /// Uses the "x" and "y" lanes from [v]. |
2134 external factory Float64x2.fromFloat32x4(Float32x4 v); | 2143 external factory Float64x2.fromFloat32x4(Float32x4 v); |
2135 | 2144 |
2136 /// Addition operator. | 2145 /// Addition operator. |
2137 Float64x2 operator+(Float64x2 other); | 2146 Float64x2 operator +(Float64x2 other); |
| 2147 |
2138 /// Negate operator. | 2148 /// Negate operator. |
2139 Float64x2 operator-(); | 2149 Float64x2 operator -(); |
| 2150 |
2140 /// Subtraction operator. | 2151 /// Subtraction operator. |
2141 Float64x2 operator-(Float64x2 other); | 2152 Float64x2 operator -(Float64x2 other); |
| 2153 |
2142 /// Multiplication operator. | 2154 /// Multiplication operator. |
2143 Float64x2 operator*(Float64x2 other); | 2155 Float64x2 operator *(Float64x2 other); |
| 2156 |
2144 /// Division operator. | 2157 /// Division operator. |
2145 Float64x2 operator/(Float64x2 other); | 2158 Float64x2 operator /(Float64x2 other); |
2146 | 2159 |
2147 /// Returns a copy of [this] each lane being scaled by [s]. | 2160 /// Returns a copy of [this] each lane being scaled by [s]. |
2148 /// Equivalent to this * new Float64x2.splat(s) | 2161 /// Equivalent to this * new Float64x2.splat(s) |
2149 Float64x2 scale(double s); | 2162 Float64x2 scale(double s); |
| 2163 |
2150 /// Returns the lane-wise absolute value of this [Float64x2]. | 2164 /// Returns the lane-wise absolute value of this [Float64x2]. |
2151 Float64x2 abs(); | 2165 Float64x2 abs(); |
2152 | 2166 |
2153 /// Lane-wise clamp [this] to be in the range [lowerLimit]-[upperLimit]. | 2167 /// Lane-wise clamp [this] to be in the range [lowerLimit]-[upperLimit]. |
2154 Float64x2 clamp(Float64x2 lowerLimit, | 2168 Float64x2 clamp(Float64x2 lowerLimit, Float64x2 upperLimit); |
2155 Float64x2 upperLimit); | |
2156 | 2169 |
2157 /// Extracted x value. | 2170 /// Extracted x value. |
2158 double get x; | 2171 double get x; |
| 2172 |
2159 /// Extracted y value. | 2173 /// Extracted y value. |
2160 double get y; | 2174 double get y; |
2161 | 2175 |
2162 /// Extract the sign bits from each lane return them in the first 2 bits. | 2176 /// Extract the sign bits from each lane return them in the first 2 bits. |
2163 /// "x" lane is bit 0. | 2177 /// "x" lane is bit 0. |
2164 /// "y" lane is bit 1. | 2178 /// "y" lane is bit 1. |
2165 int get signMask; | 2179 int get signMask; |
2166 | 2180 |
2167 /// Returns a new [Float64x2] copied from [this] with a new x value. | 2181 /// Returns a new [Float64x2] copied from [this] with a new x value. |
2168 Float64x2 withX(double x); | 2182 Float64x2 withX(double x); |
| 2183 |
2169 /// Returns a new [Float64x2] copied from [this] with a new y value. | 2184 /// Returns a new [Float64x2] copied from [this] with a new y value. |
2170 Float64x2 withY(double y); | 2185 Float64x2 withY(double y); |
2171 | 2186 |
2172 /// Returns the lane-wise minimum value in [this] or [other]. | 2187 /// Returns the lane-wise minimum value in [this] or [other]. |
2173 Float64x2 min(Float64x2 other); | 2188 Float64x2 min(Float64x2 other); |
2174 | 2189 |
2175 /// Returns the lane-wise maximum value in [this] or [other]. | 2190 /// Returns the lane-wise maximum value in [this] or [other]. |
2176 Float64x2 max(Float64x2 other); | 2191 Float64x2 max(Float64x2 other); |
2177 | 2192 |
2178 /// Returns the lane-wise square root of [this]. | 2193 /// Returns the lane-wise square root of [this]. |
2179 Float64x2 sqrt(); | 2194 Float64x2 sqrt(); |
2180 } | 2195 } |
OLD | NEW |