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

Side by Side Diff: runtime/lib/byte_array.dart

Issue 11694009: Move common logic into the base class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 patch class Int8List { 5 patch class Int8List {
6 /* patch */ factory Int8List(int length) { 6 /* patch */ factory Int8List(int length) {
7 return new _Int8Array(length); 7 return new _Int8Array(length);
8 } 8 }
9 9
10 /* patch */ factory Int8List.transferable(int length) { 10 /* patch */ factory Int8List.transferable(int length) {
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 return _array._setFloat64(_offset + byteOffset, value); 1801 return _array._setFloat64(_offset + byteOffset, value);
1802 } 1802 }
1803 1803
1804 final _ByteArrayBase _array; 1804 final _ByteArrayBase _array;
1805 final int _offset; 1805 final int _offset;
1806 final int _length; 1806 final int _length;
1807 } 1807 }
1808 1808
1809 1809
1810 class _ByteArrayViewBase { 1810 class _ByteArrayViewBase {
1811 final ByteArray _array;
cshapiro 2013/01/07 23:25:58 Can you move the private field declarations to the
Anton Muhin 2013/01/09 15:35:57 Done.
1812 final int _offset;
1813 final int length;
1814
1815 _ByteArrayViewBase(this._array, this._offset, this.length);
1816
1811 num operator[](int index); 1817 num operator[](int index);
1812 1818
1813 // Methods implementing the Collection interface. 1819 // Methods implementing the Collection interface.
1814 1820
1815 void forEach(void f(element)) { 1821 void forEach(void f(element)) {
1816 var len = this.length; 1822 var len = this.length;
1817 for (var i = 0; i < len; i++) { 1823 for (var i = 0; i < len; i++) {
1818 f(this[i]); 1824 f(this[i]);
1819 } 1825 }
1820 } 1826 }
(...skipping 16 matching lines...) Expand all
1837 } 1843 }
1838 1844
1839 bool some(bool f(element)) { 1845 bool some(bool f(element)) {
1840 return Collections.some(this, f);; 1846 return Collections.some(this, f);;
1841 } 1847 }
1842 1848
1843 bool get isEmpty { 1849 bool get isEmpty {
1844 return this.length == 0; 1850 return this.length == 0;
1845 } 1851 }
1846 1852
1847 int get length;
1848
1849 // Methods implementing the List interface. 1853 // Methods implementing the List interface.
1850 1854
1851 set length(newLength) { 1855 set length(newLength) {
1852 throw new UnsupportedError( 1856 throw new UnsupportedError(
1853 "Cannot resize a non-extendable array"); 1857 "Cannot resize a non-extendable array");
1854 } 1858 }
1855 1859
1856 void add(value) { 1860 void add(value) {
1857 throw new UnsupportedError( 1861 throw new UnsupportedError(
1858 "Cannot add to a non-extendable array"); 1862 "Cannot add to a non-extendable array");
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 } 1910 }
1907 1911
1908 void insertRange(int start, int length, [initialValue]) { 1912 void insertRange(int start, int length, [initialValue]) {
1909 throw new UnsupportedError( 1913 throw new UnsupportedError(
1910 "Cannot add to a non-extendable array"); 1914 "Cannot add to a non-extendable array");
1911 } 1915 }
1912 } 1916 }
1913 1917
1914 1918
1915 class _Int8ArrayView extends _ByteArrayViewBase implements Int8List { 1919 class _Int8ArrayView extends _ByteArrayViewBase implements Int8List {
1916 _Int8ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 1920 _Int8ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
1917 : _array = array, 1921 : super(array, _requireInteger(offsetInBytes),
1918 _offset = _requireInteger(offsetInBytes), 1922 _requireIntegerOrNull(
1919 _length = _requireIntegerOrNull( 1923 _length,
1920 length, 1924 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
1921 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 1925 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
1922 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
1923 }
1924
1925 get length {
1926 return _length;
1927 } 1926 }
1928 1927
1929 int operator[](int index) { 1928 int operator[](int index) {
1930 if (index < 0 || index >= _length) { 1929 if (index < 0 || index >= length) {
1931 String message = "$index must be in the range [0..$_length)"; 1930 String message = "$index must be in the range [0..$length)";
1932 throw new RangeError(message); 1931 throw new RangeError(message);
1933 } 1932 }
1934 return _array.getInt8(_offset + (index * _BYTES_PER_ELEMENT)); 1933 return _array.getInt8(_offset + (index * _BYTES_PER_ELEMENT));
1935 } 1934 }
1936 1935
1937 void operator[]=(int index, int value) { 1936 void operator[]=(int index, int value) {
1938 if (index < 0 || index >= _length) { 1937 if (index < 0 || index >= length) {
1939 String message = "$index must be in the range [0..$_length)"; 1938 String message = "$index must be in the range [0..$length)";
1940 throw new RangeError(message); 1939 throw new RangeError(message);
1941 } 1940 }
1942 _array.setInt8(_offset + (index * _BYTES_PER_ELEMENT), _toInt8(value)); 1941 _array.setInt8(_offset + (index * _BYTES_PER_ELEMENT), _toInt8(value));
1943 } 1942 }
1944 1943
1945 Iterator<int> iterator() { 1944 Iterator<int> iterator() {
1946 return new _ByteArrayIterator<int>(this); 1945 return new _ByteArrayIterator<int>(this);
1947 } 1946 }
1948 1947
1949 List<int> getRange(int start, int length) { 1948 List<int> getRange(int start, int length) {
1950 _rangeCheck(this.length, start, length); 1949 _rangeCheck(this.length, start, length);
1951 List<int> result = new Int8List(length); 1950 List<int> result = new Int8List(length);
1952 result.setRange(0, length, this, start); 1951 result.setRange(0, length, this, start);
1953 return result; 1952 return result;
1954 } 1953 }
1955 1954
1956 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1955 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1957 Arrays.copy(from, startFrom, this, start, length); 1956 Arrays.copy(from, startFrom, this, start, length);
1958 } 1957 }
1959 1958
1960 String toString() { 1959 String toString() {
1961 return Collections.collectionToString(this); 1960 return Collections.collectionToString(this);
1962 } 1961 }
1963 1962
1964 int bytesPerElement() { 1963 int bytesPerElement() {
1965 return _BYTES_PER_ELEMENT; 1964 return _BYTES_PER_ELEMENT;
1966 } 1965 }
1967 1966
1968 int lengthInBytes() { 1967 int lengthInBytes() {
1969 return _length * _BYTES_PER_ELEMENT; 1968 return length * _BYTES_PER_ELEMENT;
1970 } 1969 }
1971 1970
1972 ByteArray asByteArray([int start = 0, int length]) { 1971 ByteArray asByteArray([int start = 0, int length]) {
1973 if (length == null) { 1972 if (length == null) {
1974 length = this.lengthInBytes(); 1973 length = this.lengthInBytes();
1975 } 1974 }
1976 _rangeCheck(this.length, start, length); 1975 _rangeCheck(this.length, start, length);
1977 return _array.subByteArray(_offset + start, length); 1976 return _array.subByteArray(_offset + start, length);
1978 } 1977 }
1979 1978
1980 static const int _BYTES_PER_ELEMENT = 1; 1979 static const int _BYTES_PER_ELEMENT = 1;
1981 final ByteArray _array;
1982 final int _offset;
1983 final int _length;
1984 } 1980 }
1985 1981
1986 1982
1987 class _Uint8ArrayView extends _ByteArrayViewBase implements Uint8List { 1983 class _Uint8ArrayView extends _ByteArrayViewBase implements Uint8List {
1988 _Uint8ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 1984 _Uint8ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
1989 : _array = array, 1985 : super(array, _requireInteger(offsetInBytes),
1990 _offset = _requireInteger(offsetInBytes), 1986 _requireIntegerOrNull(
1991 _length = _requireIntegerOrNull( 1987 _length,
1992 length, 1988 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
1993 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 1989 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
1994 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
1995 }
1996
1997 get length {
1998 return _length;
1999 } 1990 }
2000 1991
2001 int operator[](int index) { 1992 int operator[](int index) {
2002 if (index < 0 || index >= _length) { 1993 if (index < 0 || index >= length) {
2003 String message = "$index must be in the range [0..$_length)"; 1994 String message = "$index must be in the range [0..$length)";
2004 throw new RangeError(message); 1995 throw new RangeError(message);
2005 } 1996 }
2006 return _array.getUint8(_offset + (index * _BYTES_PER_ELEMENT)); 1997 return _array.getUint8(_offset + (index * _BYTES_PER_ELEMENT));
2007 } 1998 }
2008 1999
2009 void operator[]=(int index, int value) { 2000 void operator[]=(int index, int value) {
2010 if (index < 0 || index >= _length) { 2001 if (index < 0 || index >= length) {
2011 String message = "$index must be in the range [0..$_length)"; 2002 String message = "$index must be in the range [0..$length)";
2012 throw new RangeError(message); 2003 throw new RangeError(message);
2013 } 2004 }
2014 _array.setUint8(_offset + (index * _BYTES_PER_ELEMENT), _toUint8(value)); 2005 _array.setUint8(_offset + (index * _BYTES_PER_ELEMENT), _toUint8(value));
2015 } 2006 }
2016 2007
2017 Iterator<int> iterator() { 2008 Iterator<int> iterator() {
2018 return new _ByteArrayIterator<int>(this); 2009 return new _ByteArrayIterator<int>(this);
2019 } 2010 }
2020 2011
2021 List<int> getRange(int start, int length) { 2012 List<int> getRange(int start, int length) {
2022 _rangeCheck(this.length, start, length); 2013 _rangeCheck(this.length, start, length);
2023 List<int> result = new Uint8List(length); 2014 List<int> result = new Uint8List(length);
2024 result.setRange(0, length, this, start); 2015 result.setRange(0, length, this, start);
2025 return result; 2016 return result;
2026 } 2017 }
2027 2018
2028 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2019 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2029 Arrays.copy(from, startFrom, this, start, length); 2020 Arrays.copy(from, startFrom, this, start, length);
2030 } 2021 }
2031 2022
2032 String toString() { 2023 String toString() {
2033 return Collections.collectionToString(this); 2024 return Collections.collectionToString(this);
2034 } 2025 }
2035 2026
2036 int bytesPerElement() { 2027 int bytesPerElement() {
2037 return _BYTES_PER_ELEMENT; 2028 return _BYTES_PER_ELEMENT;
2038 } 2029 }
2039 2030
2040 int lengthInBytes() { 2031 int lengthInBytes() {
2041 return _length * _BYTES_PER_ELEMENT; 2032 return length * _BYTES_PER_ELEMENT;
2042 } 2033 }
2043 2034
2044 ByteArray asByteArray([int start = 0, int length]) { 2035 ByteArray asByteArray([int start = 0, int length]) {
2045 if (length == null) { 2036 if (length == null) {
2046 length = this.lengthInBytes(); 2037 length = this.lengthInBytes();
2047 } 2038 }
2048 _rangeCheck(this.length, start, length); 2039 _rangeCheck(this.length, start, length);
2049 return _array.subByteArray(_offset + start, length); 2040 return _array.subByteArray(_offset + start, length);
2050 } 2041 }
2051 2042
2052 static const int _BYTES_PER_ELEMENT = 1; 2043 static const int _BYTES_PER_ELEMENT = 1;
2053 final ByteArray _array;
2054 final int _offset;
2055 final int _length;
2056 } 2044 }
2057 2045
2058 2046
2059 class _Int16ArrayView extends _ByteArrayViewBase implements Int16List { 2047 class _Int16ArrayView extends _ByteArrayViewBase implements Int16List {
2060 _Int16ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2048 _Int16ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
2061 : _array = array, 2049 : super(array, _requireInteger(offsetInBytes),
2062 _offset = _requireInteger(offsetInBytes), 2050 _requireIntegerOrNull(
2063 _length = _requireIntegerOrNull( 2051 _length,
2064 length, 2052 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
2065 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2053 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
2066 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2067 }
2068
2069 get length {
2070 return _length;
2071 } 2054 }
2072 2055
2073 int operator[](int index) { 2056 int operator[](int index) {
2074 if (index < 0 || index >= _length) { 2057 if (index < 0 || index >= length) {
2075 String message = "$index must be in the range [0..$_length)"; 2058 String message = "$index must be in the range [0..$length)";
2076 throw new RangeError(message); 2059 throw new RangeError(message);
2077 } 2060 }
2078 return _array.getInt16(_offset + (index * _BYTES_PER_ELEMENT)); 2061 return _array.getInt16(_offset + (index * _BYTES_PER_ELEMENT));
2079 } 2062 }
2080 2063
2081 void operator[]=(int index, int value) { 2064 void operator[]=(int index, int value) {
2082 if (index < 0 || index >= _length) { 2065 if (index < 0 || index >= length) {
2083 String message = "$index must be in the range [0..$_length)"; 2066 String message = "$index must be in the range [0..$length)";
2084 throw new RangeError(message); 2067 throw new RangeError(message);
2085 } 2068 }
2086 _array.setInt16(_offset + (index * _BYTES_PER_ELEMENT), _toInt16(value)); 2069 _array.setInt16(_offset + (index * _BYTES_PER_ELEMENT), _toInt16(value));
2087 } 2070 }
2088 2071
2089 Iterator<int> iterator() { 2072 Iterator<int> iterator() {
2090 return new _ByteArrayIterator<int>(this); 2073 return new _ByteArrayIterator<int>(this);
2091 } 2074 }
2092 2075
2093 List<int> getRange(int start, int length) { 2076 List<int> getRange(int start, int length) {
2094 _rangeCheck(this.length, start, length); 2077 _rangeCheck(this.length, start, length);
2095 List<int> result = new Int16List(length); 2078 List<int> result = new Int16List(length);
2096 result.setRange(0, length, this, start); 2079 result.setRange(0, length, this, start);
2097 return result; 2080 return result;
2098 } 2081 }
2099 2082
2100 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2083 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2101 Arrays.copy(from, startFrom, this, start, length); 2084 Arrays.copy(from, startFrom, this, start, length);
2102 } 2085 }
2103 2086
2104 String toString() { 2087 String toString() {
2105 return Collections.collectionToString(this); 2088 return Collections.collectionToString(this);
2106 } 2089 }
2107 2090
2108 int bytesPerElement() { 2091 int bytesPerElement() {
2109 return _BYTES_PER_ELEMENT; 2092 return _BYTES_PER_ELEMENT;
2110 } 2093 }
2111 2094
2112 int lengthInBytes() { 2095 int lengthInBytes() {
2113 return _length * _BYTES_PER_ELEMENT; 2096 return length * _BYTES_PER_ELEMENT;
2114 } 2097 }
2115 2098
2116 ByteArray asByteArray([int start = 0, int length]) { 2099 ByteArray asByteArray([int start = 0, int length]) {
2117 if (length == null) { 2100 if (length == null) {
2118 length = this.lengthInBytes(); 2101 length = this.lengthInBytes();
2119 } 2102 }
2120 _rangeCheck(this.length, start, length); 2103 _rangeCheck(this.length, start, length);
2121 return _array.subByteArray(_offset + start, length); 2104 return _array.subByteArray(_offset + start, length);
2122 } 2105 }
2123 2106
2124 static const int _BYTES_PER_ELEMENT = 2; 2107 static const int _BYTES_PER_ELEMENT = 2;
2125 final ByteArray _array;
2126 final int _offset;
2127 final int _length;
2128 } 2108 }
2129 2109
2130 2110
2131 class _Uint16ArrayView extends _ByteArrayViewBase implements Uint16List { 2111 class _Uint16ArrayView extends _ByteArrayViewBase implements Uint16List {
2132 _Uint16ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2112 _Uint16ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
2133 : _array = array, 2113 : super(array, _requireInteger(offsetInBytes),
2134 _offset = _requireInteger(offsetInBytes), 2114 _requireIntegerOrNull(
2135 _length = _requireIntegerOrNull( 2115 _length,
2136 length, 2116 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
2137 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2117 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
2138 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2139 }
2140
2141 get length {
2142 return _length;
2143 } 2118 }
2144 2119
2145 int operator[](int index) { 2120 int operator[](int index) {
2146 if (index < 0 || index >= _length) { 2121 if (index < 0 || index >= length) {
2147 String message = "$index must be in the range [0..$_length)"; 2122 String message = "$index must be in the range [0..$length)";
2148 throw new RangeError(message); 2123 throw new RangeError(message);
2149 } 2124 }
2150 return _array.getUint16(_offset + (index * _BYTES_PER_ELEMENT)); 2125 return _array.getUint16(_offset + (index * _BYTES_PER_ELEMENT));
2151 } 2126 }
2152 2127
2153 void operator[]=(int index, int value) { 2128 void operator[]=(int index, int value) {
2154 if (index < 0 || index >= _length) { 2129 if (index < 0 || index >= length) {
2155 String message = "$index must be in the range [0..$_length)"; 2130 String message = "$index must be in the range [0..$length)";
2156 throw new RangeError(message); 2131 throw new RangeError(message);
2157 } 2132 }
2158 _array.setUint16(_offset + (index * _BYTES_PER_ELEMENT), _toUint16(value)); 2133 _array.setUint16(_offset + (index * _BYTES_PER_ELEMENT), _toUint16(value));
2159 } 2134 }
2160 2135
2161 Iterator<int> iterator() { 2136 Iterator<int> iterator() {
2162 return new _ByteArrayIterator<int>(this); 2137 return new _ByteArrayIterator<int>(this);
2163 } 2138 }
2164 2139
2165 List<int> getRange(int start, int length) { 2140 List<int> getRange(int start, int length) {
2166 _rangeCheck(this.length, start, length); 2141 _rangeCheck(this.length, start, length);
2167 List<int> result = new Uint16List(length); 2142 List<int> result = new Uint16List(length);
2168 result.setRange(0, length, this, start); 2143 result.setRange(0, length, this, start);
2169 return result; 2144 return result;
2170 } 2145 }
2171 2146
2172 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2147 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2173 Arrays.copy(from, startFrom, this, start, length); 2148 Arrays.copy(from, startFrom, this, start, length);
2174 } 2149 }
2175 2150
2176 String toString() { 2151 String toString() {
2177 return Collections.collectionToString(this); 2152 return Collections.collectionToString(this);
2178 } 2153 }
2179 2154
2180 int bytesPerElement() { 2155 int bytesPerElement() {
2181 return _BYTES_PER_ELEMENT; 2156 return _BYTES_PER_ELEMENT;
2182 } 2157 }
2183 2158
2184 int lengthInBytes() { 2159 int lengthInBytes() {
2185 return _length * _BYTES_PER_ELEMENT; 2160 return length * _BYTES_PER_ELEMENT;
2186 } 2161 }
2187 2162
2188 ByteArray asByteArray([int start = 0, int length]) { 2163 ByteArray asByteArray([int start = 0, int length]) {
2189 if (length == null) { 2164 if (length == null) {
2190 length = this.lengthInBytes(); 2165 length = this.lengthInBytes();
2191 } 2166 }
2192 _rangeCheck(this.length, start, length); 2167 _rangeCheck(this.length, start, length);
2193 return _array.subByteArray(_offset + start, length); 2168 return _array.subByteArray(_offset + start, length);
2194 } 2169 }
2195 2170
2196 static const int _BYTES_PER_ELEMENT = 2; 2171 static const int _BYTES_PER_ELEMENT = 2;
2197 final ByteArray _array;
2198 final int _offset;
2199 final int _length;
2200 } 2172 }
2201 2173
2202 2174
2203 class _Int32ArrayView extends _ByteArrayViewBase implements Int32List { 2175 class _Int32ArrayView extends _ByteArrayViewBase implements Int32List {
2204 _Int32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2176 _Int32ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
2205 : _array = array, 2177 : super(array, _requireInteger(offsetInBytes),
2206 _offset = _requireInteger(offsetInBytes), 2178 _requireIntegerOrNull(
2207 _length = _requireIntegerOrNull( 2179 _length,
2208 length, 2180 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
2209 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2181 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
2210 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2211 }
2212
2213 get length {
2214 return _length;
2215 } 2182 }
2216 2183
2217 int operator[](int index) { 2184 int operator[](int index) {
2218 if (index < 0 || index >= _length) { 2185 if (index < 0 || index >= length) {
2219 String message = "$index must be in the range [0..$_length)"; 2186 String message = "$index must be in the range [0..$length)";
2220 throw new RangeError(message); 2187 throw new RangeError(message);
2221 } 2188 }
2222 return _array.getInt32(_offset + (index * _BYTES_PER_ELEMENT)); 2189 return _array.getInt32(_offset + (index * _BYTES_PER_ELEMENT));
2223 } 2190 }
2224 2191
2225 void operator[]=(int index, int value) { 2192 void operator[]=(int index, int value) {
2226 if (index < 0 || index >= _length) { 2193 if (index < 0 || index >= length) {
2227 String message = "$index must be in the range [0..$_length)"; 2194 String message = "$index must be in the range [0..$length)";
2228 throw new RangeError(message); 2195 throw new RangeError(message);
2229 } 2196 }
2230 _array.setInt32(_offset + (index * _BYTES_PER_ELEMENT), _toInt32(value)); 2197 _array.setInt32(_offset + (index * _BYTES_PER_ELEMENT), _toInt32(value));
2231 } 2198 }
2232 2199
2233 Iterator<int> iterator() { 2200 Iterator<int> iterator() {
2234 return new _ByteArrayIterator<int>(this); 2201 return new _ByteArrayIterator<int>(this);
2235 } 2202 }
2236 2203
2237 List<int> getRange(int start, int length) { 2204 List<int> getRange(int start, int length) {
2238 _rangeCheck(this.length, start, length); 2205 _rangeCheck(this.length, start, length);
2239 List<int> result = new Int32List(length); 2206 List<int> result = new Int32List(length);
2240 result.setRange(0, length, this, start); 2207 result.setRange(0, length, this, start);
2241 return result; 2208 return result;
2242 } 2209 }
2243 2210
2244 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2211 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2245 Arrays.copy(from, startFrom, this, start, length); 2212 Arrays.copy(from, startFrom, this, start, length);
2246 } 2213 }
2247 2214
2248 String toString() { 2215 String toString() {
2249 return Collections.collectionToString(this); 2216 return Collections.collectionToString(this);
2250 } 2217 }
2251 2218
2252 int bytesPerElement() { 2219 int bytesPerElement() {
2253 return _BYTES_PER_ELEMENT; 2220 return _BYTES_PER_ELEMENT;
2254 } 2221 }
2255 2222
2256 int lengthInBytes() { 2223 int lengthInBytes() {
2257 return _length * _BYTES_PER_ELEMENT; 2224 return length * _BYTES_PER_ELEMENT;
2258 } 2225 }
2259 2226
2260 ByteArray asByteArray([int start = 0, int length]) { 2227 ByteArray asByteArray([int start = 0, int length]) {
2261 if (length == null) { 2228 if (length == null) {
2262 length = this.lengthInBytes(); 2229 length = this.lengthInBytes();
2263 } 2230 }
2264 _rangeCheck(this.length, start, length); 2231 _rangeCheck(this.length, start, length);
2265 return _array.subByteArray(_offset + start, length); 2232 return _array.subByteArray(_offset + start, length);
2266 } 2233 }
2267 2234
2268 static const int _BYTES_PER_ELEMENT = 4; 2235 static const int _BYTES_PER_ELEMENT = 4;
2269 final ByteArray _array;
2270 final int _offset;
2271 final int _length;
2272 } 2236 }
2273 2237
2274 2238
2275 class _Uint32ArrayView extends _ByteArrayViewBase implements Uint32List { 2239 class _Uint32ArrayView extends _ByteArrayViewBase implements Uint32List {
2276 _Uint32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2240 _Uint32ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
2277 : _array = array, 2241 : super(array, _requireInteger(offsetInBytes),
2278 _offset = _requireInteger(offsetInBytes), 2242 _requireIntegerOrNull(
2279 _length = _requireIntegerOrNull( 2243 _length,
2280 length, 2244 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
2281 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2245 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
2282 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2283 }
2284
2285 get length {
2286 return _length;
2287 } 2246 }
2288 2247
2289 int operator[](int index) { 2248 int operator[](int index) {
2290 if (index < 0 || index >= _length) { 2249 if (index < 0 || index >= length) {
2291 String message = "$index must be in the range [0..$_length)"; 2250 String message = "$index must be in the range [0..$length)";
2292 throw new RangeError(message); 2251 throw new RangeError(message);
2293 } 2252 }
2294 return _array.getUint32(_offset + (index * _BYTES_PER_ELEMENT)); 2253 return _array.getUint32(_offset + (index * _BYTES_PER_ELEMENT));
2295 } 2254 }
2296 2255
2297 void operator[]=(int index, int value) { 2256 void operator[]=(int index, int value) {
2298 if (index < 0 || index >= _length) { 2257 if (index < 0 || index >= length) {
2299 String message = "$index must be in the range [0..$_length)"; 2258 String message = "$index must be in the range [0..$length)";
2300 throw new RangeError(message); 2259 throw new RangeError(message);
2301 } 2260 }
2302 _array.setUint32(_offset + (index * _BYTES_PER_ELEMENT), _toUint32(value)); 2261 _array.setUint32(_offset + (index * _BYTES_PER_ELEMENT), _toUint32(value));
2303 } 2262 }
2304 2263
2305 Iterator<int> iterator() { 2264 Iterator<int> iterator() {
2306 return new _ByteArrayIterator<int>(this); 2265 return new _ByteArrayIterator<int>(this);
2307 } 2266 }
2308 2267
2309 List<int> getRange(int start, int length) { 2268 List<int> getRange(int start, int length) {
2310 _rangeCheck(this.length, start, length); 2269 _rangeCheck(this.length, start, length);
2311 List<int> result = new Uint32List(length); 2270 List<int> result = new Uint32List(length);
2312 result.setRange(0, length, this, start); 2271 result.setRange(0, length, this, start);
2313 return result; 2272 return result;
2314 } 2273 }
2315 2274
2316 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2275 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2317 Arrays.copy(from, startFrom, this, start, length); 2276 Arrays.copy(from, startFrom, this, start, length);
2318 } 2277 }
2319 2278
2320 String toString() { 2279 String toString() {
2321 return Collections.collectionToString(this); 2280 return Collections.collectionToString(this);
2322 } 2281 }
2323 2282
2324 int bytesPerElement() { 2283 int bytesPerElement() {
2325 return _BYTES_PER_ELEMENT; 2284 return _BYTES_PER_ELEMENT;
2326 } 2285 }
2327 2286
2328 int lengthInBytes() { 2287 int lengthInBytes() {
2329 return _length * _BYTES_PER_ELEMENT; 2288 return length * _BYTES_PER_ELEMENT;
2330 } 2289 }
2331 2290
2332 ByteArray asByteArray([int start = 0, int length]) { 2291 ByteArray asByteArray([int start = 0, int length]) {
2333 if (length == null) { 2292 if (length == null) {
2334 length = this.lengthInBytes(); 2293 length = this.lengthInBytes();
2335 } 2294 }
2336 _rangeCheck(this.length, start, length); 2295 _rangeCheck(this.length, start, length);
2337 return _array.subByteArray(_offset + start, length); 2296 return _array.subByteArray(_offset + start, length);
2338 } 2297 }
2339 2298
2340 static const int _BYTES_PER_ELEMENT = 4; 2299 static const int _BYTES_PER_ELEMENT = 4;
2341 final ByteArray _array;
2342 final int _offset;
2343 final int _length;
2344 } 2300 }
2345 2301
2346 2302
2347 class _Int64ArrayView extends _ByteArrayViewBase implements Int64List { 2303 class _Int64ArrayView extends _ByteArrayViewBase implements Int64List {
2348 _Int64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2304 _Int64ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
2349 : _array = array, 2305 : super(array, _requireInteger(offsetInBytes),
2350 _offset = _requireInteger(offsetInBytes), 2306 _requireIntegerOrNull(
2351 _length = _requireIntegerOrNull( 2307 _length,
2352 length, 2308 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
2353 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2309 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
2354 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2355 }
2356
2357 get length {
2358 return _length;
2359 } 2310 }
2360 2311
2361 int operator[](int index) { 2312 int operator[](int index) {
2362 if (index < 0 || index >= _length) { 2313 if (index < 0 || index >= length) {
2363 String message = "$index must be in the range [0..$_length)"; 2314 String message = "$index must be in the range [0..$length)";
2364 throw new RangeError(message); 2315 throw new RangeError(message);
2365 } 2316 }
2366 return _array.getInt64(_offset + (index * _BYTES_PER_ELEMENT)); 2317 return _array.getInt64(_offset + (index * _BYTES_PER_ELEMENT));
2367 } 2318 }
2368 2319
2369 void operator[]=(int index, int value) { 2320 void operator[]=(int index, int value) {
2370 if (index < 0 || index >= _length) { 2321 if (index < 0 || index >= length) {
2371 String message = "$index must be in the range [0..$_length)"; 2322 String message = "$index must be in the range [0..$length)";
2372 throw new RangeError(message); 2323 throw new RangeError(message);
2373 } 2324 }
2374 _array.setInt64(_offset + (index * _BYTES_PER_ELEMENT), _toInt64(value)); 2325 _array.setInt64(_offset + (index * _BYTES_PER_ELEMENT), _toInt64(value));
2375 } 2326 }
2376 2327
2377 Iterator<int> iterator() { 2328 Iterator<int> iterator() {
2378 return new _ByteArrayIterator<int>(this); 2329 return new _ByteArrayIterator<int>(this);
2379 } 2330 }
2380 2331
2381 List<int> getRange(int start, int length) { 2332 List<int> getRange(int start, int length) {
2382 _rangeCheck(this.length, start, length); 2333 _rangeCheck(this.length, start, length);
2383 List<int> result = new Int64List(length); 2334 List<int> result = new Int64List(length);
2384 result.setRange(0, length, this, start); 2335 result.setRange(0, length, this, start);
2385 return result; 2336 return result;
2386 } 2337 }
2387 2338
2388 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2339 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2389 Arrays.copy(from, startFrom, this, start, length); 2340 Arrays.copy(from, startFrom, this, start, length);
2390 } 2341 }
2391 2342
2392 String toString() { 2343 String toString() {
2393 return Collections.collectionToString(this); 2344 return Collections.collectionToString(this);
2394 } 2345 }
2395 2346
2396 int bytesPerElement() { 2347 int bytesPerElement() {
2397 return _BYTES_PER_ELEMENT; 2348 return _BYTES_PER_ELEMENT;
2398 } 2349 }
2399 2350
2400 int lengthInBytes() { 2351 int lengthInBytes() {
2401 return _length * _BYTES_PER_ELEMENT; 2352 return length * _BYTES_PER_ELEMENT;
2402 } 2353 }
2403 2354
2404 ByteArray asByteArray([int start = 0, int length]) { 2355 ByteArray asByteArray([int start = 0, int length]) {
2405 if (length == null) { 2356 if (length == null) {
2406 length = this.lengthInBytes(); 2357 length = this.lengthInBytes();
2407 } 2358 }
2408 _rangeCheck(this.length, start, length); 2359 _rangeCheck(this.length, start, length);
2409 return _array.subByteArray(_offset + start, length); 2360 return _array.subByteArray(_offset + start, length);
2410 } 2361 }
2411 2362
2412 static const int _BYTES_PER_ELEMENT = 8; 2363 static const int _BYTES_PER_ELEMENT = 8;
2413 final ByteArray _array;
2414 final int _offset;
2415 final int _length;
2416 } 2364 }
2417 2365
2418 2366
2419 class _Uint64ArrayView extends _ByteArrayViewBase implements Uint64List { 2367 class _Uint64ArrayView extends _ByteArrayViewBase implements Uint64List {
2420 _Uint64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2368 _Uint64ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
2421 : _array = array, 2369 : super(array, _requireInteger(offsetInBytes),
2422 _offset = _requireInteger(offsetInBytes), 2370 _requireIntegerOrNull(
2423 _length = _requireIntegerOrNull( 2371 _length,
2424 length, 2372 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
2425 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2373 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
2426 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2427 }
2428
2429 get length {
2430 return _length;
2431 } 2374 }
2432 2375
2433 int operator[](int index) { 2376 int operator[](int index) {
2434 if (index < 0 || index >= _length) { 2377 if (index < 0 || index >= length) {
2435 String message = "$index must be in the range [0..$_length)"; 2378 String message = "$index must be in the range [0..$length)";
2436 throw new RangeError(message); 2379 throw new RangeError(message);
2437 } 2380 }
2438 return _array.getUint64(_offset + (index * _BYTES_PER_ELEMENT)); 2381 return _array.getUint64(_offset + (index * _BYTES_PER_ELEMENT));
2439 } 2382 }
2440 2383
2441 void operator[]=(int index, int value) { 2384 void operator[]=(int index, int value) {
2442 if (index < 0 || index >= _length) { 2385 if (index < 0 || index >= length) {
2443 String message = "$index must be in the range [0..$_length)"; 2386 String message = "$index must be in the range [0..$length)";
2444 throw new RangeError(message); 2387 throw new RangeError(message);
2445 } 2388 }
2446 _array.setUint64(_offset + (index * _BYTES_PER_ELEMENT), _toUint64(value)); 2389 _array.setUint64(_offset + (index * _BYTES_PER_ELEMENT), _toUint64(value));
2447 } 2390 }
2448 2391
2449 Iterator<int> iterator() { 2392 Iterator<int> iterator() {
2450 return new _ByteArrayIterator<int>(this); 2393 return new _ByteArrayIterator<int>(this);
2451 } 2394 }
2452 2395
2453 List<int> getRange(int start, int length) { 2396 List<int> getRange(int start, int length) {
2454 _rangeCheck(this.length, start, length); 2397 _rangeCheck(this.length, start, length);
2455 List<int> result = new Uint64List(length); 2398 List<int> result = new Uint64List(length);
2456 result.setRange(0, length, this, start); 2399 result.setRange(0, length, this, start);
2457 return result; 2400 return result;
2458 } 2401 }
2459 2402
2460 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2403 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2461 Arrays.copy(from, startFrom, this, start, length); 2404 Arrays.copy(from, startFrom, this, start, length);
2462 } 2405 }
2463 2406
2464 String toString() { 2407 String toString() {
2465 return Collections.collectionToString(this); 2408 return Collections.collectionToString(this);
2466 } 2409 }
2467 2410
2468 int bytesPerElement() { 2411 int bytesPerElement() {
2469 return _BYTES_PER_ELEMENT; 2412 return _BYTES_PER_ELEMENT;
2470 } 2413 }
2471 2414
2472 int lengthInBytes() { 2415 int lengthInBytes() {
2473 return _length * _BYTES_PER_ELEMENT; 2416 return length * _BYTES_PER_ELEMENT;
2474 } 2417 }
2475 2418
2476 ByteArray asByteArray([int start = 0, int length]) { 2419 ByteArray asByteArray([int start = 0, int length]) {
2477 if (length == null) { 2420 if (length == null) {
2478 length = this.lengthInBytes(); 2421 length = this.lengthInBytes();
2479 } 2422 }
2480 _rangeCheck(this.length, start, length); 2423 _rangeCheck(this.length, start, length);
2481 return _array.subByteArray(_offset + start, length); 2424 return _array.subByteArray(_offset + start, length);
2482 } 2425 }
2483 2426
2484 static const int _BYTES_PER_ELEMENT = 8; 2427 static const int _BYTES_PER_ELEMENT = 8;
2485 final ByteArray _array;
2486 final int _offset;
2487 final int _length;
2488 } 2428 }
2489 2429
2490 2430
2491 class _Float32ArrayView extends _ByteArrayViewBase implements Float32List { 2431 class _Float32ArrayView extends _ByteArrayViewBase implements Float32List {
2492 _Float32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2432 _Float32ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
2493 : _array = array, 2433 : super(array, _requireInteger(offsetInBytes),
2494 _offset = _requireInteger(offsetInBytes), 2434 _requireIntegerOrNull(
2495 _length = _requireIntegerOrNull( 2435 _length,
2496 length, 2436 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
2497 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2437 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
2498 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2499 }
2500
2501 get length {
2502 return _length;
2503 } 2438 }
2504 2439
2505 double operator[](int index) { 2440 double operator[](int index) {
2506 if (index < 0 || index >= _length) { 2441 if (index < 0 || index >= length) {
2507 String message = "$index must be in the range [0..$_length)"; 2442 String message = "$index must be in the range [0..$length)";
2508 throw new RangeError(message); 2443 throw new RangeError(message);
2509 } 2444 }
2510 return _array.getFloat32(_offset + (index * _BYTES_PER_ELEMENT)); 2445 return _array.getFloat32(_offset + (index * _BYTES_PER_ELEMENT));
2511 } 2446 }
2512 2447
2513 void operator[]=(int index, double value) { 2448 void operator[]=(int index, double value) {
2514 if (index < 0 || index >= _length) { 2449 if (index < 0 || index >= length) {
2515 String message = "$index must be in the range [0..$_length)"; 2450 String message = "$index must be in the range [0..$length)";
2516 throw new RangeError(message); 2451 throw new RangeError(message);
2517 } 2452 }
2518 _array.setFloat32(_offset + (index * _BYTES_PER_ELEMENT), value); 2453 _array.setFloat32(_offset + (index * _BYTES_PER_ELEMENT), value);
2519 } 2454 }
2520 2455
2521 Iterator<double> iterator() { 2456 Iterator<double> iterator() {
2522 return new _ByteArrayIterator<double>(this); 2457 return new _ByteArrayIterator<double>(this);
2523 } 2458 }
2524 2459
2525 List<double> getRange(int start, int length) { 2460 List<double> getRange(int start, int length) {
2526 _rangeCheck(this.length, start, length); 2461 _rangeCheck(this.length, start, length);
2527 List<double> result = new Float32List(length); 2462 List<double> result = new Float32List(length);
2528 result.setRange(0, length, this, start); 2463 result.setRange(0, length, this, start);
2529 return result; 2464 return result;
2530 } 2465 }
2531 2466
2532 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { 2467 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
2533 Arrays.copy(from, startFrom, this, start, length); 2468 Arrays.copy(from, startFrom, this, start, length);
2534 } 2469 }
2535 2470
2536 String toString() { 2471 String toString() {
2537 return Collections.collectionToString(this); 2472 return Collections.collectionToString(this);
2538 } 2473 }
2539 2474
2540 int bytesPerElement() { 2475 int bytesPerElement() {
2541 return _BYTES_PER_ELEMENT; 2476 return _BYTES_PER_ELEMENT;
2542 } 2477 }
2543 2478
2544 int lengthInBytes() { 2479 int lengthInBytes() {
2545 return _length * _BYTES_PER_ELEMENT; 2480 return length * _BYTES_PER_ELEMENT;
2546 } 2481 }
2547 2482
2548 ByteArray asByteArray([int start = 0, int length]) { 2483 ByteArray asByteArray([int start = 0, int length]) {
2549 if (length == null) { 2484 if (length == null) {
2550 length = this.lengthInBytes(); 2485 length = this.lengthInBytes();
2551 } 2486 }
2552 _rangeCheck(this.length, start, length); 2487 _rangeCheck(this.length, start, length);
2553 return _array.subByteArray(_offset + start, length); 2488 return _array.subByteArray(_offset + start, length);
2554 } 2489 }
2555 2490
2556 static const int _BYTES_PER_ELEMENT = 4; 2491 static const int _BYTES_PER_ELEMENT = 4;
2557 final ByteArray _array;
2558 final int _offset;
2559 final int _length;
2560 } 2492 }
2561 2493
2562 2494
2563 class _Float64ArrayView extends _ByteArrayViewBase implements Float64List { 2495 class _Float64ArrayView extends _ByteArrayViewBase implements Float64List {
2564 _Float64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2496 _Float64ArrayView(ByteArray array, [int offsetInBytes = 0, int _length])
2565 : _array = array, 2497 : super(array, _requireInteger(offsetInBytes),
2566 _offset = _requireInteger(offsetInBytes), 2498 _requireIntegerOrNull(
2567 _length = _requireIntegerOrNull( 2499 _length,
2568 length, 2500 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) {
2569 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2501 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT);
2570 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2571 }
2572
2573 get length {
2574 return _length;
2575 } 2502 }
2576 2503
2577 double operator[](int index) { 2504 double operator[](int index) {
2578 if (index < 0 || index >= _length) { 2505 if (index < 0 || index >= length) {
2579 String message = "$index must be in the range [0..$_length)"; 2506 String message = "$index must be in the range [0..$length)";
2580 throw new RangeError(message); 2507 throw new RangeError(message);
2581 } 2508 }
2582 return _array.getFloat64(_offset + (index * _BYTES_PER_ELEMENT)); 2509 return _array.getFloat64(_offset + (index * _BYTES_PER_ELEMENT));
2583 } 2510 }
2584 2511
2585 void operator[]=(int index, double value) { 2512 void operator[]=(int index, double value) {
2586 if (index < 0 || index >= _length) { 2513 if (index < 0 || index >= length) {
2587 String message = "$index must be in the range [0..$_length)"; 2514 String message = "$index must be in the range [0..$length)";
2588 throw new RangeError(message); 2515 throw new RangeError(message);
2589 } 2516 }
2590 _array.setFloat64(_offset + (index * _BYTES_PER_ELEMENT), value); 2517 _array.setFloat64(_offset + (index * _BYTES_PER_ELEMENT), value);
2591 } 2518 }
2592 2519
2593 Iterator<double> iterator() { 2520 Iterator<double> iterator() {
2594 return new _ByteArrayIterator<double>(this); 2521 return new _ByteArrayIterator<double>(this);
2595 } 2522 }
2596 2523
2597 List<double> getRange(int start, int length) { 2524 List<double> getRange(int start, int length) {
2598 _rangeCheck(this.length, start, length); 2525 _rangeCheck(this.length, start, length);
2599 List<double> result = new Float64List(length); 2526 List<double> result = new Float64List(length);
2600 result.setRange(0, length, this, start); 2527 result.setRange(0, length, this, start);
2601 return result; 2528 return result;
2602 } 2529 }
2603 2530
2604 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { 2531 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
2605 Arrays.copy(from, startFrom, this, start, length); 2532 Arrays.copy(from, startFrom, this, start, length);
2606 } 2533 }
2607 2534
2608 String toString() { 2535 String toString() {
2609 return Collections.collectionToString(this); 2536 return Collections.collectionToString(this);
2610 } 2537 }
2611 2538
2612 int bytesPerElement() { 2539 int bytesPerElement() {
2613 return _BYTES_PER_ELEMENT; 2540 return _BYTES_PER_ELEMENT;
2614 } 2541 }
2615 2542
2616 int lengthInBytes() { 2543 int lengthInBytes() {
2617 return _length * _BYTES_PER_ELEMENT; 2544 return length * _BYTES_PER_ELEMENT;
2618 } 2545 }
2619 2546
2620 ByteArray asByteArray([int start = 0, int length]) { 2547 ByteArray asByteArray([int start = 0, int length]) {
2621 if (length == null) { 2548 if (length == null) {
2622 length = this.lengthInBytes(); 2549 length = this.lengthInBytes();
2623 } 2550 }
2624 _rangeCheck(this.length, start, length); 2551 _rangeCheck(this.length, start, length);
2625 return _array.subByteArray(_offset + start, length); 2552 return _array.subByteArray(_offset + start, length);
2626 } 2553 }
2627 2554
2628 static const int _BYTES_PER_ELEMENT = 8; 2555 static const int _BYTES_PER_ELEMENT = 8;
2629 final ByteArray _array;
2630 final int _offset;
2631 final int _length;
2632 } 2556 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698