| 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 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.view(ByteArray array, | 10 /* patch */ factory Int8List.view(ByteArray array, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return this.length === 0; | 157 return this.length === 0; |
| 158 } | 158 } |
| 159 | 159 |
| 160 int get length { | 160 int get length { |
| 161 return _length(); | 161 return _length(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // Methods implementing the List interface. | 164 // Methods implementing the List interface. |
| 165 | 165 |
| 166 set length(newLength) { | 166 set length(newLength) { |
| 167 throw const UnsupportedOperationException( | 167 throw new StateError( |
| 168 "Cannot resize a non-extendable array"); | 168 "Cannot resize a non-extendable array"); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void add(value) { | 171 void add(value) { |
| 172 throw const UnsupportedOperationException( | 172 throw new StateError( |
| 173 "Cannot add to a non-extendable array"); | 173 "Cannot add to a non-extendable array"); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void addLast(value) { | 176 void addLast(value) { |
| 177 throw const UnsupportedOperationException( | 177 throw new StateError( |
| 178 "Cannot add to a non-extendable array"); | 178 "Cannot add to a non-extendable array"); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void addAll(Collection value) { | 181 void addAll(Collection value) { |
| 182 throw const UnsupportedOperationException( | 182 throw new StateError( |
| 183 "Cannot add to a non-extendable array"); | 183 "Cannot add to a non-extendable array"); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void sort([Comparator compare = Comparable.compare]) { | 186 void sort([Comparator compare = Comparable.compare]) { |
| 187 DualPivotQuicksort.sort(this, compare); | 187 DualPivotQuicksort.sort(this, compare); |
| 188 } | 188 } |
| 189 | 189 |
| 190 int indexOf(element, [int start = 0]) { | 190 int indexOf(element, [int start = 0]) { |
| 191 return Arrays.indexOf(this, element, start, this.length); | 191 return Arrays.indexOf(this, element, start, this.length); |
| 192 } | 192 } |
| 193 | 193 |
| 194 int lastIndexOf(element, [int start = null]) { | 194 int lastIndexOf(element, [int start = null]) { |
| 195 if (start === null) start = length - 1; | 195 if (start === null) start = length - 1; |
| 196 return Arrays.lastIndexOf(this, element, start); | 196 return Arrays.lastIndexOf(this, element, start); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void clear() { | 199 void clear() { |
| 200 throw const UnsupportedOperationException( | 200 throw new StateError( |
| 201 "Cannot remove from a non-extendable array"); | 201 "Cannot remove from a non-extendable array"); |
| 202 } | 202 } |
| 203 | 203 |
| 204 int removeLast() { | 204 int removeLast() { |
| 205 throw const UnsupportedOperationException( | 205 throw new StateError( |
| 206 "Cannot remove from a non-extendable array"); | 206 "Cannot remove from a non-extendable array"); |
| 207 } | 207 } |
| 208 | 208 |
| 209 last() { | 209 last() { |
| 210 return this[length - 1]; | 210 return this[length - 1]; |
| 211 } | 211 } |
| 212 | 212 |
| 213 void removeRange(int start, int length) { | 213 void removeRange(int start, int length) { |
| 214 throw const UnsupportedOperationException( | 214 throw new StateError( |
| 215 "Cannot remove from a non-extendable array"); | 215 "Cannot remove from a non-extendable array"); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void insertRange(int start, int length, [initialValue]) { | 218 void insertRange(int start, int length, [initialValue]) { |
| 219 throw const UnsupportedOperationException( | 219 throw new StateError( |
| 220 "Cannot add to a non-extendable array"); | 220 "Cannot add to a non-extendable array"); |
| 221 } | 221 } |
| 222 | 222 |
| 223 ByteArray asByteArray([int start = 0, int length]) { | 223 ByteArray asByteArray([int start = 0, int length]) { |
| 224 if (length === null) { | 224 if (length === null) { |
| 225 length = this.length; | 225 length = this.length; |
| 226 } | 226 } |
| 227 _rangeCheck(this.length, start, length); | 227 _rangeCheck(this.length, start, length); |
| 228 return new _ByteArrayView(this, | 228 return new _ByteArrayView(this, |
| 229 start * this.bytesPerElement(), | 229 start * this.bytesPerElement(), |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 | 1635 |
| 1636 bool isEmpty() { | 1636 bool isEmpty() { |
| 1637 return this.length === 0; | 1637 return this.length === 0; |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 abstract int get length; | 1640 abstract int get length; |
| 1641 | 1641 |
| 1642 // Methods implementing the List interface. | 1642 // Methods implementing the List interface. |
| 1643 | 1643 |
| 1644 set length(newLength) { | 1644 set length(newLength) { |
| 1645 throw const UnsupportedOperationException( | 1645 throw new StateError( |
| 1646 "Cannot resize a non-extendable array"); | 1646 "Cannot resize a non-extendable array"); |
| 1647 } | 1647 } |
| 1648 | 1648 |
| 1649 void add(value) { | 1649 void add(value) { |
| 1650 throw const UnsupportedOperationException( | 1650 throw new StateError( |
| 1651 "Cannot add to a non-extendable array"); | 1651 "Cannot add to a non-extendable array"); |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 void addLast(value) { | 1654 void addLast(value) { |
| 1655 throw const UnsupportedOperationException( | 1655 throw new StateError( |
| 1656 "Cannot add to a non-extendable array"); | 1656 "Cannot add to a non-extendable array"); |
| 1657 } | 1657 } |
| 1658 | 1658 |
| 1659 void addAll(Collection value) { | 1659 void addAll(Collection value) { |
| 1660 throw const UnsupportedOperationException( | 1660 throw new StateError( |
| 1661 "Cannot add to a non-extendable array"); | 1661 "Cannot add to a non-extendable array"); |
| 1662 } | 1662 } |
| 1663 | 1663 |
| 1664 void sort([Comparator compare = Comparable.compare]) { | 1664 void sort([Comparator compare = Comparable.compare]) { |
| 1665 DualPivotQuicksort.sort(this, compare); | 1665 DualPivotQuicksort.sort(this, compare); |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 int indexOf(element, [int start = 0]) { | 1668 int indexOf(element, [int start = 0]) { |
| 1669 return Arrays.indexOf(this, element, start, this.length); | 1669 return Arrays.indexOf(this, element, start, this.length); |
| 1670 } | 1670 } |
| 1671 | 1671 |
| 1672 int lastIndexOf(element, [int start = null]) { | 1672 int lastIndexOf(element, [int start = null]) { |
| 1673 if (start === null) start = length - 1; | 1673 if (start === null) start = length - 1; |
| 1674 return Arrays.lastIndexOf(this, element, start); | 1674 return Arrays.lastIndexOf(this, element, start); |
| 1675 } | 1675 } |
| 1676 | 1676 |
| 1677 void clear() { | 1677 void clear() { |
| 1678 throw const UnsupportedOperationException( | 1678 throw new StateError( |
| 1679 "Cannot remove from a non-extendable array"); | 1679 "Cannot remove from a non-extendable array"); |
| 1680 } | 1680 } |
| 1681 | 1681 |
| 1682 int removeLast() { | 1682 int removeLast() { |
| 1683 throw const UnsupportedOperationException( | 1683 throw new StateError( |
| 1684 "Cannot remove from a non-extendable array"); | 1684 "Cannot remove from a non-extendable array"); |
| 1685 } | 1685 } |
| 1686 | 1686 |
| 1687 last() { | 1687 last() { |
| 1688 return this[length - 1]; | 1688 return this[length - 1]; |
| 1689 } | 1689 } |
| 1690 | 1690 |
| 1691 void removeRange(int start, int length) { | 1691 void removeRange(int start, int length) { |
| 1692 throw const UnsupportedOperationException( | 1692 throw new StateError( |
| 1693 "Cannot remove from a non-extendable array"); | 1693 "Cannot remove from a non-extendable array"); |
| 1694 } | 1694 } |
| 1695 | 1695 |
| 1696 void insertRange(int start, int length, [initialValue]) { | 1696 void insertRange(int start, int length, [initialValue]) { |
| 1697 throw const UnsupportedOperationException( | 1697 throw new StateError( |
| 1698 "Cannot add to a non-extendable array"); | 1698 "Cannot add to a non-extendable array"); |
| 1699 } | 1699 } |
| 1700 } | 1700 } |
| 1701 | 1701 |
| 1702 | 1702 |
| 1703 class _Int8ArrayView extends _ByteArrayViewBase implements Int8List { | 1703 class _Int8ArrayView extends _ByteArrayViewBase implements Int8List { |
| 1704 _Int8ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) | 1704 _Int8ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) |
| 1705 : _array = array, | 1705 : _array = array, |
| 1706 _offset = _requireInteger(offsetInBytes), | 1706 _offset = _requireInteger(offsetInBytes), |
| 1707 _length = _requireIntegerOrNull( | 1707 _length = _requireIntegerOrNull( |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2411 } | 2411 } |
| 2412 _rangeCheck(this.length, start, length); | 2412 _rangeCheck(this.length, start, length); |
| 2413 return _array.subByteArray(_offset + start, length); | 2413 return _array.subByteArray(_offset + start, length); |
| 2414 } | 2414 } |
| 2415 | 2415 |
| 2416 static const int _BYTES_PER_ELEMENT = 8; | 2416 static const int _BYTES_PER_ELEMENT = 8; |
| 2417 final ByteArray _array; | 2417 final ByteArray _array; |
| 2418 final int _offset; | 2418 final int _offset; |
| 2419 final int _length; | 2419 final int _length; |
| 2420 } | 2420 } |
| OLD | NEW |