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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 */ | 346 */ |
347 ByteArray asByteArray([int start, int length]); | 347 ByteArray asByteArray([int start, int length]); |
348 } | 348 } |
349 | 349 |
350 | 350 |
351 /** | 351 /** |
352 * A fixed-length list of 8-bit signed integers that is viewable as a | 352 * A fixed-length list of 8-bit signed integers that is viewable as a |
353 * [ByteArray]. For long lists, this implementation will be considerably | 353 * [ByteArray]. For long lists, this implementation will be considerably |
354 * more space- and time-efficient than the default [List] implementation. | 354 * more space- and time-efficient than the default [List] implementation. |
355 */ | 355 */ |
356 class Int8List implements List<int>, ByteArrayViewable { | 356 abstract class Int8List implements List<int>, ByteArrayViewable { |
357 /** | 357 /** |
358 * Creates an [Int8List] of the specified length (in elements), all of | 358 * Creates an [Int8List] of the specified length (in elements), all of |
359 * whose elements are initially zero. | 359 * whose elements are initially zero. |
360 */ | 360 */ |
361 external Int8List(int length); | 361 external factory Int8List(int length); |
362 | 362 |
363 /** | 363 /** |
364 * Creates an [Int8List] _view_ of the specified region in the specified | 364 * Creates an [Int8List] _view_ of the specified region in the specified |
365 * byte [array]. Changes in the [Int8List] will be visible in the byte | 365 * byte [array]. Changes in the [Int8List] will be visible in the byte |
366 * array and vice versa. If the [start] index of the region is not specified, | 366 * array and vice versa. If the [start] index of the region is not specified, |
367 * it defaults to zero (the first byte in the byte array). If the length is | 367 * it defaults to zero (the first byte in the byte array). If the length is |
368 * not specified, it defaults to null, which indicates that the view extends | 368 * not specified, it defaults to null, which indicates that the view extends |
369 * to the end of the byte array. | 369 * to the end of the byte array. |
370 */ | 370 */ |
371 external Int8List.view(ByteArray array, [int start, int length]); | 371 external factory Int8List.view(ByteArray array, [int start, int length]); |
372 } | 372 } |
373 | 373 |
374 | 374 |
375 /** | 375 /** |
376 * A fixed-length list of 8-bit unsigned integers that is viewable as a | 376 * A fixed-length list of 8-bit unsigned integers that is viewable as a |
377 * [ByteArray]. For long lists, this implementation will be considerably | 377 * [ByteArray]. For long lists, this implementation will be considerably |
378 * more space- and time-efficient than the default [List] implementation. | 378 * more space- and time-efficient than the default [List] implementation. |
379 */ | 379 */ |
380 class Uint8List implements List<int>, ByteArrayViewable { | 380 abstract class Uint8List implements List<int>, ByteArrayViewable { |
381 /** | 381 /** |
382 * Creates a [Uint8List] of the specified length (in elements), all of | 382 * Creates a [Uint8List] of the specified length (in elements), all of |
383 * whose elements are initially zero. | 383 * whose elements are initially zero. |
384 */ | 384 */ |
385 external Uint8List(int length); | 385 external factory Uint8List(int length); |
386 | 386 |
387 /** | 387 /** |
388 * Creates a [Uint8List] _view_ of the specified region in the specified | 388 * Creates a [Uint8List] _view_ of the specified region in the specified |
389 * byte [array]. Changes in the [Uint8List] will be visible in the byte | 389 * byte [array]. Changes in the [Uint8List] will be visible in the byte |
390 * array and vice versa. If the [start] index of the region is not specified, | 390 * array and vice versa. If the [start] index of the region is not specified, |
391 * it defaults to zero (the first byte in the byte array). If the length is | 391 * it defaults to zero (the first byte in the byte array). If the length is |
392 * not specified, it defaults to null, which indicates that the view extends | 392 * not specified, it defaults to null, which indicates that the view extends |
393 * to the end of the byte array. | 393 * to the end of the byte array. |
394 */ | 394 */ |
395 external Uint8List.view(ByteArray array, [int start, int length]); | 395 external factory Uint8List.view(ByteArray array, [int start, int length]); |
396 } | 396 } |
397 | 397 |
398 | 398 |
399 /** | 399 /** |
400 * A fixed-length list of 16-bit signed integers that is viewable as a | 400 * A fixed-length list of 16-bit signed integers that is viewable as a |
401 * [ByteArray]. For long lists, this implementation will be considerably | 401 * [ByteArray]. For long lists, this implementation will be considerably |
402 * more space- and time-efficient than the default [List] implementation. | 402 * more space- and time-efficient than the default [List] implementation. |
403 */ | 403 */ |
404 class Int16List implements List<int>, ByteArrayViewable { | 404 abstract class Int16List implements List<int>, ByteArrayViewable { |
405 /** | 405 /** |
406 * Creates an [Int16List] of the specified length (in elements), all of | 406 * Creates an [Int16List] of the specified length (in elements), all of |
407 * whose elements are initially zero. | 407 * whose elements are initially zero. |
408 */ | 408 */ |
409 external Int16List(int length); | 409 external factory Int16List(int length); |
410 | 410 |
411 /** | 411 /** |
412 * Creates an [Int16List] _view_ of the specified region in the specified | 412 * Creates an [Int16List] _view_ of the specified region in the specified |
413 * byte [array]. Changes in the [Int16List] will be visible in the byte | 413 * byte [array]. Changes in the [Int16List] will be visible in the byte |
414 * array and vice versa. If the [start] index of the region is not specified, | 414 * array and vice versa. If the [start] index of the region is not specified, |
415 * it defaults to zero (the first byte in the byte array). If the length is | 415 * it defaults to zero (the first byte in the byte array). If the length is |
416 * not specified, it defaults to null, which indicates that the view extends | 416 * not specified, it defaults to null, which indicates that the view extends |
417 * to the end of the byte array. | 417 * to the end of the byte array. |
418 * | 418 * |
419 * Throws [ArgumentError] if the length of the specified region | 419 * Throws [ArgumentError] if the length of the specified region |
420 * is not divisible by 2 (the size of an "int16" in bytes), or if the | 420 * is not divisible by 2 (the size of an "int16" in bytes), or if the |
421 * [start] of the region is not divisible by 2. If, however, [array] | 421 * [start] of the region is not divisible by 2. If, however, [array] |
422 * is a view of another byte array, this constructor will throw | 422 * is a view of another byte array, this constructor will throw |
423 * [ArgumentError] if the implicit starting position in the | 423 * [ArgumentError] if the implicit starting position in the |
424 * "ultimately backing" byte array is not divisible by 2. In plain terms, | 424 * "ultimately backing" byte array is not divisible by 2. In plain terms, |
425 * this constructor throws [ArgumentError] if the specified | 425 * this constructor throws [ArgumentError] if the specified |
426 * region does not contain an integral number of "int16s," or if it | 426 * region does not contain an integral number of "int16s," or if it |
427 * is not "int16-aligned." | 427 * is not "int16-aligned." |
428 */ | 428 */ |
429 external Int16List.view(ByteArray array, [int start, int length]); | 429 external factory Int16List.view(ByteArray array, [int start, int length]); |
430 } | 430 } |
431 | 431 |
432 | 432 |
433 /** | 433 /** |
434 * A fixed-length list of 16-bit unsigned integers that is viewable as a | 434 * A fixed-length list of 16-bit unsigned integers that is viewable as a |
435 * [ByteArray]. For long lists, this implementation will be considerably | 435 * [ByteArray]. For long lists, this implementation will be considerably |
436 * more space- and time-efficient than the default [List] implementation. | 436 * more space- and time-efficient than the default [List] implementation. |
437 */ | 437 */ |
438 class Uint16List implements List<int>, ByteArrayViewable { | 438 abstract class Uint16List implements List<int>, ByteArrayViewable { |
439 /** | 439 /** |
440 * Creates a [Uint16List] of the specified length (in elements), all | 440 * Creates a [Uint16List] of the specified length (in elements), all |
441 * of whose elements are initially zero. | 441 * of whose elements are initially zero. |
442 */ | 442 */ |
443 external Uint16List(int length); | 443 external factory Uint16List(int length); |
444 | 444 |
445 /** | 445 /** |
446 * Creates a [Uint16List] _view_ of the specified region in | 446 * Creates a [Uint16List] _view_ of the specified region in |
447 * the specified byte [array]. Changes in the [Uint16List] will be | 447 * the specified byte [array]. Changes in the [Uint16List] will be |
448 * visible in the byte array and vice versa. If the [start] index of the | 448 * visible in the byte array and vice versa. If the [start] index of the |
449 * region is not specified, it defaults to zero (the first byte in the byte | 449 * region is not specified, it defaults to zero (the first byte in the byte |
450 * array). If the length is not specified, it defaults to null, which | 450 * array). If the length is not specified, it defaults to null, which |
451 * indicates that the view extends to the end of the byte array. | 451 * indicates that the view extends to the end of the byte array. |
452 * | 452 * |
453 * Throws [ArgumentError] if the length of the specified region | 453 * Throws [ArgumentError] if the length of the specified region |
454 * is not divisible by 2 (the size of a "uint16" in bytes), or if the | 454 * is not divisible by 2 (the size of a "uint16" in bytes), or if the |
455 * [start] of the region is not divisible by 2. If, however, [array] | 455 * [start] of the region is not divisible by 2. If, however, [array] |
456 * is a view of another byte array, this constructor will throw | 456 * is a view of another byte array, this constructor will throw |
457 * [ArgumentError] if the implicit starting position in the | 457 * [ArgumentError] if the implicit starting position in the |
458 * "ultimately backing" byte array is not divisible by 2. In plain terms, | 458 * "ultimately backing" byte array is not divisible by 2. In plain terms, |
459 * this constructor throws [ArgumentError] if the specified | 459 * this constructor throws [ArgumentError] if the specified |
460 * region does not contain an integral number of "uint16s," or if it | 460 * region does not contain an integral number of "uint16s," or if it |
461 * is not "uint16-aligned." | 461 * is not "uint16-aligned." |
462 */ | 462 */ |
463 external Uint16List.view(ByteArray array, [int start, int length]); | 463 external factory Uint16List.view(ByteArray array, [int start, int length]); |
464 } | 464 } |
465 | 465 |
466 | 466 |
467 /** | 467 /** |
468 * A fixed-length list of 32-bit signed integers that is viewable as a | 468 * A fixed-length list of 32-bit signed integers that is viewable as a |
469 * [ByteArray]. For long lists, this implementation will be considerably | 469 * [ByteArray]. For long lists, this implementation will be considerably |
470 * more space- and time-efficient than the default [List] implementation. | 470 * more space- and time-efficient than the default [List] implementation. |
471 */ | 471 */ |
472 class Int32List implements List<int>, ByteArrayViewable { | 472 abstract class Int32List implements List<int>, ByteArrayViewable { |
473 /** | 473 /** |
474 * Creates an [Int32List] of the specified length (in elements), all of | 474 * Creates an [Int32List] of the specified length (in elements), all of |
475 * whose elements are initially zero. | 475 * whose elements are initially zero. |
476 */ | 476 */ |
477 external Int32List(int length); | 477 external factory Int32List(int length); |
478 | 478 |
479 /** | 479 /** |
480 * Creates an [Int32List] _view_ of the specified region in the specified | 480 * Creates an [Int32List] _view_ of the specified region in the specified |
481 * byte [array]. Changes in the [Int32List] will be visible in the byte | 481 * byte [array]. Changes in the [Int32List] will be visible in the byte |
482 * array and vice versa. If the [start] index of the region is not specified, | 482 * array and vice versa. If the [start] index of the region is not specified, |
483 * it defaults to zero (the first byte in the byte array). If the length is | 483 * it defaults to zero (the first byte in the byte array). If the length is |
484 * not specified, it defaults to null, which indicates that the view extends | 484 * not specified, it defaults to null, which indicates that the view extends |
485 * to the end of the byte array. | 485 * to the end of the byte array. |
486 * | 486 * |
487 * Throws [ArgumentError] if the length of the specified region | 487 * Throws [ArgumentError] if the length of the specified region |
488 * is not divisible by 4 (the size of an "int32" in bytes), or if the | 488 * is not divisible by 4 (the size of an "int32" in bytes), or if the |
489 * [start] of the region is not divisible by 4. If, however, [array] | 489 * [start] of the region is not divisible by 4. If, however, [array] |
490 * is a view of another byte array, this constructor will throw | 490 * is a view of another byte array, this constructor will throw |
491 * [ArgumentError] if the implicit starting position in the | 491 * [ArgumentError] if the implicit starting position in the |
492 * "ultimately backing" byte array is not divisible by 4. In plain terms, | 492 * "ultimately backing" byte array is not divisible by 4. In plain terms, |
493 * this constructor throws [ArgumentError] if the specified | 493 * this constructor throws [ArgumentError] if the specified |
494 * region does not contain an integral number of "int32s," or if it | 494 * region does not contain an integral number of "int32s," or if it |
495 * is not "int32-aligned." | 495 * is not "int32-aligned." |
496 */ | 496 */ |
497 external Int32List.view(ByteArray array, [int start, int length]); | 497 external factory Int32List.view(ByteArray array, [int start, int length]); |
498 } | 498 } |
499 | 499 |
500 | 500 |
501 /** | 501 /** |
502 * A fixed-length list of 32-bit unsigned integers that is viewable as a | 502 * A fixed-length list of 32-bit unsigned integers that is viewable as a |
503 * [ByteArray]. For long lists, this implementation will be considerably | 503 * [ByteArray]. For long lists, this implementation will be considerably |
504 * more space- and time-efficient than the default [List] implementation. | 504 * more space- and time-efficient than the default [List] implementation. |
505 */ | 505 */ |
506 class Uint32List implements List<int>, ByteArrayViewable { | 506 abstract class Uint32List implements List<int>, ByteArrayViewable { |
507 /** | 507 /** |
508 * Creates a [Uint32List] of the specified length (in elements), all | 508 * Creates a [Uint32List] of the specified length (in elements), all |
509 * of whose elements are initially zero. | 509 * of whose elements are initially zero. |
510 */ | 510 */ |
511 external Uint32List(int length); | 511 external factory Uint32List(int length); |
512 | 512 |
513 /** | 513 /** |
514 * Creates a [Uint32List] _view_ of the specified region in | 514 * Creates a [Uint32List] _view_ of the specified region in |
515 * the specified byte [array]. Changes in the [Uint32] will be | 515 * the specified byte [array]. Changes in the [Uint32] will be |
516 * visible in the byte array and vice versa. If the [start] index of the | 516 * visible in the byte array and vice versa. If the [start] index of the |
517 * region is not specified, it defaults to zero (the first byte in the byte | 517 * region is not specified, it defaults to zero (the first byte in the byte |
518 * array). If the length is not specified, it defaults to null, which | 518 * array). If the length is not specified, it defaults to null, which |
519 * indicates that the view extends to the end of the byte array. | 519 * indicates that the view extends to the end of the byte array. |
520 * | 520 * |
521 * Throws [ArgumentError] if the length of the specified region | 521 * Throws [ArgumentError] if the length of the specified region |
522 * is not divisible by 4 (the size of a "uint32" in bytes), or if the | 522 * is not divisible by 4 (the size of a "uint32" in bytes), or if the |
523 * [start] of the region is not divisible by 4. If, however, [array] | 523 * [start] of the region is not divisible by 4. If, however, [array] |
524 * is a view of another byte array, this constructor will throw | 524 * is a view of another byte array, this constructor will throw |
525 * [ArgumentError] if the implicit starting position in the | 525 * [ArgumentError] if the implicit starting position in the |
526 * "ultimately backing" byte array is not divisible by 4. In plain terms, | 526 * "ultimately backing" byte array is not divisible by 4. In plain terms, |
527 * this constructor throws [ArgumentError] if the specified | 527 * this constructor throws [ArgumentError] if the specified |
528 * region does not contain an integral number of "uint32s," or if it | 528 * region does not contain an integral number of "uint32s," or if it |
529 * is not "uint32-aligned." | 529 * is not "uint32-aligned." |
530 */ | 530 */ |
531 external Uint32List.view(ByteArray array, [int start, int length]); | 531 external factory Uint32List.view(ByteArray array, [int start, int length]); |
532 } | 532 } |
533 | 533 |
534 | 534 |
535 /** | 535 /** |
536 * A fixed-length list of 64-bit signed integers that is viewable as a | 536 * A fixed-length list of 64-bit signed integers that is viewable as a |
537 * [ByteArray]. For long lists, this implementation will be considerably | 537 * [ByteArray]. For long lists, this implementation will be considerably |
538 * more space- and time-efficient than the default [List] implementation. | 538 * more space- and time-efficient than the default [List] implementation. |
539 */ | 539 */ |
540 class Int64List implements List<int>, ByteArrayViewable { | 540 abstract class Int64List implements List<int>, ByteArrayViewable { |
541 /** | 541 /** |
542 * Creates an [Int64List] of the specified length (in elements), all of | 542 * Creates an [Int64List] of the specified length (in elements), all of |
543 * whose elements are initially zero. | 543 * whose elements are initially zero. |
544 */ | 544 */ |
545 external Int64List(int length); | 545 external factory Int64List(int length); |
546 | 546 |
547 /** | 547 /** |
548 * Creates an [Int64List] _view_ of the specified region in the specified | 548 * Creates an [Int64List] _view_ of the specified region in the specified |
549 * byte [array]. Changes in the [Int64List] will be visible in the byte | 549 * byte [array]. Changes in the [Int64List] will be visible in the byte |
550 * array and vice versa. If the [start] index of the region is not specified, | 550 * array and vice versa. If the [start] index of the region is not specified, |
551 * it defaults to zero (the first byte in the byte array). If the length is | 551 * it defaults to zero (the first byte in the byte array). If the length is |
552 * not specified, it defaults to null, which indicates that the view extends | 552 * not specified, it defaults to null, which indicates that the view extends |
553 * to the end of the byte array. | 553 * to the end of the byte array. |
554 * | 554 * |
555 * Throws [ArgumentError] if the length of the specified region | 555 * Throws [ArgumentError] if the length of the specified region |
556 * is not divisible by 8 (the size of an "int64" in bytes), or if the | 556 * is not divisible by 8 (the size of an "int64" in bytes), or if the |
557 * [start] of the region is not divisible by 8. If, however, [array] | 557 * [start] of the region is not divisible by 8. If, however, [array] |
558 * is a view of another byte array, this constructor will throw | 558 * is a view of another byte array, this constructor will throw |
559 * [ArgumentError] if the implicit starting position in the | 559 * [ArgumentError] if the implicit starting position in the |
560 * "ultimately backing" byte array is not divisible by 8. In plain terms, | 560 * "ultimately backing" byte array is not divisible by 8. In plain terms, |
561 * this constructor throws [ArgumentError] if the specified | 561 * this constructor throws [ArgumentError] if the specified |
562 * region does not contain an integral number of "int64s," or if it | 562 * region does not contain an integral number of "int64s," or if it |
563 * is not "int64-aligned." | 563 * is not "int64-aligned." |
564 */ | 564 */ |
565 external Int64List.view(ByteArray array, [int start, int length]); | 565 external factory Int64List.view(ByteArray array, [int start, int length]); |
566 } | 566 } |
567 | 567 |
568 | 568 |
569 /** | 569 /** |
570 * A fixed-length list of 64-bit unsigned integers that is viewable as a | 570 * A fixed-length list of 64-bit unsigned integers that is viewable as a |
571 * [ByteArray]. For long lists, this implementation will be considerably | 571 * [ByteArray]. For long lists, this implementation will be considerably |
572 * more space- and time-efficient than the default [List] implementation. | 572 * more space- and time-efficient than the default [List] implementation. |
573 */ | 573 */ |
574 class Uint64List implements List<int>, ByteArrayViewable { | 574 abstract class Uint64List implements List<int>, ByteArrayViewable { |
575 /** | 575 /** |
576 * Creates a [Uint64List] of the specified length (in elements), all | 576 * Creates a [Uint64List] of the specified length (in elements), all |
577 * of whose elements are initially zero. | 577 * of whose elements are initially zero. |
578 */ | 578 */ |
579 external Uint64List(int length); | 579 external factory Uint64List(int length); |
580 | 580 |
581 /** | 581 /** |
582 * Creates an [Uint64List] _view_ of the specified region in | 582 * Creates an [Uint64List] _view_ of the specified region in |
583 * the specified byte [array]. Changes in the [Uint64List] will be | 583 * the specified byte [array]. Changes in the [Uint64List] will be |
584 * visible in the byte array and vice versa. If the [start] index of the | 584 * visible in the byte array and vice versa. If the [start] index of the |
585 * region is not specified, it defaults to zero (the first byte in the byte | 585 * region is not specified, it defaults to zero (the first byte in the byte |
586 * array). If the length is not specified, it defaults to null, which | 586 * array). If the length is not specified, it defaults to null, which |
587 * indicates that the view extends to the end of the byte array. | 587 * indicates that the view extends to the end of the byte array. |
588 * | 588 * |
589 * Throws [ArgumentError] if the length of the specified region | 589 * Throws [ArgumentError] if the length of the specified region |
590 * is not divisible by 8 (the size of a "uint64" in bytes), or if the | 590 * is not divisible by 8 (the size of a "uint64" in bytes), or if the |
591 * [start] of the region is not divisible by 8. If, however, [array] | 591 * [start] of the region is not divisible by 8. If, however, [array] |
592 * is a view of another byte array, this constructor will throw | 592 * is a view of another byte array, this constructor will throw |
593 * [ArgumentError] if the implicit starting position in the | 593 * [ArgumentError] if the implicit starting position in the |
594 * "ultimately backing" byte array is not divisible by 8. In plain terms, | 594 * "ultimately backing" byte array is not divisible by 8. In plain terms, |
595 * this constructor throws [ArgumentError] if the specified | 595 * this constructor throws [ArgumentError] if the specified |
596 * region does not contain an integral number of "uint64s," or if it | 596 * region does not contain an integral number of "uint64s," or if it |
597 * is not "uint64-aligned." | 597 * is not "uint64-aligned." |
598 */ | 598 */ |
599 external Uint64List.view(ByteArray array, [int start, int length]); | 599 external factory Uint64List.view(ByteArray array, [int start, int length]); |
600 } | 600 } |
601 | 601 |
602 | 602 |
603 /** | 603 /** |
604 * A fixed-length list of IEEE 754 single-precision binary floating-point | 604 * A fixed-length list of IEEE 754 single-precision binary floating-point |
605 * numbers that is viewable as a [ByteArray]. For long lists, this | 605 * numbers that is viewable as a [ByteArray]. For long lists, this |
606 * implementation will be considerably more space- and time-efficient than | 606 * implementation will be considerably more space- and time-efficient than |
607 * the default [List] implementation. | 607 * the default [List] implementation. |
608 */ | 608 */ |
609 class Float32List implements List<double>, ByteArrayViewable { | 609 abstract class Float32List implements List<double>, ByteArrayViewable { |
610 /** | 610 /** |
611 * Creates a [Float32List] of the specified length (in elements), all of | 611 * Creates a [Float32List] of the specified length (in elements), all of |
612 * whose elements are initially zero. | 612 * whose elements are initially zero. |
613 */ | 613 */ |
614 external Float32List(int length); | 614 external factory Float32List(int length); |
615 | 615 |
616 /** | 616 /** |
617 * Creates a [Float32List] _view_ of the specified region in the specified | 617 * Creates a [Float32List] _view_ of the specified region in the specified |
618 * byte [array]. Changes in the [Float32List] will be visible in the byte | 618 * byte [array]. Changes in the [Float32List] will be visible in the byte |
619 * array and vice versa. If the [start] index of the region is not specified, | 619 * array and vice versa. If the [start] index of the region is not specified, |
620 * it defaults to zero (the first byte in the byte array). If the length is | 620 * it defaults to zero (the first byte in the byte array). If the length is |
621 * not specified, it defaults to null, which indicates that the view extends | 621 * not specified, it defaults to null, which indicates that the view extends |
622 * to the end of the byte array. | 622 * to the end of the byte array. |
623 * | 623 * |
624 * Throws [ArgumentError] if the length of the specified region | 624 * Throws [ArgumentError] if the length of the specified region |
625 * is not divisible by 4 (the size of a "float32" in bytes), or if the | 625 * is not divisible by 4 (the size of a "float32" in bytes), or if the |
626 * [start] of the region is not divisible by 4. If, however, [array] | 626 * [start] of the region is not divisible by 4. If, however, [array] |
627 * is a view of another byte array, this constructor will throw | 627 * is a view of another byte array, this constructor will throw |
628 * [ArgumentError] if the implicit starting position in the | 628 * [ArgumentError] if the implicit starting position in the |
629 * "ultimately backing" byte array is not divisible by 4. In plain terms, | 629 * "ultimately backing" byte array is not divisible by 4. In plain terms, |
630 * this constructor throws [ArgumentError] if the specified | 630 * this constructor throws [ArgumentError] if the specified |
631 * region does not contain an integral number of "float32s," or if it | 631 * region does not contain an integral number of "float32s," or if it |
632 * is not "float32-aligned." | 632 * is not "float32-aligned." |
633 */ | 633 */ |
634 external Float32List.view(ByteArray array, [int start, int length]); | 634 external factory Float32List.view(ByteArray array, [int start, int length]); |
635 } | 635 } |
636 | 636 |
637 | 637 |
638 /** | 638 /** |
639 * A fixed-length list of IEEE 754 double-precision binary floating-point | 639 * A fixed-length list of IEEE 754 double-precision binary floating-point |
640 * numbers that is viewable as a [ByteArray]. For long lists, this | 640 * numbers that is viewable as a [ByteArray]. For long lists, this |
641 * implementation will be considerably more space- and time-efficient than | 641 * implementation will be considerably more space- and time-efficient than |
642 * the default [List] implementation. | 642 * the default [List] implementation. |
643 */ | 643 */ |
644 class Float64List implements List<double>, ByteArrayViewable { | 644 abstract class Float64List implements List<double>, ByteArrayViewable { |
645 /** | 645 /** |
646 * Creates a [Float64List] of the specified length (in elements), all of | 646 * Creates a [Float64List] of the specified length (in elements), all of |
647 * whose elements are initially zero. | 647 * whose elements are initially zero. |
648 */ | 648 */ |
649 external Float64List(int length); | 649 external factory Float64List(int length); |
650 | 650 |
651 /** | 651 /** |
652 * Creates a [Float64List] _view_ of the specified region in the specified | 652 * Creates a [Float64List] _view_ of the specified region in the specified |
653 * byte [array]. Changes in the [Float64List] will be visible in the byte | 653 * byte [array]. Changes in the [Float64List] will be visible in the byte |
654 * array and vice versa. If the [start] index of the region is not specified, | 654 * array and vice versa. If the [start] index of the region is not specified, |
655 * it defaults to zero (the first byte in the byte array). If the length is | 655 * it defaults to zero (the first byte in the byte array). If the length is |
656 * not specified, it defaults to null, which indicates that the view extends | 656 * not specified, it defaults to null, which indicates that the view extends |
657 * to the end of the byte array. | 657 * to the end of the byte array. |
658 * | 658 * |
659 * Throws [ArgumentError] if the length of the specified region | 659 * Throws [ArgumentError] if the length of the specified region |
660 * is not divisible by 8 (the size of a "float64" in bytes), or if the | 660 * is not divisible by 8 (the size of a "float64" in bytes), or if the |
661 * [start] of the region is not divisible by 8. If, however, [array] | 661 * [start] of the region is not divisible by 8. If, however, [array] |
662 * is a view of another byte array, this constructor will throw | 662 * is a view of another byte array, this constructor will throw |
663 * [ArgumentError] if the implicit starting position in the | 663 * [ArgumentError] if the implicit starting position in the |
664 * "ultimately backing" byte array is not divisible by 8. In plain terms, | 664 * "ultimately backing" byte array is not divisible by 8. In plain terms, |
665 * this constructor throws [ArgumentError] if the specified | 665 * this constructor throws [ArgumentError] if the specified |
666 * region does not contain an integral number of "float64s," or if it | 666 * region does not contain an integral number of "float64s," or if it |
667 * is not "float64-aligned." | 667 * is not "float64-aligned." |
668 */ | 668 */ |
669 external Float64List.view(ByteArray array, [int start, int length]); | 669 external factory Float64List.view(ByteArray array, [int start, int length]); |
670 } | 670 } |
OLD | NEW |