| 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 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2374 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2374 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2375 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2375 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2376 } | 2376 } |
| 2377 | 2377 |
| 2378 get length() { | 2378 get length() { |
| 2379 return _length; | 2379 return _length; |
| 2380 } | 2380 } |
| 2381 | 2381 |
| 2382 int operator[](int index) { | 2382 int operator[](int index) { |
| 2383 if (index < 0 || index >= _length) { | 2383 if (index < 0 || index >= _length) { |
| 2384 throw new IndexOutOfRangeException(index); | 2384 String message = "$index must be in the range [0..$_length)"; |
| 2385 throw new IndexOutOfRangeException(message); |
| 2385 } | 2386 } |
| 2386 return _array.getInt8(_offset + (index * _BYTES_PER_ELEMENT)); | 2387 return _array.getInt8(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2387 } | 2388 } |
| 2388 | 2389 |
| 2389 void operator[]=(int index, int value) { | 2390 void operator[]=(int index, int value) { |
| 2390 if (index < 0 || index >= _length) { | 2391 if (index < 0 || index >= _length) { |
| 2391 throw new IndexOutOfRangeException(index); | 2392 String message = "$index must be in the range [0..$_length)"; |
| 2393 throw new IndexOutOfRangeException(message); |
| 2392 } | 2394 } |
| 2393 _array.setInt8(_offset + (index * _BYTES_PER_ELEMENT), _toInt8(value)); | 2395 _array.setInt8(_offset + (index * _BYTES_PER_ELEMENT), _toInt8(value)); |
| 2394 } | 2396 } |
| 2395 | 2397 |
| 2396 Iterator<int> iterator() { | 2398 Iterator<int> iterator() { |
| 2397 return new _ByteArrayIterator<int>(this); | 2399 return new _ByteArrayIterator<int>(this); |
| 2398 } | 2400 } |
| 2399 | 2401 |
| 2400 List<int> getRange(int start, int length) { | 2402 List<int> getRange(int start, int length) { |
| 2401 _rangeCheck(this.length, start, length); | 2403 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2444 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2446 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2445 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2447 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2446 } | 2448 } |
| 2447 | 2449 |
| 2448 get length() { | 2450 get length() { |
| 2449 return _length; | 2451 return _length; |
| 2450 } | 2452 } |
| 2451 | 2453 |
| 2452 int operator[](int index) { | 2454 int operator[](int index) { |
| 2453 if (index < 0 || index >= _length) { | 2455 if (index < 0 || index >= _length) { |
| 2454 throw new IndexOutOfRangeException(index); | 2456 String message = "$index must be in the range [0..$_length)"; |
| 2457 throw new IndexOutOfRangeException(message); |
| 2455 } | 2458 } |
| 2456 return _array.getUint8(_offset + (index * _BYTES_PER_ELEMENT)); | 2459 return _array.getUint8(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2457 } | 2460 } |
| 2458 | 2461 |
| 2459 void operator[]=(int index, int value) { | 2462 void operator[]=(int index, int value) { |
| 2460 if (index < 0 || index >= _length) { | 2463 if (index < 0 || index >= _length) { |
| 2461 throw new IndexOutOfRangeException(index); | 2464 String message = "$index must be in the range [0..$_length)"; |
| 2465 throw new IndexOutOfRangeException(message); |
| 2462 } | 2466 } |
| 2463 _array.setUint8(_offset + (index * _BYTES_PER_ELEMENT), _toUint8(value)); | 2467 _array.setUint8(_offset + (index * _BYTES_PER_ELEMENT), _toUint8(value)); |
| 2464 } | 2468 } |
| 2465 | 2469 |
| 2466 Iterator<int> iterator() { | 2470 Iterator<int> iterator() { |
| 2467 return new _ByteArrayIterator<int>(this); | 2471 return new _ByteArrayIterator<int>(this); |
| 2468 } | 2472 } |
| 2469 | 2473 |
| 2470 List<int> getRange(int start, int length) { | 2474 List<int> getRange(int start, int length) { |
| 2471 _rangeCheck(this.length, start, length); | 2475 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2514 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2518 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2515 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2519 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2516 } | 2520 } |
| 2517 | 2521 |
| 2518 get length() { | 2522 get length() { |
| 2519 return _length; | 2523 return _length; |
| 2520 } | 2524 } |
| 2521 | 2525 |
| 2522 int operator[](int index) { | 2526 int operator[](int index) { |
| 2523 if (index < 0 || index >= _length) { | 2527 if (index < 0 || index >= _length) { |
| 2524 throw new IndexOutOfRangeException(index); | 2528 String message = "$index must be in the range [0..$_length)"; |
| 2529 throw new IndexOutOfRangeException(message); |
| 2525 } | 2530 } |
| 2526 return _array.getInt16(_offset + (index * _BYTES_PER_ELEMENT)); | 2531 return _array.getInt16(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2527 } | 2532 } |
| 2528 | 2533 |
| 2529 void operator[]=(int index, int value) { | 2534 void operator[]=(int index, int value) { |
| 2530 if (index < 0 || index >= _length) { | 2535 if (index < 0 || index >= _length) { |
| 2531 throw new IndexOutOfRangeException(index); | 2536 String message = "$index must be in the range [0..$_length)"; |
| 2537 throw new IndexOutOfRangeException(message); |
| 2532 } | 2538 } |
| 2533 _array.setInt16(_offset + (index * _BYTES_PER_ELEMENT), _toInt16(value)); | 2539 _array.setInt16(_offset + (index * _BYTES_PER_ELEMENT), _toInt16(value)); |
| 2534 } | 2540 } |
| 2535 | 2541 |
| 2536 Iterator<int> iterator() { | 2542 Iterator<int> iterator() { |
| 2537 return new _ByteArrayIterator<int>(this); | 2543 return new _ByteArrayIterator<int>(this); |
| 2538 } | 2544 } |
| 2539 | 2545 |
| 2540 List<int> getRange(int start, int length) { | 2546 List<int> getRange(int start, int length) { |
| 2541 _rangeCheck(this.length, start, length); | 2547 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2584 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2590 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2585 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2591 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2586 } | 2592 } |
| 2587 | 2593 |
| 2588 get length() { | 2594 get length() { |
| 2589 return _length; | 2595 return _length; |
| 2590 } | 2596 } |
| 2591 | 2597 |
| 2592 int operator[](int index) { | 2598 int operator[](int index) { |
| 2593 if (index < 0 || index >= _length) { | 2599 if (index < 0 || index >= _length) { |
| 2594 throw new IndexOutOfRangeException(index); | 2600 String message = "$index must be in the range [0..$_length)"; |
| 2601 throw new IndexOutOfRangeException(message); |
| 2595 } | 2602 } |
| 2596 return _array.getUint16(_offset + (index * _BYTES_PER_ELEMENT)); | 2603 return _array.getUint16(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2597 } | 2604 } |
| 2598 | 2605 |
| 2599 void operator[]=(int index, int value) { | 2606 void operator[]=(int index, int value) { |
| 2600 if (index < 0 || index >= _length) { | 2607 if (index < 0 || index >= _length) { |
| 2601 throw new IndexOutOfRangeException(index); | 2608 String message = "$index must be in the range [0..$_length)"; |
| 2609 throw new IndexOutOfRangeException(message); |
| 2602 } | 2610 } |
| 2603 _array.setUint16(_offset + (index * _BYTES_PER_ELEMENT), _toUint16(value)); | 2611 _array.setUint16(_offset + (index * _BYTES_PER_ELEMENT), _toUint16(value)); |
| 2604 } | 2612 } |
| 2605 | 2613 |
| 2606 Iterator<int> iterator() { | 2614 Iterator<int> iterator() { |
| 2607 return new _ByteArrayIterator<int>(this); | 2615 return new _ByteArrayIterator<int>(this); |
| 2608 } | 2616 } |
| 2609 | 2617 |
| 2610 List<int> getRange(int start, int length) { | 2618 List<int> getRange(int start, int length) { |
| 2611 _rangeCheck(this.length, start, length); | 2619 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2662 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2655 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2663 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2656 } | 2664 } |
| 2657 | 2665 |
| 2658 get length() { | 2666 get length() { |
| 2659 return _length; | 2667 return _length; |
| 2660 } | 2668 } |
| 2661 | 2669 |
| 2662 int operator[](int index) { | 2670 int operator[](int index) { |
| 2663 if (index < 0 || index >= _length) { | 2671 if (index < 0 || index >= _length) { |
| 2664 throw new IndexOutOfRangeException(index); | 2672 String message = "$index must be in the range [0..$_length)"; |
| 2673 throw new IndexOutOfRangeException(message); |
| 2665 } | 2674 } |
| 2666 return _array.getInt32(_offset + (index * _BYTES_PER_ELEMENT)); | 2675 return _array.getInt32(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2667 } | 2676 } |
| 2668 | 2677 |
| 2669 void operator[]=(int index, int value) { | 2678 void operator[]=(int index, int value) { |
| 2670 if (index < 0 || index >= _length) { | 2679 if (index < 0 || index >= _length) { |
| 2671 throw new IndexOutOfRangeException(index); | 2680 String message = "$index must be in the range [0..$_length)"; |
| 2681 throw new IndexOutOfRangeException(message); |
| 2672 } | 2682 } |
| 2673 _array.setInt32(_offset + (index * _BYTES_PER_ELEMENT), _toInt32(value)); | 2683 _array.setInt32(_offset + (index * _BYTES_PER_ELEMENT), _toInt32(value)); |
| 2674 } | 2684 } |
| 2675 | 2685 |
| 2676 Iterator<int> iterator() { | 2686 Iterator<int> iterator() { |
| 2677 return new _ByteArrayIterator<int>(this); | 2687 return new _ByteArrayIterator<int>(this); |
| 2678 } | 2688 } |
| 2679 | 2689 |
| 2680 List<int> getRange(int start, int length) { | 2690 List<int> getRange(int start, int length) { |
| 2681 _rangeCheck(this.length, start, length); | 2691 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2724 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2734 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2725 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2735 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2726 } | 2736 } |
| 2727 | 2737 |
| 2728 get length() { | 2738 get length() { |
| 2729 return _length; | 2739 return _length; |
| 2730 } | 2740 } |
| 2731 | 2741 |
| 2732 int operator[](int index) { | 2742 int operator[](int index) { |
| 2733 if (index < 0 || index >= _length) { | 2743 if (index < 0 || index >= _length) { |
| 2734 throw new IndexOutOfRangeException(index); | 2744 String message = "$index must be in the range [0..$_length)"; |
| 2745 throw new IndexOutOfRangeException(message); |
| 2735 } | 2746 } |
| 2736 return _array.getUint32(_offset + (index * _BYTES_PER_ELEMENT)); | 2747 return _array.getUint32(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2737 } | 2748 } |
| 2738 | 2749 |
| 2739 void operator[]=(int index, int value) { | 2750 void operator[]=(int index, int value) { |
| 2740 if (index < 0 || index >= _length) { | 2751 if (index < 0 || index >= _length) { |
| 2741 throw new IndexOutOfRangeException(index); | 2752 String message = "$index must be in the range [0..$_length)"; |
| 2753 throw new IndexOutOfRangeException(message); |
| 2742 } | 2754 } |
| 2743 _array.setUint32(_offset + (index * _BYTES_PER_ELEMENT), _toUint32(value)); | 2755 _array.setUint32(_offset + (index * _BYTES_PER_ELEMENT), _toUint32(value)); |
| 2744 } | 2756 } |
| 2745 | 2757 |
| 2746 Iterator<int> iterator() { | 2758 Iterator<int> iterator() { |
| 2747 return new _ByteArrayIterator<int>(this); | 2759 return new _ByteArrayIterator<int>(this); |
| 2748 } | 2760 } |
| 2749 | 2761 |
| 2750 List<int> getRange(int start, int length) { | 2762 List<int> getRange(int start, int length) { |
| 2751 _rangeCheck(this.length, start, length); | 2763 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2794 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2806 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2795 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2807 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2796 } | 2808 } |
| 2797 | 2809 |
| 2798 get length() { | 2810 get length() { |
| 2799 return _length; | 2811 return _length; |
| 2800 } | 2812 } |
| 2801 | 2813 |
| 2802 int operator[](int index) { | 2814 int operator[](int index) { |
| 2803 if (index < 0 || index >= _length) { | 2815 if (index < 0 || index >= _length) { |
| 2804 throw new IndexOutOfRangeException(index); | 2816 String message = "$index must be in the range [0..$_length)"; |
| 2817 throw new IndexOutOfRangeException(message); |
| 2805 } | 2818 } |
| 2806 return _array.getInt64(_offset + (index * _BYTES_PER_ELEMENT)); | 2819 return _array.getInt64(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2807 } | 2820 } |
| 2808 | 2821 |
| 2809 void operator[]=(int index, int value) { | 2822 void operator[]=(int index, int value) { |
| 2810 if (index < 0 || index >= _length) { | 2823 if (index < 0 || index >= _length) { |
| 2811 throw new IndexOutOfRangeException(index); | 2824 String message = "$index must be in the range [0..$_length)"; |
| 2825 throw new IndexOutOfRangeException(message); |
| 2812 } | 2826 } |
| 2813 _array.setInt64(_offset + (index * _BYTES_PER_ELEMENT), _toInt64(value)); | 2827 _array.setInt64(_offset + (index * _BYTES_PER_ELEMENT), _toInt64(value)); |
| 2814 } | 2828 } |
| 2815 | 2829 |
| 2816 Iterator<int> iterator() { | 2830 Iterator<int> iterator() { |
| 2817 return new _ByteArrayIterator<int>(this); | 2831 return new _ByteArrayIterator<int>(this); |
| 2818 } | 2832 } |
| 2819 | 2833 |
| 2820 List<int> getRange(int start, int length) { | 2834 List<int> getRange(int start, int length) { |
| 2821 _rangeCheck(this.length, start, length); | 2835 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2864 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2878 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2865 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2879 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2866 } | 2880 } |
| 2867 | 2881 |
| 2868 get length() { | 2882 get length() { |
| 2869 return _length; | 2883 return _length; |
| 2870 } | 2884 } |
| 2871 | 2885 |
| 2872 int operator[](int index) { | 2886 int operator[](int index) { |
| 2873 if (index < 0 || index >= _length) { | 2887 if (index < 0 || index >= _length) { |
| 2874 throw new IndexOutOfRangeException(index); | 2888 String message = "$index must be in the range [0..$_length)"; |
| 2889 throw new IndexOutOfRangeException(message); |
| 2875 } | 2890 } |
| 2876 return _array.getUint64(_offset + (index * _BYTES_PER_ELEMENT)); | 2891 return _array.getUint64(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2877 } | 2892 } |
| 2878 | 2893 |
| 2879 void operator[]=(int index, int value) { | 2894 void operator[]=(int index, int value) { |
| 2880 if (index < 0 || index >= _length) { | 2895 if (index < 0 || index >= _length) { |
| 2881 throw new IndexOutOfRangeException(index); | 2896 String message = "$index must be in the range [0..$_length)"; |
| 2897 throw new IndexOutOfRangeException(message); |
| 2882 } | 2898 } |
| 2883 _array.setUint64(_offset + (index * _BYTES_PER_ELEMENT), _toUint64(value)); | 2899 _array.setUint64(_offset + (index * _BYTES_PER_ELEMENT), _toUint64(value)); |
| 2884 } | 2900 } |
| 2885 | 2901 |
| 2886 Iterator<int> iterator() { | 2902 Iterator<int> iterator() { |
| 2887 return new _ByteArrayIterator<int>(this); | 2903 return new _ByteArrayIterator<int>(this); |
| 2888 } | 2904 } |
| 2889 | 2905 |
| 2890 List<int> getRange(int start, int length) { | 2906 List<int> getRange(int start, int length) { |
| 2891 _rangeCheck(this.length, start, length); | 2907 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2934 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 2950 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 2935 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 2951 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 2936 } | 2952 } |
| 2937 | 2953 |
| 2938 get length() { | 2954 get length() { |
| 2939 return _length; | 2955 return _length; |
| 2940 } | 2956 } |
| 2941 | 2957 |
| 2942 double operator[](int index) { | 2958 double operator[](int index) { |
| 2943 if (index < 0 || index >= _length) { | 2959 if (index < 0 || index >= _length) { |
| 2944 throw new IndexOutOfRangeException(index); | 2960 String message = "$index must be in the range [0..$_length)"; |
| 2961 throw new IndexOutOfRangeException(message); |
| 2945 } | 2962 } |
| 2946 return _array.getFloat32(_offset + (index * _BYTES_PER_ELEMENT)); | 2963 return _array.getFloat32(_offset + (index * _BYTES_PER_ELEMENT)); |
| 2947 } | 2964 } |
| 2948 | 2965 |
| 2949 void operator[]=(int index, double value) { | 2966 void operator[]=(int index, double value) { |
| 2950 if (index < 0 || index >= _length) { | 2967 if (index < 0 || index >= _length) { |
| 2951 throw new IndexOutOfRangeException(index); | 2968 String message = "$index must be in the range [0..$_length)"; |
| 2969 throw new IndexOutOfRangeException(message); |
| 2952 } | 2970 } |
| 2953 _array.setFloat32(_offset + (index * _BYTES_PER_ELEMENT), value); | 2971 _array.setFloat32(_offset + (index * _BYTES_PER_ELEMENT), value); |
| 2954 } | 2972 } |
| 2955 | 2973 |
| 2956 Iterator<double> iterator() { | 2974 Iterator<double> iterator() { |
| 2957 return new _ByteArrayIterator<double>(this); | 2975 return new _ByteArrayIterator<double>(this); |
| 2958 } | 2976 } |
| 2959 | 2977 |
| 2960 List<double> getRange(int start, int length) { | 2978 List<double> getRange(int start, int length) { |
| 2961 _rangeCheck(this.length, start, length); | 2979 _rangeCheck(this.length, start, length); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3004 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { | 3022 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { |
| 3005 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); | 3023 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); |
| 3006 } | 3024 } |
| 3007 | 3025 |
| 3008 get length() { | 3026 get length() { |
| 3009 return _length; | 3027 return _length; |
| 3010 } | 3028 } |
| 3011 | 3029 |
| 3012 double operator[](int index) { | 3030 double operator[](int index) { |
| 3013 if (index < 0 || index >= _length) { | 3031 if (index < 0 || index >= _length) { |
| 3014 throw new IndexOutOfRangeException(index); | 3032 String message = "$index must be in the range [0..$_length)"; |
| 3033 throw new IndexOutOfRangeException(message); |
| 3015 } | 3034 } |
| 3016 return _array.getFloat64(_offset + (index * _BYTES_PER_ELEMENT)); | 3035 return _array.getFloat64(_offset + (index * _BYTES_PER_ELEMENT)); |
| 3017 } | 3036 } |
| 3018 | 3037 |
| 3019 void operator[]=(int index, double value) { | 3038 void operator[]=(int index, double value) { |
| 3020 if (index < 0 || index >= _length) { | 3039 if (index < 0 || index >= _length) { |
| 3021 throw new IndexOutOfRangeException(index); | 3040 String message = "$index must be in the range [0..$_length)"; |
| 3041 throw new IndexOutOfRangeException(message); |
| 3022 } | 3042 } |
| 3023 _array.setFloat64(_offset + (index * _BYTES_PER_ELEMENT), value); | 3043 _array.setFloat64(_offset + (index * _BYTES_PER_ELEMENT), value); |
| 3024 } | 3044 } |
| 3025 | 3045 |
| 3026 Iterator<double> iterator() { | 3046 Iterator<double> iterator() { |
| 3027 return new _ByteArrayIterator<double>(this); | 3047 return new _ByteArrayIterator<double>(this); |
| 3028 } | 3048 } |
| 3029 | 3049 |
| 3030 List<double> getRange(int start, int length) { | 3050 List<double> getRange(int start, int length) { |
| 3031 _rangeCheck(this.length, start, length); | 3051 _rangeCheck(this.length, start, length); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3056 } | 3076 } |
| 3057 _rangeCheck(this.length, start, length); | 3077 _rangeCheck(this.length, start, length); |
| 3058 return _array.subByteArray(_offset + start, length); | 3078 return _array.subByteArray(_offset + start, length); |
| 3059 } | 3079 } |
| 3060 | 3080 |
| 3061 static final int _BYTES_PER_ELEMENT = 8; | 3081 static final int _BYTES_PER_ELEMENT = 8; |
| 3062 final ByteArray _array; | 3082 final ByteArray _array; |
| 3063 final int _offset; | 3083 final int _offset; |
| 3064 final int _length; | 3084 final int _length; |
| 3065 } | 3085 } |
| OLD | NEW |