| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * A random-access sequence of bytes that also provides random access to | 6 * A random-access sequence of bytes that also provides random access to |
| 7 * the fixed-width integers and floating point numbers represented by | 7 * the fixed-width integers and floating point numbers represented by |
| 8 * those bytes. Byte arrays may be used to pack and unpack data from | 8 * those bytes. Byte arrays may be used to pack and unpack data from |
| 9 * external sources (such as networks or files systems), and to process | 9 * external sources (such as networks or files systems), and to process |
| 10 * large quantities of numerical data more efficiently than would be possible | 10 * large quantities of numerical data more efficiently than would be possible |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 external factory Int8List(int length); | 362 external factory Int8List(int length); |
| 363 | 363 |
| 364 /** | 364 /** |
| 365 * Creates an [Int8List] _view_ of the specified region in the specified | 365 * Creates an [Int8List] _view_ of the specified region in the specified |
| 366 * byte [array]. Changes in the [Int8List] will be visible in the byte | 366 * byte [array]. Changes in the [Int8List] will be visible in the byte |
| 367 * array and vice versa. If the [start] index of the region is not specified, | 367 * array and vice versa. If the [start] index of the region is not specified, |
| 368 * it defaults to zero (the first byte in the byte array). If the length is | 368 * it defaults to zero (the first byte in the byte array). If the length is |
| 369 * not specified, it defaults to null, which indicates that the view extends | 369 * not specified, it defaults to null, which indicates that the view extends |
| 370 * to the end of the byte array. | 370 * to the end of the byte array. |
| 371 */ | 371 */ |
| 372 external factory Int8List.view(ByteArray array, [int start, int length]); | 372 external factory Int8List.view(ByteArray array, [int start = 0, int length]); |
| 373 } | 373 } |
| 374 | 374 |
| 375 | 375 |
| 376 /** | 376 /** |
| 377 * A fixed-length list of 8-bit unsigned integers that is viewable as a | 377 * A fixed-length list of 8-bit unsigned integers that is viewable as a |
| 378 * [ByteArray]. For long lists, this implementation will be considerably | 378 * [ByteArray]. For long lists, this implementation will be considerably |
| 379 * more space- and time-efficient than the default [List] implementation. | 379 * more space- and time-efficient than the default [List] implementation. |
| 380 */ | 380 */ |
| 381 abstract class Uint8List implements List<int>, ByteArrayViewable { | 381 abstract class Uint8List implements List<int>, ByteArrayViewable { |
| 382 /** | 382 /** |
| 383 * Creates a [Uint8List] of the specified length (in elements), all of | 383 * Creates a [Uint8List] of the specified length (in elements), all of |
| 384 * whose elements are initially zero. | 384 * whose elements are initially zero. |
| 385 */ | 385 */ |
| 386 external factory Uint8List(int length); | 386 external factory Uint8List(int length); |
| 387 | 387 |
| 388 /** | 388 /** |
| 389 * Creates a [Uint8List] _view_ of the specified region in the specified | 389 * Creates a [Uint8List] _view_ of the specified region in the specified |
| 390 * byte [array]. Changes in the [Uint8List] will be visible in the byte | 390 * byte [array]. Changes in the [Uint8List] will be visible in the byte |
| 391 * array and vice versa. If the [start] index of the region is not specified, | 391 * array and vice versa. If the [start] index of the region is not specified, |
| 392 * it defaults to zero (the first byte in the byte array). If the length is | 392 * it defaults to zero (the first byte in the byte array). If the length is |
| 393 * not specified, it defaults to null, which indicates that the view extends | 393 * not specified, it defaults to null, which indicates that the view extends |
| 394 * to the end of the byte array. | 394 * to the end of the byte array. |
| 395 */ | 395 */ |
| 396 external factory Uint8List.view(ByteArray array, [int start, int length]); | 396 external factory Uint8List.view(ByteArray array, [int start = 0, int length]); |
| 397 } | 397 } |
| 398 | 398 |
| 399 | 399 |
| 400 /** | 400 /** |
| 401 * A fixed-length list of 8-bit unsigned integers that is viewable as a | 401 * A fixed-length list of 8-bit unsigned integers that is viewable as a |
| 402 * [ByteArray]. For long lists, this implementation will be considerably | 402 * [ByteArray]. For long lists, this implementation will be considerably |
| 403 * more space- and time-efficient than the default [List] implementation. | 403 * more space- and time-efficient than the default [List] implementation. |
| 404 * Indexed store clamps the value to range 0..0xFF. | 404 * Indexed store clamps the value to range 0..0xFF. |
| 405 */ | 405 */ |
| 406 abstract class Uint8ClampedList implements List<int>, ByteArrayViewable { | 406 abstract class Uint8ClampedList implements List<int>, ByteArrayViewable { |
| 407 /** | 407 /** |
| 408 * Creates a [Uint8ClampedList] of the specified length (in elements), all of | 408 * Creates a [Uint8ClampedList] of the specified length (in elements), all of |
| 409 * whose elements are initially zero. | 409 * whose elements are initially zero. |
| 410 */ | 410 */ |
| 411 external factory Uint8ClampedList(int length); | 411 external factory Uint8ClampedList(int length); |
| 412 | 412 |
| 413 /** | 413 /** |
| 414 * Creates a [Uint8ClampedList] _view_ of the specified region in the | 414 * Creates a [Uint8ClampedList] _view_ of the specified region in the |
| 415 * specified byte [array]. Changes in the [Uint8List] will be visible in the | 415 * specified byte [array]. Changes in the [Uint8List] will be visible in the |
| 416 * byte array and vice versa. If the [start] index of the region is not | 416 * byte array and vice versa. If the [start] index of the region is not |
| 417 * specified, it defaults to zero (the first byte in the byte array). If the | 417 * specified, it defaults to zero (the first byte in the byte array). If the |
| 418 * length is not specified, it defaults to null, which indicates that the view | 418 * length is not specified, it defaults to null, which indicates that the view |
| 419 * extends to the end of the byte array. | 419 * extends to the end of the byte array. |
| 420 */ | 420 */ |
| 421 external factory Uint8ClampedList.view(ByteArray array, | 421 external factory Uint8ClampedList.view(ByteArray array, |
| 422 [int start, int length]); | 422 [int start = 0, int length]); |
| 423 } | 423 } |
| 424 | 424 |
| 425 | 425 |
| 426 /** | 426 /** |
| 427 * A fixed-length list of 16-bit signed integers that is viewable as a | 427 * A fixed-length list of 16-bit signed integers that is viewable as a |
| 428 * [ByteArray]. For long lists, this implementation will be considerably | 428 * [ByteArray]. For long lists, this implementation will be considerably |
| 429 * more space- and time-efficient than the default [List] implementation. | 429 * more space- and time-efficient than the default [List] implementation. |
| 430 */ | 430 */ |
| 431 abstract class Int16List implements List<int>, ByteArrayViewable { | 431 abstract class Int16List implements List<int>, ByteArrayViewable { |
| 432 /** | 432 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 446 * Throws [ArgumentError] if the length of the specified region | 446 * Throws [ArgumentError] if the length of the specified region |
| 447 * is not divisible by 2 (the size of an "int16" in bytes), or if the | 447 * is not divisible by 2 (the size of an "int16" in bytes), or if the |
| 448 * [start] of the region is not divisible by 2. If, however, [array] | 448 * [start] of the region is not divisible by 2. If, however, [array] |
| 449 * is a view of another byte array, this constructor will throw | 449 * is a view of another byte array, this constructor will throw |
| 450 * [ArgumentError] if the implicit starting position in the | 450 * [ArgumentError] if the implicit starting position in the |
| 451 * "ultimately backing" byte array is not divisible by 2. In plain terms, | 451 * "ultimately backing" byte array is not divisible by 2. In plain terms, |
| 452 * this constructor throws [ArgumentError] if the specified | 452 * this constructor throws [ArgumentError] if the specified |
| 453 * region does not contain an integral number of "int16s," or if it | 453 * region does not contain an integral number of "int16s," or if it |
| 454 * is not "int16-aligned." | 454 * is not "int16-aligned." |
| 455 */ | 455 */ |
| 456 external factory Int16List.view(ByteArray array, [int start, int length]); | 456 external factory Int16List.view(ByteArray array, [int start = 0, int length]); |
| 457 } | 457 } |
| 458 | 458 |
| 459 | 459 |
| 460 /** | 460 /** |
| 461 * A fixed-length list of 16-bit unsigned integers that is viewable as a | 461 * A fixed-length list of 16-bit unsigned integers that is viewable as a |
| 462 * [ByteArray]. For long lists, this implementation will be considerably | 462 * [ByteArray]. For long lists, this implementation will be considerably |
| 463 * more space- and time-efficient than the default [List] implementation. | 463 * more space- and time-efficient than the default [List] implementation. |
| 464 */ | 464 */ |
| 465 abstract class Uint16List implements List<int>, ByteArrayViewable { | 465 abstract class Uint16List implements List<int>, ByteArrayViewable { |
| 466 /** | 466 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 480 * Throws [ArgumentError] if the length of the specified region | 480 * Throws [ArgumentError] if the length of the specified region |
| 481 * is not divisible by 2 (the size of a "uint16" in bytes), or if the | 481 * is not divisible by 2 (the size of a "uint16" in bytes), or if the |
| 482 * [start] of the region is not divisible by 2. If, however, [array] | 482 * [start] of the region is not divisible by 2. If, however, [array] |
| 483 * is a view of another byte array, this constructor will throw | 483 * is a view of another byte array, this constructor will throw |
| 484 * [ArgumentError] if the implicit starting position in the | 484 * [ArgumentError] if the implicit starting position in the |
| 485 * "ultimately backing" byte array is not divisible by 2. In plain terms, | 485 * "ultimately backing" byte array is not divisible by 2. In plain terms, |
| 486 * this constructor throws [ArgumentError] if the specified | 486 * this constructor throws [ArgumentError] if the specified |
| 487 * region does not contain an integral number of "uint16s," or if it | 487 * region does not contain an integral number of "uint16s," or if it |
| 488 * is not "uint16-aligned." | 488 * is not "uint16-aligned." |
| 489 */ | 489 */ |
| 490 external factory Uint16List.view(ByteArray array, [int start, int length]); | 490 external factory Uint16List.view(ByteArray array, |
| 491 [int start = 0, int length]); |
| 491 } | 492 } |
| 492 | 493 |
| 493 | 494 |
| 494 /** | 495 /** |
| 495 * A fixed-length list of 32-bit signed integers that is viewable as a | 496 * A fixed-length list of 32-bit signed integers that is viewable as a |
| 496 * [ByteArray]. For long lists, this implementation will be considerably | 497 * [ByteArray]. For long lists, this implementation will be considerably |
| 497 * more space- and time-efficient than the default [List] implementation. | 498 * more space- and time-efficient than the default [List] implementation. |
| 498 */ | 499 */ |
| 499 abstract class Int32List implements List<int>, ByteArrayViewable { | 500 abstract class Int32List implements List<int>, ByteArrayViewable { |
| 500 /** | 501 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 514 * Throws [ArgumentError] if the length of the specified region | 515 * Throws [ArgumentError] if the length of the specified region |
| 515 * is not divisible by 4 (the size of an "int32" in bytes), or if the | 516 * is not divisible by 4 (the size of an "int32" in bytes), or if the |
| 516 * [start] of the region is not divisible by 4. If, however, [array] | 517 * [start] of the region is not divisible by 4. If, however, [array] |
| 517 * is a view of another byte array, this constructor will throw | 518 * is a view of another byte array, this constructor will throw |
| 518 * [ArgumentError] if the implicit starting position in the | 519 * [ArgumentError] if the implicit starting position in the |
| 519 * "ultimately backing" byte array is not divisible by 4. In plain terms, | 520 * "ultimately backing" byte array is not divisible by 4. In plain terms, |
| 520 * this constructor throws [ArgumentError] if the specified | 521 * this constructor throws [ArgumentError] if the specified |
| 521 * region does not contain an integral number of "int32s," or if it | 522 * region does not contain an integral number of "int32s," or if it |
| 522 * is not "int32-aligned." | 523 * is not "int32-aligned." |
| 523 */ | 524 */ |
| 524 external factory Int32List.view(ByteArray array, [int start, int length]); | 525 external factory Int32List.view(ByteArray array, [int start = 0, int length]); |
| 525 } | 526 } |
| 526 | 527 |
| 527 | 528 |
| 528 /** | 529 /** |
| 529 * A fixed-length list of 32-bit unsigned integers that is viewable as a | 530 * A fixed-length list of 32-bit unsigned integers that is viewable as a |
| 530 * [ByteArray]. For long lists, this implementation will be considerably | 531 * [ByteArray]. For long lists, this implementation will be considerably |
| 531 * more space- and time-efficient than the default [List] implementation. | 532 * more space- and time-efficient than the default [List] implementation. |
| 532 */ | 533 */ |
| 533 abstract class Uint32List implements List<int>, ByteArrayViewable { | 534 abstract class Uint32List implements List<int>, ByteArrayViewable { |
| 534 /** | 535 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 548 * Throws [ArgumentError] if the length of the specified region | 549 * Throws [ArgumentError] if the length of the specified region |
| 549 * is not divisible by 4 (the size of a "uint32" in bytes), or if the | 550 * is not divisible by 4 (the size of a "uint32" in bytes), or if the |
| 550 * [start] of the region is not divisible by 4. If, however, [array] | 551 * [start] of the region is not divisible by 4. If, however, [array] |
| 551 * is a view of another byte array, this constructor will throw | 552 * is a view of another byte array, this constructor will throw |
| 552 * [ArgumentError] if the implicit starting position in the | 553 * [ArgumentError] if the implicit starting position in the |
| 553 * "ultimately backing" byte array is not divisible by 4. In plain terms, | 554 * "ultimately backing" byte array is not divisible by 4. In plain terms, |
| 554 * this constructor throws [ArgumentError] if the specified | 555 * this constructor throws [ArgumentError] if the specified |
| 555 * region does not contain an integral number of "uint32s," or if it | 556 * region does not contain an integral number of "uint32s," or if it |
| 556 * is not "uint32-aligned." | 557 * is not "uint32-aligned." |
| 557 */ | 558 */ |
| 558 external factory Uint32List.view(ByteArray array, [int start, int length]); | 559 external factory Uint32List.view(ByteArray array, |
| 560 [int start = 0, int length]); |
| 559 } | 561 } |
| 560 | 562 |
| 561 | 563 |
| 562 /** | 564 /** |
| 563 * A fixed-length list of 64-bit signed integers that is viewable as a | 565 * A fixed-length list of 64-bit signed integers that is viewable as a |
| 564 * [ByteArray]. For long lists, this implementation will be considerably | 566 * [ByteArray]. For long lists, this implementation will be considerably |
| 565 * more space- and time-efficient than the default [List] implementation. | 567 * more space- and time-efficient than the default [List] implementation. |
| 566 */ | 568 */ |
| 567 abstract class Int64List implements List<int>, ByteArrayViewable { | 569 abstract class Int64List implements List<int>, ByteArrayViewable { |
| 568 /** | 570 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 582 * Throws [ArgumentError] if the length of the specified region | 584 * Throws [ArgumentError] if the length of the specified region |
| 583 * is not divisible by 8 (the size of an "int64" in bytes), or if the | 585 * is not divisible by 8 (the size of an "int64" in bytes), or if the |
| 584 * [start] of the region is not divisible by 8. If, however, [array] | 586 * [start] of the region is not divisible by 8. If, however, [array] |
| 585 * is a view of another byte array, this constructor will throw | 587 * is a view of another byte array, this constructor will throw |
| 586 * [ArgumentError] if the implicit starting position in the | 588 * [ArgumentError] if the implicit starting position in the |
| 587 * "ultimately backing" byte array is not divisible by 8. In plain terms, | 589 * "ultimately backing" byte array is not divisible by 8. In plain terms, |
| 588 * this constructor throws [ArgumentError] if the specified | 590 * this constructor throws [ArgumentError] if the specified |
| 589 * region does not contain an integral number of "int64s," or if it | 591 * region does not contain an integral number of "int64s," or if it |
| 590 * is not "int64-aligned." | 592 * is not "int64-aligned." |
| 591 */ | 593 */ |
| 592 external factory Int64List.view(ByteArray array, [int start, int length]); | 594 external factory Int64List.view(ByteArray array, [int start = 0, int length]); |
| 593 } | 595 } |
| 594 | 596 |
| 595 | 597 |
| 596 /** | 598 /** |
| 597 * A fixed-length list of 64-bit unsigned integers that is viewable as a | 599 * A fixed-length list of 64-bit unsigned integers that is viewable as a |
| 598 * [ByteArray]. For long lists, this implementation will be considerably | 600 * [ByteArray]. For long lists, this implementation will be considerably |
| 599 * more space- and time-efficient than the default [List] implementation. | 601 * more space- and time-efficient than the default [List] implementation. |
| 600 */ | 602 */ |
| 601 abstract class Uint64List implements List<int>, ByteArrayViewable { | 603 abstract class Uint64List implements List<int>, ByteArrayViewable { |
| 602 /** | 604 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 616 * Throws [ArgumentError] if the length of the specified region | 618 * Throws [ArgumentError] if the length of the specified region |
| 617 * is not divisible by 8 (the size of a "uint64" in bytes), or if the | 619 * is not divisible by 8 (the size of a "uint64" in bytes), or if the |
| 618 * [start] of the region is not divisible by 8. If, however, [array] | 620 * [start] of the region is not divisible by 8. If, however, [array] |
| 619 * is a view of another byte array, this constructor will throw | 621 * is a view of another byte array, this constructor will throw |
| 620 * [ArgumentError] if the implicit starting position in the | 622 * [ArgumentError] if the implicit starting position in the |
| 621 * "ultimately backing" byte array is not divisible by 8. In plain terms, | 623 * "ultimately backing" byte array is not divisible by 8. In plain terms, |
| 622 * this constructor throws [ArgumentError] if the specified | 624 * this constructor throws [ArgumentError] if the specified |
| 623 * region does not contain an integral number of "uint64s," or if it | 625 * region does not contain an integral number of "uint64s," or if it |
| 624 * is not "uint64-aligned." | 626 * is not "uint64-aligned." |
| 625 */ | 627 */ |
| 626 external factory Uint64List.view(ByteArray array, [int start, int length]); | 628 external factory Uint64List.view(ByteArray array, |
| 629 [int start = 0, int length]); |
| 627 } | 630 } |
| 628 | 631 |
| 629 | 632 |
| 630 /** | 633 /** |
| 631 * A fixed-length list of IEEE 754 single-precision binary floating-point | 634 * A fixed-length list of IEEE 754 single-precision binary floating-point |
| 632 * numbers that is viewable as a [ByteArray]. For long lists, this | 635 * numbers that is viewable as a [ByteArray]. For long lists, this |
| 633 * implementation will be considerably more space- and time-efficient than | 636 * implementation will be considerably more space- and time-efficient than |
| 634 * the default [List] implementation. | 637 * the default [List] implementation. |
| 635 */ | 638 */ |
| 636 abstract class Float32List implements List<double>, ByteArrayViewable { | 639 abstract class Float32List implements List<double>, ByteArrayViewable { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 651 * Throws [ArgumentError] if the length of the specified region | 654 * Throws [ArgumentError] if the length of the specified region |
| 652 * is not divisible by 4 (the size of a "float32" in bytes), or if the | 655 * is not divisible by 4 (the size of a "float32" in bytes), or if the |
| 653 * [start] of the region is not divisible by 4. If, however, [array] | 656 * [start] of the region is not divisible by 4. If, however, [array] |
| 654 * is a view of another byte array, this constructor will throw | 657 * is a view of another byte array, this constructor will throw |
| 655 * [ArgumentError] if the implicit starting position in the | 658 * [ArgumentError] if the implicit starting position in the |
| 656 * "ultimately backing" byte array is not divisible by 4. In plain terms, | 659 * "ultimately backing" byte array is not divisible by 4. In plain terms, |
| 657 * this constructor throws [ArgumentError] if the specified | 660 * this constructor throws [ArgumentError] if the specified |
| 658 * region does not contain an integral number of "float32s," or if it | 661 * region does not contain an integral number of "float32s," or if it |
| 659 * is not "float32-aligned." | 662 * is not "float32-aligned." |
| 660 */ | 663 */ |
| 661 external factory Float32List.view(ByteArray array, [int start, int length]); | 664 external factory Float32List.view(ByteArray array, |
| 665 [int start = 0, int length]); |
| 662 } | 666 } |
| 663 | 667 |
| 664 | 668 |
| 665 /** | 669 /** |
| 666 * A fixed-length list of IEEE 754 double-precision binary floating-point | 670 * A fixed-length list of IEEE 754 double-precision binary floating-point |
| 667 * numbers that is viewable as a [ByteArray]. For long lists, this | 671 * numbers that is viewable as a [ByteArray]. For long lists, this |
| 668 * implementation will be considerably more space- and time-efficient than | 672 * implementation will be considerably more space- and time-efficient than |
| 669 * the default [List] implementation. | 673 * the default [List] implementation. |
| 670 */ | 674 */ |
| 671 abstract class Float64List implements List<double>, ByteArrayViewable { | 675 abstract class Float64List implements List<double>, ByteArrayViewable { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 686 * Throws [ArgumentError] if the length of the specified region | 690 * Throws [ArgumentError] if the length of the specified region |
| 687 * is not divisible by 8 (the size of a "float64" in bytes), or if the | 691 * is not divisible by 8 (the size of a "float64" in bytes), or if the |
| 688 * [start] of the region is not divisible by 8. If, however, [array] | 692 * [start] of the region is not divisible by 8. If, however, [array] |
| 689 * is a view of another byte array, this constructor will throw | 693 * is a view of another byte array, this constructor will throw |
| 690 * [ArgumentError] if the implicit starting position in the | 694 * [ArgumentError] if the implicit starting position in the |
| 691 * "ultimately backing" byte array is not divisible by 8. In plain terms, | 695 * "ultimately backing" byte array is not divisible by 8. In plain terms, |
| 692 * this constructor throws [ArgumentError] if the specified | 696 * this constructor throws [ArgumentError] if the specified |
| 693 * region does not contain an integral number of "float64s," or if it | 697 * region does not contain an integral number of "float64s," or if it |
| 694 * is not "float64-aligned." | 698 * is not "float64-aligned." |
| 695 */ | 699 */ |
| 696 external factory Float64List.view(ByteArray array, [int start, int length]); | 700 external factory Float64List.view(ByteArray array, |
| 701 [int start = 0, int length]); |
| 697 } | 702 } |
| OLD | NEW |