Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: sdk/lib/typeddata/typeddata.dart

Issue 13834008: Add fromList constructor to typeddata typed lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 library dart.typeddata; 5 library dart.typeddata;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 /** 9 /**
10 * A sequence of bytes underlying a typed data object. 10 * A sequence of bytes underlying a typed data object.
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 * more space- and time-efficient than the default [List] implementation. 320 * more space- and time-efficient than the default [List] implementation.
321 */ 321 */
322 abstract class Int8List implements List<int>, TypedData { 322 abstract class Int8List implements List<int>, TypedData {
323 /** 323 /**
324 * Creates an [Int8List] of the specified length (in elements), all of 324 * Creates an [Int8List] of the specified length (in elements), all of
325 * whose elements are initially zero. 325 * whose elements are initially zero.
326 */ 326 */
327 external factory Int8List(int length); 327 external factory Int8List(int length);
328 328
329 /** 329 /**
330 * Creates a [Int8List] with the same size as the [elements] list
331 * and copies over the elements.
332 */
333 external factory Int8List.fromList(List<int> elements);
334
335 /**
330 * Creates an [Int8List] _view_ of the specified region in the specified 336 * Creates an [Int8List] _view_ of the specified region in the specified
331 * byte buffer. Changes in the [Int8List] will be visible in the byte 337 * byte buffer. Changes in the [Int8List] will be visible in the byte
332 * buffer and vice versa. If the [offsetInBytes] index of the region is not 338 * buffer and vice versa. If the [offsetInBytes] index of the region is not
333 * specified, it defaults to zero (the first byte in the byte buffer). 339 * specified, it defaults to zero (the first byte in the byte buffer).
334 * If the length is not specified, it defaults to null, which indicates 340 * If the length is not specified, it defaults to null, which indicates
335 * that the view extends to the end of the byte buffer. 341 * that the view extends to the end of the byte buffer.
336 * 342 *
337 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 343 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
338 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 344 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
339 * the length of [buffer]. 345 * the length of [buffer].
(...skipping 11 matching lines...) Expand all
351 * more space- and time-efficient than the default [List] implementation. 357 * more space- and time-efficient than the default [List] implementation.
352 */ 358 */
353 abstract class Uint8List implements List<int>, TypedData { 359 abstract class Uint8List implements List<int>, TypedData {
354 /** 360 /**
355 * Creates a [Uint8List] of the specified length (in elements), all of 361 * Creates a [Uint8List] of the specified length (in elements), all of
356 * whose elements are initially zero. 362 * whose elements are initially zero.
357 */ 363 */
358 external factory Uint8List(int length); 364 external factory Uint8List(int length);
359 365
360 /** 366 /**
367 * Creates a [Uint8List] with the same size as the [elements] list
368 * and copies over the elements.
369 */
370 external factory Uint8List.fromList(List<int> elements);
371
372 /**
361 * Creates a [Uint8List] _view_ of the specified region in the specified 373 * Creates a [Uint8List] _view_ of the specified region in the specified
362 * byte buffer. Changes in the [Uint8List] will be visible in the byte 374 * byte buffer. Changes in the [Uint8List] will be visible in the byte
363 * buffer and vice versa. If the [offsetInBytes] index of the region is not 375 * buffer and vice versa. If the [offsetInBytes] index of the region is not
364 * specified, it defaults to zero (the first byte in the byte buffer). 376 * specified, it defaults to zero (the first byte in the byte buffer).
365 * If the length is not specified, it defaults to null, which indicates 377 * If the length is not specified, it defaults to null, which indicates
366 * that the view extends to the end of the byte buffer. 378 * that the view extends to the end of the byte buffer.
367 * 379 *
368 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 380 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
369 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 381 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
370 * the length of [buffer]. 382 * the length of [buffer].
(...skipping 12 matching lines...) Expand all
383 * Indexed store clamps the value to range 0..0xFF. 395 * Indexed store clamps the value to range 0..0xFF.
384 */ 396 */
385 abstract class Uint8ClampedList implements List<int>, TypedData { 397 abstract class Uint8ClampedList implements List<int>, TypedData {
386 /** 398 /**
387 * Creates a [Uint8ClampedList] of the specified length (in elements), all of 399 * Creates a [Uint8ClampedList] of the specified length (in elements), all of
388 * whose elements are initially zero. 400 * whose elements are initially zero.
389 */ 401 */
390 external factory Uint8ClampedList(int length); 402 external factory Uint8ClampedList(int length);
391 403
392 /** 404 /**
405 * Creates a [Uint8ClampedList] of the same size as the [elements]
406 * list and copies over the values clamping when needed.
407 */
408 external factory Uint8ClampedList.fromList(List<int> elements);
409
410 /**
393 * Creates a [Uint8ClampedList] _view_ of the specified region in the 411 * Creates a [Uint8ClampedList] _view_ of the specified region in the
394 * specified byte [buffer]. Changes in the [Uint8List] will be visible in the 412 * specified byte [buffer]. Changes in the [Uint8List] will be visible in the
395 * byte buffer and vice versa. If the [offsetInBytes] index of the region is 413 * byte buffer and vice versa. If the [offsetInBytes] index of the region is
396 * not specified, it defaults to zero (the first byte in the byte buffer). 414 * not specified, it defaults to zero (the first byte in the byte buffer).
397 * If the length is not specified, it defaults to null, which indicates that 415 * If the length is not specified, it defaults to null, which indicates that
398 * the view extends to the end of the byte buffer. 416 * the view extends to the end of the byte buffer.
399 * 417 *
400 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 418 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
401 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 419 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
402 * the length of [buffer]. 420 * the length of [buffer].
(...skipping 11 matching lines...) Expand all
414 * more space- and time-efficient than the default [List] implementation. 432 * more space- and time-efficient than the default [List] implementation.
415 */ 433 */
416 abstract class Int16List implements List<int>, TypedData { 434 abstract class Int16List implements List<int>, TypedData {
417 /** 435 /**
418 * Creates an [Int16List] of the specified length (in elements), all of 436 * Creates an [Int16List] of the specified length (in elements), all of
419 * whose elements are initially zero. 437 * whose elements are initially zero.
420 */ 438 */
421 external factory Int16List(int length); 439 external factory Int16List(int length);
422 440
423 /** 441 /**
442 * Creates a [Int16List] with the same size as the [elements] list
443 * and copies over the elements.
444 */
445 external factory Int16List.fromList(List<int> elements);
446
447 /**
424 * Creates an [Int16List] _view_ of the specified region in the specified 448 * Creates an [Int16List] _view_ of the specified region in the specified
425 * byte buffer. Changes in the [Int16List] will be visible in the byte 449 * byte buffer. Changes in the [Int16List] will be visible in the byte
426 * buffer and vice versa. If the [offsetInBytes] index of the region is not 450 * buffer and vice versa. If the [offsetInBytes] index of the region is not
427 * specified, it defaults to zero (the first byte in the byte buffer). 451 * specified, it defaults to zero (the first byte in the byte buffer).
428 * If the length is not specified, it defaults to null, which indicates 452 * If the length is not specified, it defaults to null, which indicates
429 * that the view extends to the end of the byte buffer. 453 * that the view extends to the end of the byte buffer.
430 * 454 *
431 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 455 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
432 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 456 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
433 * the length of [buffer]. 457 * the length of [buffer].
(...skipping 14 matching lines...) Expand all
448 * more space- and time-efficient than the default [List] implementation. 472 * more space- and time-efficient than the default [List] implementation.
449 */ 473 */
450 abstract class Uint16List implements List<int>, TypedData { 474 abstract class Uint16List implements List<int>, TypedData {
451 /** 475 /**
452 * Creates a [Uint16List] of the specified length (in elements), all 476 * Creates a [Uint16List] of the specified length (in elements), all
453 * of whose elements are initially zero. 477 * of whose elements are initially zero.
454 */ 478 */
455 external factory Uint16List(int length); 479 external factory Uint16List(int length);
456 480
457 /** 481 /**
482 * Creates a [Uint16List] with the same size as the [elements] list
483 * and copies over the elements.
484 */
485 external factory Uint16List.fromList(List<int> elements);
486
487 /**
458 * Creates a [Uint16List] _view_ of the specified region in 488 * Creates a [Uint16List] _view_ of the specified region in
459 * the specified byte buffer. Changes in the [Uint16List] will be 489 * the specified byte buffer. Changes in the [Uint16List] will be
460 * visible in the byte buffer and vice versa. If the [offsetInBytes] index 490 * visible in the byte buffer and vice versa. If the [offsetInBytes] index
461 * of the region is not specified, it defaults to zero (the first byte in 491 * of the region is not specified, it defaults to zero (the first byte in
462 * the byte buffer). If the length is not specified, it defaults to null, 492 * the byte buffer). If the length is not specified, it defaults to null,
463 * which indicates that the view extends to the end of the byte buffer. 493 * which indicates that the view extends to the end of the byte buffer.
464 * 494 *
465 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 495 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
466 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 496 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
467 * the length of [buffer]. 497 * the length of [buffer].
(...skipping 14 matching lines...) Expand all
482 * more space- and time-efficient than the default [List] implementation. 512 * more space- and time-efficient than the default [List] implementation.
483 */ 513 */
484 abstract class Int32List implements List<int>, TypedData { 514 abstract class Int32List implements List<int>, TypedData {
485 /** 515 /**
486 * Creates an [Int32List] of the specified length (in elements), all of 516 * Creates an [Int32List] of the specified length (in elements), all of
487 * whose elements are initially zero. 517 * whose elements are initially zero.
488 */ 518 */
489 external factory Int32List(int length); 519 external factory Int32List(int length);
490 520
491 /** 521 /**
522 * Creates a [Int32List] with the same size as the [elements] list
523 * and copies over the elements.
524 */
525 external factory Int32List.fromList(List<int> elements);
526
527 /**
492 * Creates an [Int32List] _view_ of the specified region in the specified 528 * Creates an [Int32List] _view_ of the specified region in the specified
493 * byte buffer. Changes in the [Int32List] will be visible in the byte 529 * byte buffer. Changes in the [Int32List] will be visible in the byte
494 * buffer and vice versa. If the [offsetInBytes] index of the region is not 530 * buffer and vice versa. If the [offsetInBytes] index of the region is not
495 * specified, it defaults to zero (the first byte in the byte buffer). 531 * specified, it defaults to zero (the first byte in the byte buffer).
496 * If the length is not specified, it defaults to null, which indicates 532 * If the length is not specified, it defaults to null, which indicates
497 * that the view extends to the end of the byte buffer. 533 * that the view extends to the end of the byte buffer.
498 * 534 *
499 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 535 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
500 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 536 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
501 * the length of [buffer]. 537 * the length of [buffer].
(...skipping 14 matching lines...) Expand all
516 * more space- and time-efficient than the default [List] implementation. 552 * more space- and time-efficient than the default [List] implementation.
517 */ 553 */
518 abstract class Uint32List implements List<int>, TypedData { 554 abstract class Uint32List implements List<int>, TypedData {
519 /** 555 /**
520 * Creates a [Uint32List] of the specified length (in elements), all 556 * Creates a [Uint32List] of the specified length (in elements), all
521 * of whose elements are initially zero. 557 * of whose elements are initially zero.
522 */ 558 */
523 external factory Uint32List(int length); 559 external factory Uint32List(int length);
524 560
525 /** 561 /**
562 * Creates a [Uint32List] with the same size as the [elements] list
563 * and copies over the elements.
564 */
565 external factory Uint32List.fromList(List<int> elements);
566
567 /**
526 * Creates a [Uint32List] _view_ of the specified region in 568 * Creates a [Uint32List] _view_ of the specified region in
527 * the specified byte buffer. Changes in the [Uint32] will be 569 * the specified byte buffer. Changes in the [Uint32] will be
528 * visible in the byte buffer and vice versa. If the [offsetInBytes] index 570 * visible in the byte buffer and vice versa. If the [offsetInBytes] index
529 * of the region is not specified, it defaults to zero (the first byte in 571 * of the region is not specified, it defaults to zero (the first byte in
530 * the byte buffer). If the length is not specified, it defaults to null, 572 * the byte buffer). If the length is not specified, it defaults to null,
531 * which indicates that the view extends to the end of the byte buffer. 573 * which indicates that the view extends to the end of the byte buffer.
532 * 574 *
533 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 575 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
534 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 576 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
535 * the length of [buffer]. 577 * the length of [buffer].
(...skipping 14 matching lines...) Expand all
550 * more space- and time-efficient than the default [List] implementation. 592 * more space- and time-efficient than the default [List] implementation.
551 */ 593 */
552 abstract class Int64List implements List<int>, TypedData { 594 abstract class Int64List implements List<int>, TypedData {
553 /** 595 /**
554 * Creates an [Int64List] of the specified length (in elements), all of 596 * Creates an [Int64List] of the specified length (in elements), all of
555 * whose elements are initially zero. 597 * whose elements are initially zero.
556 */ 598 */
557 external factory Int64List(int length); 599 external factory Int64List(int length);
558 600
559 /** 601 /**
602 * Creates a [Int64List] with the same size as the [elements] list
603 * and copies over the elements.
604 */
605 external factory Int64List.fromList(List<int> elements);
606
607 /**
560 * Creates an [Int64List] _view_ of the specified region in the specified 608 * Creates an [Int64List] _view_ of the specified region in the specified
561 * byte buffer. Changes in the [Int64List] will be visible in the byte buffer 609 * byte buffer. Changes in the [Int64List] will be visible in the byte buffer
562 * and vice versa. If the [offsetInBytes] index of the region is not 610 * and vice versa. If the [offsetInBytes] index of the region is not
563 * specified, it defaults to zero (the first byte in the byte buffer). 611 * specified, it defaults to zero (the first byte in the byte buffer).
564 * If the length is not specified, it defaults to null, which indicates that 612 * If the length is not specified, it defaults to null, which indicates that
565 * the view extends to the end of the byte buffer. 613 * the view extends to the end of the byte buffer.
566 * 614 *
567 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 615 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
568 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 616 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
569 * the length of [buffer]. 617 * the length of [buffer].
(...skipping 14 matching lines...) Expand all
584 * more space- and time-efficient than the default [List] implementation. 632 * more space- and time-efficient than the default [List] implementation.
585 */ 633 */
586 abstract class Uint64List implements List<int>, TypedData { 634 abstract class Uint64List implements List<int>, TypedData {
587 /** 635 /**
588 * Creates a [Uint64List] of the specified length (in elements), all 636 * Creates a [Uint64List] of the specified length (in elements), all
589 * of whose elements are initially zero. 637 * of whose elements are initially zero.
590 */ 638 */
591 external factory Uint64List(int length); 639 external factory Uint64List(int length);
592 640
593 /** 641 /**
642 * Creates a [Uint64List] with the same size as the [elements] list
643 * and copies over the elements.
644 */
645 external factory Uint64List.fromList(List<int> elements);
646
647 /**
594 * Creates an [Uint64List] _view_ of the specified region in 648 * Creates an [Uint64List] _view_ of the specified region in
595 * the specified byte buffer. Changes in the [Uint64List] will be 649 * the specified byte buffer. Changes in the [Uint64List] will be
596 * visible in the byte buffer and vice versa. If the [offsetInBytes] 650 * visible in the byte buffer and vice versa. If the [offsetInBytes]
597 * index of the region is not specified, it defaults to zero (the first 651 * index of the region is not specified, it defaults to zero (the first
598 * byte in the byte buffer). If the length is not specified, it defaults 652 * byte in the byte buffer). If the length is not specified, it defaults
599 * to null, which indicates that the view extends to the end of the byte 653 * to null, which indicates that the view extends to the end of the byte
600 * buffer. 654 * buffer.
601 * 655 *
602 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 656 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
603 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 657 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
(...skipping 16 matching lines...) Expand all
620 * the default [List] implementation. 674 * the default [List] implementation.
621 */ 675 */
622 abstract class Float32List implements List<double>, TypedData { 676 abstract class Float32List implements List<double>, TypedData {
623 /** 677 /**
624 * Creates a [Float32List] of the specified length (in elements), all of 678 * Creates a [Float32List] of the specified length (in elements), all of
625 * whose elements are initially zero. 679 * whose elements are initially zero.
626 */ 680 */
627 external factory Float32List(int length); 681 external factory Float32List(int length);
628 682
629 /** 683 /**
684 * Creates a [Float32List] with the same size as the [elements] list
685 * and copies over the elements.
686 */
687 external factory Float32List.fromList(List<double> elements);
688
689 /**
630 * Creates a [Float32List] _view_ of the specified region in the specified 690 * Creates a [Float32List] _view_ of the specified region in the specified
631 * byte buffer. Changes in the [Float32List] will be visible in the byte 691 * byte buffer. Changes in the [Float32List] will be visible in the byte
632 * buffer and vice versa. If the [offsetInBytes] index of the region is not 692 * buffer and vice versa. If the [offsetInBytes] index of the region is not
633 * specified, it defaults to zero (the first byte in the byte buffer). 693 * specified, it defaults to zero (the first byte in the byte buffer).
634 * If the length is not specified, it defaults to null, which indicates 694 * If the length is not specified, it defaults to null, which indicates
635 * that the view extends to the end of the byte buffer. 695 * that the view extends to the end of the byte buffer.
636 * 696 *
637 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 697 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
638 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 698 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
639 * the length of [buffer]. 699 * the length of [buffer].
(...skipping 15 matching lines...) Expand all
655 * the default [List] implementation. 715 * the default [List] implementation.
656 */ 716 */
657 abstract class Float64List implements List<double>, TypedData { 717 abstract class Float64List implements List<double>, TypedData {
658 /** 718 /**
659 * Creates a [Float64List] of the specified length (in elements), all of 719 * Creates a [Float64List] of the specified length (in elements), all of
660 * whose elements are initially zero. 720 * whose elements are initially zero.
661 */ 721 */
662 external factory Float64List(int length); 722 external factory Float64List(int length);
663 723
664 /** 724 /**
725 * Creates a [Float64List] with the same size as the [elements] list
726 * and copies over the elements.
727 */
728 external factory Float64List.fromList(List<double> elements);
729
730 /**
665 * Creates a [Float64List] _view_ of the specified region in the specified 731 * Creates a [Float64List] _view_ of the specified region in the specified
666 * byte buffer. Changes in the [Float64List] will be visible in the byte 732 * byte buffer. Changes in the [Float64List] will be visible in the byte
667 * buffer and vice versa. If the [offsetInBytes] index of the region is not 733 * buffer and vice versa. If the [offsetInBytes] index of the region is not
668 * specified, it defaults to zero (the first byte in the byte buffer). 734 * specified, it defaults to zero (the first byte in the byte buffer).
669 * If the length is not specified, it defaults to null, which indicates 735 * If the length is not specified, it defaults to null, which indicates
670 * that the view extends to the end of the byte buffer. 736 * that the view extends to the end of the byte buffer.
671 * 737 *
672 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or 738 * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
673 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than 739 * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
674 * the length of [buffer]. 740 * the length of [buffer].
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 Uint32x4 withFlagW(bool w); 925 Uint32x4 withFlagW(bool w);
860 926
861 /// Merge [trueValue] and [falseValue] based on [this]' bit mask: 927 /// Merge [trueValue] and [falseValue] based on [this]' bit mask:
862 /// Select bit from [trueValue] when bit in [this] is on. 928 /// Select bit from [trueValue] when bit in [this] is on.
863 /// Select bit from [falseValue] when bit in [this] is off. 929 /// Select bit from [falseValue] when bit in [this] is off.
864 Float32x4 select(Float32x4 trueValue, Float32x4 falseValue); 930 Float32x4 select(Float32x4 trueValue, Float32x4 falseValue);
865 931
866 /// Returns a bit-wise copy of [this] as a [Float32x4]. 932 /// Returns a bit-wise copy of [this] as a [Float32x4].
867 Float32x4 toFloat32x4(); 933 Float32x4 toFloat32x4();
868 } 934 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698