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

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

Issue 10653002: Fix some warnings in the core library identified by the static analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 6 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 | « corelib/src/string_buffer.dart ('k') | runtime/lib/growable_array.dart » ('j') | 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 /** 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 */ 678 */
679 Float64List.view(ByteArray array, [int start, int length]); 679 Float64List.view(ByteArray array, [int start, int length]);
680 } 680 }
681 681
682 682
683 class _Int8ArrayFactory { 683 class _Int8ArrayFactory {
684 factory Int8List(int length) { 684 factory Int8List(int length) {
685 return new _Int8Array(length); 685 return new _Int8Array(length);
686 } 686 }
687 687
688 factory Int8List.view(ByteArray array, [int start, int length]) { 688 factory Int8List.view(ByteArray array, [int start = 0, int length]) {
689 return new _Int8ArrayView(array, start, length); 689 return new _Int8ArrayView(array, start, length);
690 } 690 }
691 } 691 }
692 692
693 693
694 class _Uint8ArrayFactory { 694 class _Uint8ArrayFactory {
695 factory Uint8List(int length) { 695 factory Uint8List(int length) {
696 return new _Uint8Array(length); 696 return new _Uint8Array(length);
697 } 697 }
698 698
699 factory Uint8List.view(ByteArray array, [int start, int length]) { 699 factory Uint8List.view(ByteArray array, [int start = 0, int length]) {
700 return new _Uint8ArrayView(array, start, length); 700 return new _Uint8ArrayView(array, start, length);
701 } 701 }
702 } 702 }
703 703
704 704
705 class _Int16ArrayFactory { 705 class _Int16ArrayFactory {
706 factory Int16List(int length) { 706 factory Int16List(int length) {
707 return new _Int16Array(length); 707 return new _Int16Array(length);
708 } 708 }
709 709
710 factory Int16List.view(ByteArray array, [int start, int length]) { 710 factory Int16List.view(ByteArray array, [int start = 0, int length]) {
711 return new _Int16ArrayView(array, start, length); 711 return new _Int16ArrayView(array, start, length);
712 } 712 }
713 } 713 }
714 714
715 715
716 class _Uint16ArrayFactory { 716 class _Uint16ArrayFactory {
717 factory Uint16List(int length) { 717 factory Uint16List(int length) {
718 return new _Uint16Array(length); 718 return new _Uint16Array(length);
719 } 719 }
720 720
721 factory Uint16List.view(ByteArray array, [int start, int length]) { 721 factory Uint16List.view(ByteArray array, [int start = 0, int length]) {
722 return new _Uint16ArrayView(array, start, length); 722 return new _Uint16ArrayView(array, start, length);
723 } 723 }
724 } 724 }
725 725
726 726
727 class _Int32ArrayFactory { 727 class _Int32ArrayFactory {
728 factory Int32List(int length) { 728 factory Int32List(int length) {
729 return new _Int32Array(length); 729 return new _Int32Array(length);
730 } 730 }
731 731
732 factory Int32List.view(ByteArray array, [int start, int length]) { 732 factory Int32List.view(ByteArray array, [int start = 0, int length]) {
733 return new _Int32ArrayView(array, start, length); 733 return new _Int32ArrayView(array, start, length);
734 } 734 }
735 } 735 }
736 736
737 737
738 class _Uint32ArrayFactory { 738 class _Uint32ArrayFactory {
739 factory Uint32List(int length) { 739 factory Uint32List(int length) {
740 return new _Uint32Array(length); 740 return new _Uint32Array(length);
741 } 741 }
742 742
743 factory Uint32List.view(ByteArray array, [int start, int length]) { 743 factory Uint32List.view(ByteArray array, [int start = 0, int length]) {
744 return new _Uint32ArrayView(array, start, length); 744 return new _Uint32ArrayView(array, start, length);
745 } 745 }
746 } 746 }
747 747
748 748
749 class _Int64ArrayFactory { 749 class _Int64ArrayFactory {
750 factory Int64List(int length) { 750 factory Int64List(int length) {
751 return new _Int64Array(length); 751 return new _Int64Array(length);
752 } 752 }
753 753
754 factory Int64List.view(ByteArray array, [int start, int length]) { 754 factory Int64List.view(ByteArray array, [int start = 0, int length]) {
755 return new _Int64ArrayView(array, start, length); 755 return new _Int64ArrayView(array, start, length);
756 } 756 }
757 } 757 }
758 758
759 759
760 class _Uint64ArrayFactory { 760 class _Uint64ArrayFactory {
761 factory Uint64List(int length) { 761 factory Uint64List(int length) {
762 return new _Uint64Array(length); 762 return new _Uint64Array(length);
763 } 763 }
764 764
765 factory Uint64List.view(ByteArray array, [int start, int length]) { 765 factory Uint64List.view(ByteArray array, [int start = 0, int length]) {
766 return new _Uint64ArrayView(array, start, length); 766 return new _Uint64ArrayView(array, start, length);
767 } 767 }
768 } 768 }
769 769
770 770
771 class _Float32ArrayFactory { 771 class _Float32ArrayFactory {
772 factory Float32List(int length) { 772 factory Float32List(int length) {
773 return new _Float32Array(length); 773 return new _Float32Array(length);
774 } 774 }
775 775
776 factory Float32List.view(ByteArray array, [int start, int length]) { 776 factory Float32List.view(ByteArray array, [int start = 0, int length]) {
777 return new _Float32ArrayView(array, start, length); 777 return new _Float32ArrayView(array, start, length);
778 } 778 }
779 } 779 }
780 780
781 781
782 class _Float64ArrayFactory { 782 class _Float64ArrayFactory {
783 factory Float64List(int length) { 783 factory Float64List(int length) {
784 return new _Float64Array(length); 784 return new _Float64Array(length);
785 } 785 }
786 786
787 factory Float64List.view(ByteArray array, [int start, int length]) { 787 factory Float64List.view(ByteArray array, [int start = 0, int length]) {
788 return new _Float64ArrayView(array, start, length); 788 return new _Float64ArrayView(array, start, length);
789 } 789 }
790 } 790 }
791 791
792 792
793 abstract class _ByteArrayBase { 793 abstract class _ByteArrayBase {
794 abstract int lengthInBytes();
795
796 abstract int bytesPerElement();
797
798 abstract operator[](int index);
794 799
795 // Methods implementing the Collection interface. 800 // Methods implementing the Collection interface.
796 801
797 void forEach(void f(element)) { 802 void forEach(void f(element)) {
798 var len = this.length; 803 var len = this.length;
799 for (var i = 0; i < len; i++) { 804 for (var i = 0; i < len; i++) {
800 f(this[i]); 805 f(this[i]);
801 } 806 }
802 } 807 }
803 808
804 Collection map(f(element)) { 809 Collection map(f(element)) {
805 return Collections.map(this, 810 return Collections.map(this,
806 new GrowableObjectArray.withCapacity(length), 811 new GrowableObjectArray.withCapacity(length),
807 f); 812 f);
808 } 813 }
809 814
810 Collection filter(bool f(element)) { 815 Collection filter(bool f(element)) {
811 return Collections.filter(this, new GrowableObjectArray(), f); 816 return Collections.filter(this, new GrowableObjectArray(), f);
812 } 817 }
813 818
814 bool every(bool f(element)) { 819 bool every(bool f(element)) {
815 return Collections.every(this, f); 820 return Collections.every(this, f);
816 } 821 }
817 822
818 bool some(bool f(element)) { 823 bool some(bool f(element)) {
819 return Collections.some(this, f);; 824 return Collections.some(this, f);
820 } 825 }
821 826
822 bool isEmpty() { 827 bool isEmpty() {
823 return this.length === 0; 828 return this.length === 0;
824 } 829 }
825 830
826 int get length() { 831 int get length() {
827 return _length(); 832 return _length();
828 } 833 }
829 834
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 "Cannot remove from a non-extendable array"); 886 "Cannot remove from a non-extendable array");
882 } 887 }
883 888
884 void insertRange(int start, int length, [initialValue]) { 889 void insertRange(int start, int length, [initialValue]) {
885 throw const UnsupportedOperationException( 890 throw const UnsupportedOperationException(
886 "Cannot add to a non-extendable array"); 891 "Cannot add to a non-extendable array");
887 } 892 }
888 893
889 ByteArray asByteArray([int start = 0, int length]) { 894 ByteArray asByteArray([int start = 0, int length]) {
890 if (length === null) { 895 if (length === null) {
891 length = this.lengthInBytes(); 896 length = this.length;
892 } 897 }
893 return new _ByteArrayView(this, start, length); 898 _rangeCheck(this.length, start, length);
899 return new _ByteArrayView(this,
900 start * this.bytesPerElement(),
901 length * this.bytesPerElement());
894 } 902 }
895 903
896 int _length() native "ByteArray_getLength"; 904 int _length() native "ByteArray_getLength";
897 905
898 void _setRange(int startInBytes, int lengthInBytes, 906 void _setRange(int startInBytes, int lengthInBytes,
899 _ByteArrayBase from, int startFromInBytes) 907 _ByteArrayBase from, int startFromInBytes)
900 native "ByteArray_setRange"; 908 native "ByteArray_setRange";
901 909
902 int _getInt8(int byteOffset) native "ByteArray_getInt8"; 910 int _getInt8(int byteOffset) native "ByteArray_getInt8";
903 int _setInt8(int byteOffset, int value) native "ByteArray_setInt8"; 911 int _setInt8(int byteOffset, int value) native "ByteArray_setInt8";
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 970
963 971
964 int _toInt64(int value) { 972 int _toInt64(int value) {
965 return _toInt(value, 0xFFFFFFFFFFFFFFFF); 973 return _toInt(value, 0xFFFFFFFFFFFFFFFF);
966 } 974 }
967 int _toUint64(int value) { 975 int _toUint64(int value) {
968 return value & 0xFFFFFFFFFFFFFFFF; 976 return value & 0xFFFFFFFFFFFFFFFF;
969 } 977 }
970 978
971 979
972 void _rangeCheck(List a, int start, int length) { 980 void _rangeCheck(int listLength, int start, int length) {
973 if (length < 0) { 981 if (length < 0) {
974 throw new IllegalArgumentException("negative length $length"); 982 throw new IndexOutOfRangeException(length);
975 } 983 }
976 if (start < 0) { 984 if (start < 0) {
977 throw new IndexOutOfRangeException("negative start $start"); 985 throw new IndexOutOfRangeException(start);
978 } 986 }
979 if (start + length > a.length) { 987 if (start + length > listLength) {
980 throw new IndexOutOfRangeException(start + length); 988 throw new IndexOutOfRangeException(start + length);
981 } 989 }
982 } 990 }
983 991
984 992
993 int _requireInteger(object) {
994 if (object is int) {
995 return object;
996 }
997 throw new IllegalArgumentException("$object is not an integer");
998 }
999
1000
1001 int _requireIntegerOrNull(object, value) {
1002 if (object is int) {
1003 return object;
1004 }
1005 if (object === null) {
1006 return _requireInteger(value);
1007 }
1008 throw new IllegalArgumentException("$object is not an integer or null");
1009 }
1010
1011
985 class _Int8Array extends _ByteArrayBase implements Int8List { 1012 class _Int8Array extends _ByteArrayBase implements Int8List {
986 factory _Int8Array(int length) { 1013 factory _Int8Array(int length) {
987 return _new(length); 1014 return _new(length);
988 } 1015 }
989 1016
990 factory _Int8Array.view(ByteArray array, [int start = 0, int length]) { 1017 factory _Int8Array.view(ByteArray array, [int start = 0, int length]) {
991 if (length === null) { 1018 if (length === null) {
992 length = array.lengthInBytes(); 1019 length = array.lengthInBytes();
993 } 1020 }
994 return new _Int8ArrayView(array, start, length); 1021 return new _Int8ArrayView(array, start, length);
995 } 1022 }
996 1023
997 int operator[](int index) { 1024 int operator[](int index) {
998 return _getIndexed(index); 1025 return _getIndexed(index);
999 } 1026 }
1000 1027
1001 void operator[]=(int index, int value) { 1028 void operator[]=(int index, int value) {
1002 _setIndexed(index, _toInt8(value)); 1029 _setIndexed(index, _toInt8(value));
1003 } 1030 }
1004 1031
1005 Iterator<int> iterator() { 1032 Iterator<int> iterator() {
1006 return new _ByteArrayIterator<int>(this); 1033 return new _ByteArrayIterator<int>(this);
1007 } 1034 }
1008 1035
1009 List<int> getRange(int start, int length) { 1036 List<int> getRange(int start, int length) {
1010 _rangeCheck(this, start, length); 1037 _rangeCheck(this.length, start, length);
1011 List<int> result = _new(length); 1038 List<int> result = _new(length);
1012 result.setRange(0, length, this, start); 1039 result.setRange(0, length, this, start);
1013 return result; 1040 return result;
1014 } 1041 }
1015 1042
1016 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1043 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1017 if (from is _Int8Array) { 1044 if (from is _Int8Array) {
1018 int startInBytes = start * _BYTES_PER_ELEMENT; 1045 _setRange(start * _BYTES_PER_ELEMENT,
1019 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1046 length * _BYTES_PER_ELEMENT,
1020 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1047 from,
1021 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1048 startFrom * _BYTES_PER_ELEMENT);
1022 } else { 1049 } else {
1023 Arrays.copy(from, startFrom, this, start, length); 1050 Arrays.copy(from, startFrom, this, start, length);
1024 } 1051 }
1025 } 1052 }
1026 1053
1027 String toString() { 1054 String toString() {
1028 return Collections.collectionToString(this); 1055 return Collections.collectionToString(this);
1029 } 1056 }
1030 1057
1031 int bytesPerElement() { 1058 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 1090
1064 void operator[]=(int index, int value) { 1091 void operator[]=(int index, int value) {
1065 _setIndexed(index, _toUint8(value)); 1092 _setIndexed(index, _toUint8(value));
1066 } 1093 }
1067 1094
1068 Iterator<int> iterator() { 1095 Iterator<int> iterator() {
1069 return new _ByteArrayIterator<int>(this); 1096 return new _ByteArrayIterator<int>(this);
1070 } 1097 }
1071 1098
1072 List<int> getRange(int start, int length) { 1099 List<int> getRange(int start, int length) {
1073 _rangeCheck(this, start, length); 1100 _rangeCheck(this.length, start, length);
1074 List<int> result = _new(length); 1101 List<int> result = _new(length);
1075 result.setRange(0, length, this, start); 1102 result.setRange(0, length, this, start);
1076 return result; 1103 return result;
1077 } 1104 }
1078 1105
1079 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1106 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1080 if (from is _Uint8Array) { 1107 if (from is _Uint8Array) {
1081 int startInBytes = start * _BYTES_PER_ELEMENT; 1108 _setRange(start * _BYTES_PER_ELEMENT,
1082 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1109 length * _BYTES_PER_ELEMENT,
1083 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1110 from,
1084 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1111 startFrom * _BYTES_PER_ELEMENT);
1085 } else { 1112 } else {
1086 Arrays.copy(from, startFrom, this, start, length); 1113 Arrays.copy(from, startFrom, this, start, length);
1087 } 1114 }
1088 } 1115 }
1089 1116
1090 String toString() { 1117 String toString() {
1091 return Collections.collectionToString(this); 1118 return Collections.collectionToString(this);
1092 } 1119 }
1093 1120
1094 int bytesPerElement() { 1121 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 1153
1127 void operator[]=(int index, int value) { 1154 void operator[]=(int index, int value) {
1128 _setIndexed(index, _toInt16(value)); 1155 _setIndexed(index, _toInt16(value));
1129 } 1156 }
1130 1157
1131 Iterator<int> iterator() { 1158 Iterator<int> iterator() {
1132 return new _ByteArrayIterator<int>(this); 1159 return new _ByteArrayIterator<int>(this);
1133 } 1160 }
1134 1161
1135 List<int> getRange(int start, int length) { 1162 List<int> getRange(int start, int length) {
1136 _rangeCheck(this, start, length); 1163 _rangeCheck(this.length, start, length);
1137 List<int> result = _new(length); 1164 List<int> result = _new(length);
1138 result.setRange(0, length, this, start); 1165 result.setRange(0, length, this, start);
1139 return result; 1166 return result;
1140 } 1167 }
1141 1168
1142 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1169 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1143 if (from is _Int16Array) { 1170 if (from is _Int16Array) {
1144 int startInBytes = start * _BYTES_PER_ELEMENT; 1171 _setRange(start * _BYTES_PER_ELEMENT,
1145 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1172 length * _BYTES_PER_ELEMENT,
1146 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1173 from,
1147 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1174 startFrom * _BYTES_PER_ELEMENT);
1148 } else { 1175 } else {
1149 Arrays.copy(from, startFrom, this, start, length); 1176 Arrays.copy(from, startFrom, this, start, length);
1150 } 1177 }
1151 } 1178 }
1152 1179
1153 String toString() { 1180 String toString() {
1154 return Collections.collectionToString(this); 1181 return Collections.collectionToString(this);
1155 } 1182 }
1156 1183
1157 int bytesPerElement() { 1184 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 1216
1190 void operator[]=(int index, int value) { 1217 void operator[]=(int index, int value) {
1191 _setIndexed(index, _toUint16(value)); 1218 _setIndexed(index, _toUint16(value));
1192 } 1219 }
1193 1220
1194 Iterator<int> iterator() { 1221 Iterator<int> iterator() {
1195 return new _ByteArrayIterator<int>(this); 1222 return new _ByteArrayIterator<int>(this);
1196 } 1223 }
1197 1224
1198 List<int> getRange(int start, int length) { 1225 List<int> getRange(int start, int length) {
1199 _rangeCheck(this, start, length); 1226 _rangeCheck(this.length, start, length);
1200 List<int> result = _new(length); 1227 List<int> result = _new(length);
1201 result.setRange(0, length, this, start); 1228 result.setRange(0, length, this, start);
1202 return result; 1229 return result;
1203 } 1230 }
1204 1231
1205 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1232 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1206 if (from is _Uint16Array) { 1233 if (from is _Uint16Array) {
1207 int startInBytes = start * _BYTES_PER_ELEMENT; 1234 _setRange(start * _BYTES_PER_ELEMENT,
1208 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1235 length * _BYTES_PER_ELEMENT,
1209 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1236 from,
1210 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1237 startFrom * _BYTES_PER_ELEMENT);
1211 } else { 1238 } else {
1212 Arrays.copy(from, startFrom, this, start, length); 1239 Arrays.copy(from, startFrom, this, start, length);
1213 } 1240 }
1214 } 1241 }
1215 1242
1216 String toString() { 1243 String toString() {
1217 return Collections.collectionToString(this); 1244 return Collections.collectionToString(this);
1218 } 1245 }
1219 1246
1220 int bytesPerElement() { 1247 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 1279
1253 void operator[]=(int index, int value) { 1280 void operator[]=(int index, int value) {
1254 _setIndexed(index, _toInt32(value)); 1281 _setIndexed(index, _toInt32(value));
1255 } 1282 }
1256 1283
1257 Iterator<int> iterator() { 1284 Iterator<int> iterator() {
1258 return new _ByteArrayIterator<int>(this); 1285 return new _ByteArrayIterator<int>(this);
1259 } 1286 }
1260 1287
1261 List<int> getRange(int start, int length) { 1288 List<int> getRange(int start, int length) {
1262 _rangeCheck(this, start, length); 1289 _rangeCheck(this.length, start, length);
1263 List<int> result = _new(length); 1290 List<int> result = _new(length);
1264 result.setRange(0, length, this, start); 1291 result.setRange(0, length, this, start);
1265 return result; 1292 return result;
1266 } 1293 }
1267 1294
1268 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1295 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1269 if (from is _Int32Array) { 1296 if (from is _Int32Array) {
1270 int startInBytes = start * _BYTES_PER_ELEMENT; 1297 _setRange(start * _BYTES_PER_ELEMENT,
1271 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1298 length * _BYTES_PER_ELEMENT,
1272 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1299 from,
1273 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1300 startFrom * _BYTES_PER_ELEMENT);
1274 } else { 1301 } else {
1275 Arrays.copy(from, startFrom, this, start, length); 1302 Arrays.copy(from, startFrom, this, start, length);
1276 } 1303 }
1277 } 1304 }
1278 1305
1279 String toString() { 1306 String toString() {
1280 return Collections.collectionToString(this); 1307 return Collections.collectionToString(this);
1281 } 1308 }
1282 1309
1283 int bytesPerElement() { 1310 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 1342
1316 void operator[]=(int index, int value) { 1343 void operator[]=(int index, int value) {
1317 _setIndexed(index, _toUint32(value)); 1344 _setIndexed(index, _toUint32(value));
1318 } 1345 }
1319 1346
1320 Iterator<int> iterator() { 1347 Iterator<int> iterator() {
1321 return new _ByteArrayIterator<int>(this); 1348 return new _ByteArrayIterator<int>(this);
1322 } 1349 }
1323 1350
1324 List<int> getRange(int start, int length) { 1351 List<int> getRange(int start, int length) {
1325 _rangeCheck(this, start, length); 1352 _rangeCheck(this.length, start, length);
1326 List<int> result = _new(length); 1353 List<int> result = _new(length);
1327 result.setRange(0, length, this, start); 1354 result.setRange(0, length, this, start);
1328 return result; 1355 return result;
1329 } 1356 }
1330 1357
1331 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1358 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1332 if (from is _Uint32Array) { 1359 if (from is _Uint32Array) {
1333 int startInBytes = start * _BYTES_PER_ELEMENT; 1360 _setRange(start * _BYTES_PER_ELEMENT,
1334 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1361 length * _BYTES_PER_ELEMENT,
1335 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1362 from,
1336 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1363 startFrom * _BYTES_PER_ELEMENT);
1337 } else { 1364 } else {
1338 Arrays.copy(from, startFrom, this, start, length); 1365 Arrays.copy(from, startFrom, this, start, length);
1339 } 1366 }
1340 } 1367 }
1341 1368
1342 String toString() { 1369 String toString() {
1343 return Collections.collectionToString(this); 1370 return Collections.collectionToString(this);
1344 } 1371 }
1345 1372
1346 int bytesPerElement() { 1373 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 1405
1379 void operator[]=(int index, int value) { 1406 void operator[]=(int index, int value) {
1380 _setIndexed(index, _toInt64(value)); 1407 _setIndexed(index, _toInt64(value));
1381 } 1408 }
1382 1409
1383 Iterator<int> iterator() { 1410 Iterator<int> iterator() {
1384 return new _ByteArrayIterator<int>(this); 1411 return new _ByteArrayIterator<int>(this);
1385 } 1412 }
1386 1413
1387 List<int> getRange(int start, int length) { 1414 List<int> getRange(int start, int length) {
1388 _rangeCheck(this, start, length); 1415 _rangeCheck(this.length, start, length);
1389 List<int> result = _new(length); 1416 List<int> result = _new(length);
1390 result.setRange(0, length, this, start); 1417 result.setRange(0, length, this, start);
1391 return result; 1418 return result;
1392 } 1419 }
1393 1420
1394 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1421 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1395 if (from is _Int64Array) { 1422 if (from is _Int64Array) {
1396 int startInBytes = start * _BYTES_PER_ELEMENT; 1423 _setRange(start * _BYTES_PER_ELEMENT,
1397 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1424 length * _BYTES_PER_ELEMENT,
1398 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1425 from,
1399 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1426 startFrom * _BYTES_PER_ELEMENT);
1400 } else { 1427 } else {
1401 Arrays.copy(from, startFrom, this, start, length); 1428 Arrays.copy(from, startFrom, this, start, length);
1402 } 1429 }
1403 } 1430 }
1404 1431
1405 String toString() { 1432 String toString() {
1406 return Collections.collectionToString(this); 1433 return Collections.collectionToString(this);
1407 } 1434 }
1408 1435
1409 int bytesPerElement() { 1436 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1468
1442 void operator[]=(int index, int value) { 1469 void operator[]=(int index, int value) {
1443 _setIndexed(index, _toUint64(value)); 1470 _setIndexed(index, _toUint64(value));
1444 } 1471 }
1445 1472
1446 Iterator<int> iterator() { 1473 Iterator<int> iterator() {
1447 return new _ByteArrayIterator<int>(this); 1474 return new _ByteArrayIterator<int>(this);
1448 } 1475 }
1449 1476
1450 List<int> getRange(int start, int length) { 1477 List<int> getRange(int start, int length) {
1451 _rangeCheck(this, start, length); 1478 _rangeCheck(this.length, start, length);
1452 List<int> result = _new(length); 1479 List<int> result = _new(length);
1453 result.setRange(0, length, this, start); 1480 result.setRange(0, length, this, start);
1454 return result; 1481 return result;
1455 } 1482 }
1456 1483
1457 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1484 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1458 if (from is _Uint64Array) { 1485 if (from is _Uint64Array) {
1459 int startInBytes = start * _BYTES_PER_ELEMENT; 1486 _setRange(start * _BYTES_PER_ELEMENT,
1460 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1487 length * _BYTES_PER_ELEMENT,
1461 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1488 from,
1462 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1489 startFrom * _BYTES_PER_ELEMENT);
1463 } else { 1490 } else {
1464 Arrays.copy(from, startFrom, this, start, length); 1491 Arrays.copy(from, startFrom, this, start, length);
1465 } 1492 }
1466 } 1493 }
1467 1494
1468 String toString() { 1495 String toString() {
1469 return Collections.collectionToString(this); 1496 return Collections.collectionToString(this);
1470 } 1497 }
1471 1498
1472 int bytesPerElement() { 1499 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1531
1505 void operator[]=(int index, double value) { 1532 void operator[]=(int index, double value) {
1506 _setIndexed(index, value); 1533 _setIndexed(index, value);
1507 } 1534 }
1508 1535
1509 Iterator<double> iterator() { 1536 Iterator<double> iterator() {
1510 return new _ByteArrayIterator<double>(this); 1537 return new _ByteArrayIterator<double>(this);
1511 } 1538 }
1512 1539
1513 List<double> getRange(int start, int length) { 1540 List<double> getRange(int start, int length) {
1514 _rangeCheck(this, start, length); 1541 _rangeCheck(this.length, start, length);
1515 List<double> result = _new(length); 1542 List<double> result = _new(length);
1516 result.setRange(0, length, this, start); 1543 result.setRange(0, length, this, start);
1517 return result; 1544 return result;
1518 } 1545 }
1519 1546
1520 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { 1547 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
1521 if (from is _Float32Array) { 1548 if (from is _Float32Array) {
1522 int startInBytes = start * _BYTES_PER_ELEMENT; 1549 _setRange(start * _BYTES_PER_ELEMENT,
1523 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1550 length * _BYTES_PER_ELEMENT,
1524 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1551 from,
1525 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1552 startFrom * _BYTES_PER_ELEMENT);
1526 } else { 1553 } else {
1527 Arrays.copy(from, startFrom, this, start, length); 1554 Arrays.copy(from, startFrom, this, start, length);
1528 } 1555 }
1529 } 1556 }
1530 1557
1531 String toString() { 1558 String toString() {
1532 return Collections.collectionToString(this); 1559 return Collections.collectionToString(this);
1533 } 1560 }
1534 1561
1535 int bytesPerElement() { 1562 int bytesPerElement() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 1594
1568 void operator[]=(int index, double value) { 1595 void operator[]=(int index, double value) {
1569 _setIndexed(index, value); 1596 _setIndexed(index, value);
1570 } 1597 }
1571 1598
1572 Iterator<double> iterator() { 1599 Iterator<double> iterator() {
1573 return new _ByteArrayIterator<double>(this); 1600 return new _ByteArrayIterator<double>(this);
1574 } 1601 }
1575 1602
1576 List<double> getRange(int start, int length) { 1603 List<double> getRange(int start, int length) {
1577 _rangeCheck(this, start, length); 1604 _rangeCheck(this.length, start, length);
1578 List<double> result = _new(length); 1605 List<double> result = _new(length);
1579 result.setRange(0, length, this, start); 1606 result.setRange(0, length, this, start);
1580 return result; 1607 return result;
1581 } 1608 }
1582 1609
1583 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { 1610 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
1584 if (from is _Float64Array) { 1611 if (from is _Float64Array) {
1585 int startInBytes = start * _BYTES_PER_ELEMENT; 1612 _setRange(start * _BYTES_PER_ELEMENT,
1586 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1613 length * _BYTES_PER_ELEMENT,
1587 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1614 from,
1588 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1615 startFrom * _BYTES_PER_ELEMENT);
1589 } else { 1616 } else {
1590 Arrays.copy(from, startFrom, this, start, length); 1617 Arrays.copy(from, startFrom, this, start, length);
1591 } 1618 }
1592 } 1619 }
1593 1620
1594 String toString() { 1621 String toString() {
1595 return Collections.collectionToString(this); 1622 return Collections.collectionToString(this);
1596 } 1623 }
1597 1624
1598 int bytesPerElement() { 1625 int bytesPerElement() {
(...skipping 11 matching lines...) Expand all
1610 double _getIndexed(int index) native "Float64Array_getIndexed"; 1637 double _getIndexed(int index) native "Float64Array_getIndexed";
1611 void _setIndexed(int index, double value) native "Float64Array_setIndexed"; 1638 void _setIndexed(int index, double value) native "Float64Array_setIndexed";
1612 } 1639 }
1613 1640
1614 1641
1615 class _ExternalInt8Array extends _ByteArrayBase implements Int8List { 1642 class _ExternalInt8Array extends _ByteArrayBase implements Int8List {
1616 int operator[](int index) { 1643 int operator[](int index) {
1617 return _getIndexed(index); 1644 return _getIndexed(index);
1618 } 1645 }
1619 1646
1620 int operator[]=(int index, int value) { 1647 void operator[]=(int index, int value) {
1621 _setIndexed(index, _toInt8(value)); 1648 _setIndexed(index, _toInt8(value));
1622 } 1649 }
1623 1650
1624 Iterator<int> iterator() { 1651 Iterator<int> iterator() {
1625 return new _ByteArrayIterator<int>(this); 1652 return new _ByteArrayIterator<int>(this);
1626 } 1653 }
1627 1654
1628 List<int> getRange(int start, int length) { 1655 List<int> getRange(int start, int length) {
1629 _rangeCheck(this, start, length); 1656 _rangeCheck(this.length, start, length);
1630 List<int> result = new Int8List(length); 1657 List<int> result = new Int8List(length);
1631 result.setRange(0, length, this, start); 1658 result.setRange(0, length, this, start);
1632 return result; 1659 return result;
1633 } 1660 }
1634 1661
1635 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1662 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1636 if (from is _ExternalInt8Array) { 1663 if (from is _ExternalInt8Array) {
1637 int startInBytes = start * _BYTES_PER_ELEMENT; 1664 _setRange(start * _BYTES_PER_ELEMENT,
1638 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1665 length * _BYTES_PER_ELEMENT,
1639 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1666 from,
1640 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1667 startFrom * _BYTES_PER_ELEMENT);
1641 } else { 1668 } else {
1642 Arrays.copy(from, startFrom, this, start, length); 1669 Arrays.copy(from, startFrom, this, start, length);
1643 } 1670 }
1644 } 1671 }
1645 1672
1646 String toString() { 1673 String toString() {
1647 return Collections.collectionToString(this); 1674 return Collections.collectionToString(this);
1648 } 1675 }
1649 1676
1650 int bytesPerElement() { 1677 int bytesPerElement() {
1651 return _BYTES_PER_ELEMENT; 1678 return _BYTES_PER_ELEMENT;
1652 } 1679 }
1653 1680
1654 int lengthInBytes() { 1681 int lengthInBytes() {
1655 return _length() * _BYTES_PER_ELEMENT; 1682 return _length() * _BYTES_PER_ELEMENT;
1656 } 1683 }
1657 1684
1658 static final int _BYTES_PER_ELEMENT = 1; 1685 static final int _BYTES_PER_ELEMENT = 1;
1659 1686
1660 int _getIndexed(int index) native "ExternalInt8Array_getIndexed"; 1687 int _getIndexed(int index) native "ExternalInt8Array_getIndexed";
1661 void _setIndexed(int index, int value) native "ExternalInt8Array_setIndexed"; 1688 void _setIndexed(int index, int value) native "ExternalInt8Array_setIndexed";
1662 } 1689 }
1663 1690
1664 1691
1665 class _ExternalUint8Array extends _ByteArrayBase implements Uint8List { 1692 class _ExternalUint8Array extends _ByteArrayBase implements Uint8List {
1666 int operator[](int index) { 1693 int operator[](int index) {
1667 return _getIndexed(index); 1694 return _getIndexed(index);
1668 } 1695 }
1669 1696
1670 int operator[]=(int index, int value) { 1697 void operator[]=(int index, int value) {
1671 _setIndexed(index, _toUint8(value)); 1698 _setIndexed(index, _toUint8(value));
1672 } 1699 }
1673 1700
1674 Iterator<int> iterator() { 1701 Iterator<int> iterator() {
1675 return new _ByteArrayIterator<int>(this); 1702 return new _ByteArrayIterator<int>(this);
1676 } 1703 }
1677 1704
1678 List<int> getRange(int start, int length) { 1705 List<int> getRange(int start, int length) {
1679 _rangeCheck(this, start, length); 1706 _rangeCheck(this.length, start, length);
1680 List<int> result = new Uint8List(length); 1707 List<int> result = new Uint8List(length);
1681 result.setRange(0, length, this, start); 1708 result.setRange(0, length, this, start);
1682 return result; 1709 return result;
1683 } 1710 }
1684 1711
1685 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1712 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1686 if (from is _ExternalUint8Array) { 1713 if (from is _ExternalUint8Array) {
1687 int startInBytes = start * _BYTES_PER_ELEMENT; 1714 _setRange(start * _BYTES_PER_ELEMENT,
1688 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1715 length * _BYTES_PER_ELEMENT,
1689 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1716 from,
1690 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1717 startFrom * _BYTES_PER_ELEMENT);
1691 } else { 1718 } else {
1692 Arrays.copy(from, startFrom, this, start, length); 1719 Arrays.copy(from, startFrom, this, start, length);
1693 } 1720 }
1694 } 1721 }
1695 1722
1696 String toString() { 1723 String toString() {
1697 return Collections.collectionToString(this); 1724 return Collections.collectionToString(this);
1698 } 1725 }
1699 1726
1700 int bytesPerElement() { 1727 int bytesPerElement() {
1701 return _BYTES_PER_ELEMENT; 1728 return _BYTES_PER_ELEMENT;
1702 } 1729 }
1703 1730
1704 int lengthInBytes() { 1731 int lengthInBytes() {
1705 return _length() * _BYTES_PER_ELEMENT; 1732 return _length() * _BYTES_PER_ELEMENT;
1706 } 1733 }
1707 1734
1708 static final int _BYTES_PER_ELEMENT = 1; 1735 static final int _BYTES_PER_ELEMENT = 1;
1709 1736
1710 int _getIndexed(int index) native "ExternalUint8Array_getIndexed"; 1737 int _getIndexed(int index) native "ExternalUint8Array_getIndexed";
1711 void _setIndexed(int index, int value) native "ExternalUint8Array_setIndexed"; 1738 void _setIndexed(int index, int value) native "ExternalUint8Array_setIndexed";
1712 } 1739 }
1713 1740
1714 1741
1715 class _ExternalInt16Array extends _ByteArrayBase implements Int16List { 1742 class _ExternalInt16Array extends _ByteArrayBase implements Int16List {
1716 int operator[](int index) { 1743 int operator[](int index) {
1717 return _getIndexed(index); 1744 return _getIndexed(index);
1718 } 1745 }
1719 1746
1720 int operator[]=(int index, int value) { 1747 void operator[]=(int index, int value) {
1721 _setIndexed(index, _toInt16(value)); 1748 _setIndexed(index, _toInt16(value));
1722 } 1749 }
1723 1750
1724 Iterator<int> iterator() { 1751 Iterator<int> iterator() {
1725 return new _ByteArrayIterator<int>(this); 1752 return new _ByteArrayIterator<int>(this);
1726 } 1753 }
1727 1754
1728 List<int> getRange(int start, int length) { 1755 List<int> getRange(int start, int length) {
1729 _rangeCheck(this, start, length); 1756 _rangeCheck(this.length, start, length);
1730 List<int> result = new Int16List(length); 1757 List<int> result = new Int16List(length);
1731 result.setRange(0, length, this, start); 1758 result.setRange(0, length, this, start);
1732 return result; 1759 return result;
1733 } 1760 }
1734 1761
1735 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1762 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1736 if (from is _ExternalInt16Array) { 1763 if (from is _ExternalInt16Array) {
1737 int startInBytes = start * _BYTES_PER_ELEMENT; 1764 _setRange(start * _BYTES_PER_ELEMENT,
1738 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1765 length * _BYTES_PER_ELEMENT,
1739 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1766 from,
1740 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1767 startFrom * _BYTES_PER_ELEMENT);
1741 } else { 1768 } else {
1742 Arrays.copy(from, startFrom, this, start, length); 1769 Arrays.copy(from, startFrom, this, start, length);
1743 } 1770 }
1744 } 1771 }
1745 1772
1746 String toString() { 1773 String toString() {
1747 return Collections.collectionToString(this); 1774 return Collections.collectionToString(this);
1748 } 1775 }
1749 1776
1750 int bytesPerElement() { 1777 int bytesPerElement() {
1751 return _BYTES_PER_ELEMENT; 1778 return _BYTES_PER_ELEMENT;
1752 } 1779 }
1753 1780
1754 int lengthInBytes() { 1781 int lengthInBytes() {
1755 return _length() * _BYTES_PER_ELEMENT; 1782 return _length() * _BYTES_PER_ELEMENT;
1756 } 1783 }
1757 1784
1758 static final int _BYTES_PER_ELEMENT = 2; 1785 static final int _BYTES_PER_ELEMENT = 2;
1759 1786
1760 int _getIndexed(int index) native "ExternalInt16Array_getIndexed"; 1787 int _getIndexed(int index) native "ExternalInt16Array_getIndexed";
1761 void _setIndexed(int index, int value) native "ExternalInt16Array_setIndexed"; 1788 void _setIndexed(int index, int value) native "ExternalInt16Array_setIndexed";
1762 } 1789 }
1763 1790
1764 1791
1765 class _ExternalUint16Array extends _ByteArrayBase implements Uint16List { 1792 class _ExternalUint16Array extends _ByteArrayBase implements Uint16List {
1766 int operator[](int index) { 1793 int operator[](int index) {
1767 return _getIndexed(index); 1794 return _getIndexed(index);
1768 } 1795 }
1769 1796
1770 int operator[]=(int index, int value) { 1797 void operator[]=(int index, int value) {
1771 _setIndexed(index, _toUint16(value)); 1798 _setIndexed(index, _toUint16(value));
1772 } 1799 }
1773 1800
1774 Iterator<int> iterator() { 1801 Iterator<int> iterator() {
1775 return new _ByteArrayIterator<int>(this); 1802 return new _ByteArrayIterator<int>(this);
1776 } 1803 }
1777 1804
1778 List<int> getRange(int start, int length) { 1805 List<int> getRange(int start, int length) {
1779 _rangeCheck(this, start, length); 1806 _rangeCheck(this.length, start, length);
1780 List<int> result = new Uint16List(length); 1807 List<int> result = new Uint16List(length);
1781 result.setRange(0, length, this, start); 1808 result.setRange(0, length, this, start);
1782 return result; 1809 return result;
1783 } 1810 }
1784 1811
1785 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1812 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1786 if (from is _ExternalUint16Array) { 1813 if (from is _ExternalUint16Array) {
1787 int startInBytes = start * _BYTES_PER_ELEMENT; 1814 _setRange(start * _BYTES_PER_ELEMENT,
1788 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1815 length * _BYTES_PER_ELEMENT,
1789 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1816 from,
1790 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1817 startFrom * _BYTES_PER_ELEMENT);
1791 } else { 1818 } else {
1792 Arrays.copy(from, startFrom, this, start, length); 1819 Arrays.copy(from, startFrom, this, start, length);
1793 } 1820 }
1794 } 1821 }
1795 1822
1796 String toString() { 1823 String toString() {
1797 return Collections.collectionToString(this); 1824 return Collections.collectionToString(this);
1798 } 1825 }
1799 1826
1800 int bytesPerElement() { 1827 int bytesPerElement() {
(...skipping 11 matching lines...) Expand all
1812 void _setIndexed(int index, int value) 1839 void _setIndexed(int index, int value)
1813 native "ExternalUint16Array_setIndexed"; 1840 native "ExternalUint16Array_setIndexed";
1814 } 1841 }
1815 1842
1816 1843
1817 class _ExternalInt32Array extends _ByteArrayBase implements Int32List { 1844 class _ExternalInt32Array extends _ByteArrayBase implements Int32List {
1818 int operator[](int index) { 1845 int operator[](int index) {
1819 return _getIndexed(index); 1846 return _getIndexed(index);
1820 } 1847 }
1821 1848
1822 int operator[]=(int index, int value) { 1849 void operator[]=(int index, int value) {
1823 _setIndexed(index, _toInt32(value)); 1850 _setIndexed(index, _toInt32(value));
1824 } 1851 }
1825 1852
1826 Iterator<int> iterator() { 1853 Iterator<int> iterator() {
1827 return new _ByteArrayIterator<int>(this); 1854 return new _ByteArrayIterator<int>(this);
1828 } 1855 }
1829 1856
1830 List<int> getRange(int start, int length) { 1857 List<int> getRange(int start, int length) {
1831 _rangeCheck(this, start, length); 1858 _rangeCheck(this.length, start, length);
1832 List<int> result = new Int32List(length); 1859 List<int> result = new Int32List(length);
1833 result.setRange(0, length, this, start); 1860 result.setRange(0, length, this, start);
1834 return result; 1861 return result;
1835 } 1862 }
1836 1863
1837 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1864 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1838 if (from is _ExternalInt32Array) { 1865 if (from is _ExternalInt32Array) {
1839 int startInBytes = start * _BYTES_PER_ELEMENT; 1866 _setRange(start * _BYTES_PER_ELEMENT,
1840 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1867 length * _BYTES_PER_ELEMENT,
1841 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1868 from,
1842 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1869 startFrom * _BYTES_PER_ELEMENT);
1843 } else { 1870 } else {
1844 Arrays.copy(from, startFrom, this, start, length); 1871 Arrays.copy(from, startFrom, this, start, length);
1845 } 1872 }
1846 } 1873 }
1847 1874
1848 String toString() { 1875 String toString() {
1849 return Collections.collectionToString(this); 1876 return Collections.collectionToString(this);
1850 } 1877 }
1851 1878
1852 int bytesPerElement() { 1879 int bytesPerElement() {
(...skipping 11 matching lines...) Expand all
1864 void _setIndexed(int index, int value) 1891 void _setIndexed(int index, int value)
1865 native "ExternalInt32Array_setIndexed"; 1892 native "ExternalInt32Array_setIndexed";
1866 } 1893 }
1867 1894
1868 1895
1869 class _ExternalUint32Array extends _ByteArrayBase implements Uint32List { 1896 class _ExternalUint32Array extends _ByteArrayBase implements Uint32List {
1870 int operator[](int index) { 1897 int operator[](int index) {
1871 return _getIndexed(index); 1898 return _getIndexed(index);
1872 } 1899 }
1873 1900
1874 int operator[]=(int index, int value) { 1901 void operator[]=(int index, int value) {
1875 _setIndexed(index, _toUint32(value)); 1902 _setIndexed(index, _toUint32(value));
1876 } 1903 }
1877 1904
1878 Iterator<int> iterator() { 1905 Iterator<int> iterator() {
1879 return new _ByteArrayIterator<int>(this); 1906 return new _ByteArrayIterator<int>(this);
1880 } 1907 }
1881 1908
1882 List<int> getRange(int start, int length) { 1909 List<int> getRange(int start, int length) {
1883 _rangeCheck(this, start, length); 1910 _rangeCheck(this.length, start, length);
1884 List<int> result = new Uint32List(length); 1911 List<int> result = new Uint32List(length);
1885 result.setRange(0, length, this, start); 1912 result.setRange(0, length, this, start);
1886 return result; 1913 return result;
1887 } 1914 }
1888 1915
1889 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1916 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1890 if (from is _ExternalUint32Array) { 1917 if (from is _ExternalUint32Array) {
1891 int startInBytes = start * _BYTES_PER_ELEMENT; 1918 _setRange(start * _BYTES_PER_ELEMENT,
1892 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1919 length * _BYTES_PER_ELEMENT,
1893 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1920 from,
1894 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1921 startFrom * _BYTES_PER_ELEMENT);
1895 } else { 1922 } else {
1896 Arrays.copy(from, startFrom, this, start, length); 1923 Arrays.copy(from, startFrom, this, start, length);
1897 } 1924 }
1898 } 1925 }
1899 1926
1900 String toString() { 1927 String toString() {
1901 return Collections.collectionToString(this); 1928 return Collections.collectionToString(this);
1902 } 1929 }
1903 1930
1904 int bytesPerElement() { 1931 int bytesPerElement() {
(...skipping 11 matching lines...) Expand all
1916 void _setIndexed(int index, int value) 1943 void _setIndexed(int index, int value)
1917 native "ExternalUint32Array_setIndexed"; 1944 native "ExternalUint32Array_setIndexed";
1918 } 1945 }
1919 1946
1920 1947
1921 class _ExternalInt64Array extends _ByteArrayBase implements Int64List { 1948 class _ExternalInt64Array extends _ByteArrayBase implements Int64List {
1922 int operator[](int index) { 1949 int operator[](int index) {
1923 return _getIndexed(index); 1950 return _getIndexed(index);
1924 } 1951 }
1925 1952
1926 int operator[]=(int index, int value) { 1953 void operator[]=(int index, int value) {
1927 _setIndexed(index, _toInt64(value)); 1954 _setIndexed(index, _toInt64(value));
1928 } 1955 }
1929 1956
1930 Iterator<int> iterator() { 1957 Iterator<int> iterator() {
1931 return new _ByteArrayIterator<int>(this); 1958 return new _ByteArrayIterator<int>(this);
1932 } 1959 }
1933 1960
1934 List<int> getRange(int start, int length) { 1961 List<int> getRange(int start, int length) {
1935 _rangeCheck(this, start, length); 1962 _rangeCheck(this.length, start, length);
1936 List<int> result = new Int64List(length); 1963 List<int> result = new Int64List(length);
1937 result.setRange(0, length, this, start); 1964 result.setRange(0, length, this, start);
1938 return result; 1965 return result;
1939 } 1966 }
1940 1967
1941 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 1968 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1942 if (from is _ExternalInt64Array) { 1969 if (from is _ExternalInt64Array) {
1943 int startInBytes = start * _BYTES_PER_ELEMENT; 1970 _setRange(start * _BYTES_PER_ELEMENT,
1944 int lengthInBytes = length * _BYTES_PER_ELEMENT; 1971 length * _BYTES_PER_ELEMENT,
1945 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 1972 from,
1946 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 1973 startFrom * _BYTES_PER_ELEMENT);
1947 } else { 1974 } else {
1948 Arrays.copy(from, startFrom, this, start, length); 1975 Arrays.copy(from, startFrom, this, start, length);
1949 } 1976 }
1950 } 1977 }
1951 1978
1952 String toString() { 1979 String toString() {
1953 return Collections.collectionToString(this); 1980 return Collections.collectionToString(this);
1954 } 1981 }
1955 1982
1956 int bytesPerElement() { 1983 int bytesPerElement() {
(...skipping 11 matching lines...) Expand all
1968 void _setIndexed(int index, int value) 1995 void _setIndexed(int index, int value)
1969 native "ExternalInt64Array_setIndexed"; 1996 native "ExternalInt64Array_setIndexed";
1970 } 1997 }
1971 1998
1972 1999
1973 class _ExternalUint64Array extends _ByteArrayBase implements Uint64List { 2000 class _ExternalUint64Array extends _ByteArrayBase implements Uint64List {
1974 int operator[](int index) { 2001 int operator[](int index) {
1975 return _getIndexed(index); 2002 return _getIndexed(index);
1976 } 2003 }
1977 2004
1978 int operator[]=(int index, int value) { 2005 void operator[]=(int index, int value) {
1979 _setIndexed(index, _toUint64(value)); 2006 _setIndexed(index, _toUint64(value));
1980 } 2007 }
1981 2008
1982 Iterator<int> iterator() { 2009 Iterator<int> iterator() {
1983 return new _ByteArrayIterator<int>(this); 2010 return new _ByteArrayIterator<int>(this);
1984 } 2011 }
1985 2012
1986 List<int> getRange(int start, int length) { 2013 List<int> getRange(int start, int length) {
1987 _rangeCheck(this, start, length); 2014 _rangeCheck(this.length, start, length);
1988 List<int> result = new Uint64List(length); 2015 List<int> result = new Uint64List(length);
1989 result.setRange(0, length, this, start); 2016 result.setRange(0, length, this, start);
1990 return result; 2017 return result;
1991 } 2018 }
1992 2019
1993 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2020 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
1994 if (from is _ExternalUint64Array) { 2021 if (from is _ExternalUint64Array) {
1995 int startInBytes = start * _BYTES_PER_ELEMENT; 2022 _setRange(start * _BYTES_PER_ELEMENT,
1996 int lengthInBytes = length * _BYTES_PER_ELEMENT; 2023 length * _BYTES_PER_ELEMENT,
1997 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 2024 from,
1998 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 2025 startFrom * _BYTES_PER_ELEMENT);
1999 } else { 2026 } else {
2000 Arrays.copy(from, startFrom, this, start, length); 2027 Arrays.copy(from, startFrom, this, start, length);
2001 } 2028 }
2002 } 2029 }
2003 2030
2004 String toString() { 2031 String toString() {
2005 return Collections.collectionToString(this); 2032 return Collections.collectionToString(this);
2006 } 2033 }
2007 2034
2008 int bytesPerElement() { 2035 int bytesPerElement() {
2009 return _BYTES_PER_ELEMENT; 2036 return _BYTES_PER_ELEMENT;
2010 } 2037 }
2011 2038
2012 int lengthInBytes() { 2039 int lengthInBytes() {
2013 return _length() * _BYTES_PER_ELEMENT; 2040 return _length() * _BYTES_PER_ELEMENT;
2014 } 2041 }
2015 2042
2016 static final int _BYTES_PER_ELEMENT = 8; 2043 static final int _BYTES_PER_ELEMENT = 8;
2017 2044
2018 int _getIndexed(int index) 2045 int _getIndexed(int index)
2019 native "ExternalUint64Array_getIndexed"; 2046 native "ExternalUint64Array_getIndexed";
2020 void _setIndexed(int index, int value) 2047 void _setIndexed(int index, int value)
2021 native "ExternalUint64Array_setIndexed"; 2048 native "ExternalUint64Array_setIndexed";
2022 } 2049 }
2023 2050
2024 2051
2025 class _ExternalFloat32Array extends _ByteArrayBase implements Float32List { 2052 class _ExternalFloat32Array extends _ByteArrayBase implements Float32List {
2026 int operator[](int index) { 2053 double operator[](int index) {
2027 return _getIndexed(index); 2054 return _getIndexed(index);
2028 } 2055 }
2029 2056
2030 int operator[]=(int index, double value) { 2057 void operator[]=(int index, double value) {
2031 _setIndexed(index, value); 2058 _setIndexed(index, value);
2032 } 2059 }
2033 2060
2034 Iterator<double> iterator() { 2061 Iterator<double> iterator() {
2035 return new _ByteArrayIterator<double>(this); 2062 return new _ByteArrayIterator<double>(this);
2036 } 2063 }
2037 2064
2038 List<double> getRange(int start, int length) { 2065 List<double> getRange(int start, int length) {
2039 _rangeCheck(this, start, length); 2066 _rangeCheck(this.length, start, length);
2040 List<double> result = new Float32List(length); 2067 List<double> result = new Float32List(length);
2041 result.setRange(0, length, this, start); 2068 result.setRange(0, length, this, start);
2042 return result; 2069 return result;
2043 } 2070 }
2044 2071
2045 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { 2072 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
2046 if (from is _ExternalFloat32Array) { 2073 if (from is _ExternalFloat32Array) {
2047 int startInBytes = start * _BYTES_PER_ELEMENT; 2074 _setRange(start * _BYTES_PER_ELEMENT,
2048 int lengthInBytes = length * _BYTES_PER_ELEMENT; 2075 length * _BYTES_PER_ELEMENT,
2049 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 2076 from,
2050 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 2077 startFrom * _BYTES_PER_ELEMENT);
2051 } else { 2078 } else {
2052 Arrays.copy(from, startFrom, this, start, length); 2079 Arrays.copy(from, startFrom, this, start, length);
2053 } 2080 }
2054 } 2081 }
2055 2082
2056 String toString() { 2083 String toString() {
2057 return Collections.collectionToString(this); 2084 return Collections.collectionToString(this);
2058 } 2085 }
2059 2086
2060 int bytesPerElement() { 2087 int bytesPerElement() {
2061 return _BYTES_PER_ELEMENT; 2088 return _BYTES_PER_ELEMENT;
2062 } 2089 }
2063 2090
2064 int lengthInBytes() { 2091 int lengthInBytes() {
2065 return _length() * _BYTES_PER_ELEMENT; 2092 return _length() * _BYTES_PER_ELEMENT;
2066 } 2093 }
2067 2094
2068 static final int _BYTES_PER_ELEMENT = 4; 2095 static final int _BYTES_PER_ELEMENT = 4;
2069 2096
2070 double _getIndexed(int index) 2097 double _getIndexed(int index)
2071 native "ExternalFloat32Array_getIndexed"; 2098 native "ExternalFloat32Array_getIndexed";
2072 void _setIndexed(int index, double value) 2099 void _setIndexed(int index, double value)
2073 native "ExternalFloat32Array_setIndexed"; 2100 native "ExternalFloat32Array_setIndexed";
2074 } 2101 }
2075 2102
2076 2103
2077 class _ExternalFloat64Array extends _ByteArrayBase implements Float64List { 2104 class _ExternalFloat64Array extends _ByteArrayBase implements Float64List {
2078 int operator[](int index) { 2105 double operator[](int index) {
2079 return _getIndexed(index); 2106 return _getIndexed(index);
2080 } 2107 }
2081 2108
2082 int operator[]=(int index, double value) { 2109 void operator[]=(int index, double value) {
2083 _setIndexed(index, value); 2110 _setIndexed(index, value);
2084 } 2111 }
2085 2112
2086 Iterator<double> iterator() { 2113 Iterator<double> iterator() {
2087 return new _ByteArrayIterator<double>(this); 2114 return new _ByteArrayIterator<double>(this);
2088 } 2115 }
2089 2116
2090 List<double> getRange(int start, int length) { 2117 List<double> getRange(int start, int length) {
2091 _rangeCheck(this, start, length); 2118 _rangeCheck(this.length, start, length);
2092 List<double> result = new Float64List(length); 2119 List<double> result = new Float64List(length);
2093 result.setRange(0, length, this, start); 2120 result.setRange(0, length, this, start);
2094 return result; 2121 return result;
2095 } 2122 }
2096 2123
2097 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { 2124 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
2098 if (from is _ExternalFloat64Array) { 2125 if (from is _ExternalFloat64Array) {
2099 int startInBytes = start * _BYTES_PER_ELEMENT; 2126 _setRange(start * _BYTES_PER_ELEMENT,
2100 int lengthInBytes = length * _BYTES_PER_ELEMENT; 2127 length * _BYTES_PER_ELEMENT,
2101 int startFromInBytes = startFrom * _BYTES_PER_ELEMENT; 2128 from,
2102 _setRange(startInBytes, lengthInBytes, from, startFromInBytes); 2129 startFrom * _BYTES_PER_ELEMENT);
2103 } else { 2130 } else {
2104 Arrays.copy(from, startFrom, this, start, length); 2131 Arrays.copy(from, startFrom, this, start, length);
2105 } 2132 }
2106 } 2133 }
2107 2134
2108 String toString() { 2135 String toString() {
2109 return Collections.collectionToString(this); 2136 return Collections.collectionToString(this);
2110 } 2137 }
2111 2138
2112 int bytesPerElement() { 2139 int bytesPerElement() {
2113 return _BYTES_PER_ELEMENT; 2140 return _BYTES_PER_ELEMENT;
2114 } 2141 }
2115 2142
2116 int lengthInBytes() { 2143 int lengthInBytes() {
2117 return _length() * _BYTES_PER_ELEMENT; 2144 return _length() * _BYTES_PER_ELEMENT;
2118 } 2145 }
2119 2146
2120 static final int _BYTES_PER_ELEMENT = 8; 2147 static final int _BYTES_PER_ELEMENT = 8;
2121 2148
2122 double _getIndexed(int index) 2149 double _getIndexed(int index)
2123 native "ExternalFloat64Array_getIndexed"; 2150 native "ExternalFloat64Array_getIndexed";
2124 void _setIndexed(int index, double value) 2151 void _setIndexed(int index, double value)
2125 native "ExternalFloat64Array_setIndexed"; 2152 native "ExternalFloat64Array_setIndexed";
2126 } 2153 }
2127 2154
2128 2155
2129 class _ByteArrayIterator<E> implements Iterator<E> { 2156 class _ByteArrayIterator<E> implements Iterator<E> {
2130 _ByteArrayIterator(_ByteArrayBase array) 2157 _ByteArrayIterator(List array)
2131 : _array = array, _length = array.length, _pos = 0; 2158 : _array = array, _length = array.length, _pos = 0 {
2159 assert(array is _ByteArrayBase || array is _ByteArrayViewBase);
2160 }
2132 2161
2133 bool hasNext() { 2162 bool hasNext() {
2134 return _length > _pos; 2163 return _length > _pos;
2135 } 2164 }
2136 2165
2137 E next() { 2166 E next() {
2138 if (!hasNext()) { 2167 if (!hasNext()) {
2139 throw const NoMoreElementsException(); 2168 throw const NoMoreElementsException();
2140 } 2169 }
2141 return _array[_pos++]; 2170 return _array[_pos++];
2142 } 2171 }
2143 2172
2144 final List<E> _array; 2173 final List<E> _array;
2145
2146 final int _length; 2174 final int _length;
2147
2148 int _pos; 2175 int _pos;
2149 } 2176 }
2150 2177
2151 2178
2152 class _ByteArrayView implements ByteArray { 2179 class _ByteArrayView implements ByteArray {
2153 _ByteArrayView(this._array, this._offset, this._length) { 2180 _ByteArrayView(this._array, this._offset, this._length) {
2181 _rangeCheck(_array.lengthInBytes(), _offset, _length);
2154 } 2182 }
2155 2183
2156 int lengthInBytes() { 2184 int lengthInBytes() {
2157 return _length; 2185 return _length;
2158 } 2186 }
2159 2187
2160 ByteArray subByteArray([int start = 0, int length]) { 2188 ByteArray subByteArray([int start = 0, int length]) {
2161 if (length === null) { 2189 if (length === null) {
2162 length = this.lengthInBytes(); 2190 length = this.lengthInBytes();
2163 } 2191 }
2164 _rangeCheck(start, length);
2165 return new _ByteArrayView(_array, _offset + start, length); 2192 return new _ByteArrayView(_array, _offset + start, length);
2166 } 2193 }
2167 2194
2168 int getInt8(int byteOffset) { 2195 int getInt8(int byteOffset) {
2169 return _array._getInt8(_offset + byteOffset); 2196 return _array._getInt8(_offset + byteOffset);
2170 } 2197 }
2171 void setInt8(int byteOffset, int value) { 2198 int setInt8(int byteOffset, int value) {
2172 _array._setInt8(_offset + byteOffset, value); 2199 return _array._setInt8(_offset + byteOffset, value);
2173 } 2200 }
2174 2201
2175 int getUint8(int byteOffset) { 2202 int getUint8(int byteOffset) {
2176 return _array._getUint8(_offset + byteOffset); 2203 return _array._getUint8(_offset + byteOffset);
2177 } 2204 }
2178 void setUint8(int byteOffset, int value) { 2205 int setUint8(int byteOffset, int value) {
2179 _array._setUint8(_offset + byteOffset, value); 2206 return _array._setUint8(_offset + byteOffset, value);
2180 } 2207 }
2181 2208
2182 int getInt16(int byteOffset) { 2209 int getInt16(int byteOffset) {
2183 return _array._getInt16(_offset + byteOffset); 2210 return _array._getInt16(_offset + byteOffset);
2184 } 2211 }
2185 void setInt16(int byteOffset, int value) { 2212 int setInt16(int byteOffset, int value) {
2186 _array._setInt16(_offset + byteOffset, value); 2213 return _array._setInt16(_offset + byteOffset, value);
2187 } 2214 }
2188 2215
2189 int getUint16(int byteOffset) { 2216 int getUint16(int byteOffset) {
2190 return _array._getUint16(_offset + byteOffset); 2217 return _array._getUint16(_offset + byteOffset);
2191 } 2218 }
2192 void setUint16(int byteOffset, int value) { 2219 int setUint16(int byteOffset, int value) {
2193 _array._setUint16(_offset + byteOffset, value); 2220 return _array._setUint16(_offset + byteOffset, value);
2194 } 2221 }
2195 2222
2196 int getInt32(int byteOffset) { 2223 int getInt32(int byteOffset) {
2197 return _array._getInt32(_offset + byteOffset); 2224 return _array._getInt32(_offset + byteOffset);
2198 } 2225 }
2199 void setInt32(int byteOffset, int value) { 2226 int setInt32(int byteOffset, int value) {
2200 _array._setInt32(_offset + byteOffset, value); 2227 return _array._setInt32(_offset + byteOffset, value);
2201 } 2228 }
2202 2229
2203 int getUint32(int byteOffset) { 2230 int getUint32(int byteOffset) {
2204 return _array._getUint32(_offset + byteOffset); 2231 return _array._getUint32(_offset + byteOffset);
2205 } 2232 }
2206 void setUint32(int byteOffset, int value) { 2233 int setUint32(int byteOffset, int value) {
2207 _array._setUint32(_offset + byteOffset, value); 2234 return _array._setUint32(_offset + byteOffset, value);
2208 } 2235 }
2209 2236
2210 int getInt64(int byteOffset) { 2237 int getInt64(int byteOffset) {
2211 return _array._getInt64(_offset + byteOffset); 2238 return _array._getInt64(_offset + byteOffset);
2212 } 2239 }
2213 void setInt64(int byteOffset, int value) { 2240 int setInt64(int byteOffset, int value) {
2214 _array._setInt64(_offset + byteOffset, value); 2241 return _array._setInt64(_offset + byteOffset, value);
2215 } 2242 }
2216 2243
2217 int getUint64(int byteOffset) { 2244 int getUint64(int byteOffset) {
2218 return _array._getUint64(_offset + byteOffset); 2245 return _array._getUint64(_offset + byteOffset);
2219 } 2246 }
2220 void setUint64(int byteOffset, int value) { 2247 int setUint64(int byteOffset, int value) {
2221 _array._setUint64(_offset + byteOffset, value); 2248 return _array._setUint64(_offset + byteOffset, value);
2222 } 2249 }
2223 2250
2224 double getFloat32(int byteOffset) { 2251 double getFloat32(int byteOffset) {
2225 return _array._getFloat32(_offset + byteOffset); 2252 return _array._getFloat32(_offset + byteOffset);
2226 } 2253 }
2227 void setFloat32(int byteOffset, double value) { 2254 int setFloat32(int byteOffset, double value) {
2228 _array._setFloat32(_offset + byteOffset, value); 2255 return _array._setFloat32(_offset + byteOffset, value);
2229 } 2256 }
2230 2257
2231 double getFloat64(int byteOffset) { 2258 double getFloat64(int byteOffset) {
2232 return _array._getFloat64(_offset + byteOffset); 2259 return _array._getFloat64(_offset + byteOffset);
2233 } 2260 }
2234 void setFloat64(int byteOffset, double value) { 2261 int setFloat64(int byteOffset, double value) {
2235 _array._setFloat64(_offset + byteOffset, value); 2262 return _array._setFloat64(_offset + byteOffset, value);
2236 } 2263 }
2237 2264
2238 final _ByteArrayBase _array; 2265 final _ByteArrayBase _array;
2239 final int _offset; 2266 final int _offset;
2240 final int _length; 2267 final int _length;
2241 } 2268 }
2242 2269
2243 2270
2244 class _ByteArrayViewBase { 2271 class _ByteArrayViewBase {
2272 abstract num operator[](int index);
2245 2273
2246 // Methods implementing the Collection interface. 2274 // Methods implementing the Collection interface.
2247 2275
2248 void forEach(void f(element)) { 2276 void forEach(void f(element)) {
2249 var len = this.length; 2277 var len = this.length;
2250 for (var i = 0; i < len; i++) { 2278 for (var i = 0; i < len; i++) {
2251 f(this[i]); 2279 f(this[i]);
2252 } 2280 }
2253 } 2281 }
2254 2282
(...skipping 12 matching lines...) Expand all
2267 } 2295 }
2268 2296
2269 bool some(bool f(element)) { 2297 bool some(bool f(element)) {
2270 return Collections.some(this, f);; 2298 return Collections.some(this, f);;
2271 } 2299 }
2272 2300
2273 bool isEmpty() { 2301 bool isEmpty() {
2274 return this.length === 0; 2302 return this.length === 0;
2275 } 2303 }
2276 2304
2277 int get length() { 2305 abstract int get length();
2278 return _length();
2279 }
2280 2306
2281 // Methods implementing the List interface. 2307 // Methods implementing the List interface.
2282 2308
2283 set length(newLength) { 2309 set length(newLength) {
2284 throw const UnsupportedOperationException( 2310 throw const UnsupportedOperationException(
2285 "Cannot resize a non-extendable array"); 2311 "Cannot resize a non-extendable array");
2286 } 2312 }
2287 2313
2288 void add(value) { 2314 void add(value) {
2289 throw const UnsupportedOperationException( 2315 throw const UnsupportedOperationException(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 void insertRange(int start, int length, [initialValue]) { 2361 void insertRange(int start, int length, [initialValue]) {
2336 throw const UnsupportedOperationException( 2362 throw const UnsupportedOperationException(
2337 "Cannot add to a non-extendable array"); 2363 "Cannot add to a non-extendable array");
2338 } 2364 }
2339 } 2365 }
2340 2366
2341 2367
2342 class _Int8ArrayView extends _ByteArrayViewBase implements Int8List { 2368 class _Int8ArrayView extends _ByteArrayViewBase implements Int8List {
2343 _Int8ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2369 _Int8ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2344 : _array = array, 2370 : _array = array,
2345 _offset = offsetInBytes, 2371 _offset = _requireInteger(offsetInBytes),
2346 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2372 _length = _requireIntegerOrNull(
2347 : length { 2373 length,
2348 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2374 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2349 throw new IndexOutOfRangeException(offsetInBytes); 2375 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2350 }
2351 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2352 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2353 throw new IndexOutOfRangeException(length);
2354 }
2355 } 2376 }
2356 2377
2357 get length() { 2378 get length() {
2358 return _length; 2379 return _length;
2359 } 2380 }
2360 2381
2361 int operator[](int index) { 2382 int operator[](int index) {
2362 if (index < 0 || index >= _length) { 2383 if (index < 0 || index >= _length) {
2363 throw new IndexOutOfRangeException(index); 2384 throw new IndexOutOfRangeException(index);
2364 } 2385 }
2365 return _array.getInt8(_offset + (index * _BYTES_PER_ELEMENT)); 2386 return _array.getInt8(_offset + (index * _BYTES_PER_ELEMENT));
2366 } 2387 }
2367 2388
2368 void operator[]=(int index, int value) { 2389 void operator[]=(int index, int value) {
2369 if (index < 0 || index >= _length) { 2390 if (index < 0 || index >= _length) {
2370 throw new IndexOutOfRangeException(index); 2391 throw new IndexOutOfRangeException(index);
2371 } 2392 }
2372 _array.setInt8(_offset + (index * _BYTES_PER_ELEMENT), _toInt8(value)); 2393 _array.setInt8(_offset + (index * _BYTES_PER_ELEMENT), _toInt8(value));
2373 } 2394 }
2374 2395
2375 Iterator<int> iterator() { 2396 Iterator<int> iterator() {
2376 return new _ByteArrayIterator<int>(this); 2397 return new _ByteArrayIterator<int>(this);
2377 } 2398 }
2378 2399
2379 List<int> getRange(int start, int length) { 2400 List<int> getRange(int start, int length) {
2380 _rangeCheck(this, start, length); 2401 _rangeCheck(this.length, start, length);
2381 List<int> result = new Int8List(length); 2402 List<int> result = new Int8List(length);
2382 result.setRange(0, length, this, start); 2403 result.setRange(0, length, this, start);
2383 return result; 2404 return result;
2384 } 2405 }
2385 2406
2386 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2407 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2387 Arrays.copy(from, startFrom, this, start, length); 2408 Arrays.copy(from, startFrom, this, start, length);
2388 } 2409 }
2389 2410
2390 String toString() { 2411 String toString() {
2391 return Collections.collectionToString(this); 2412 return Collections.collectionToString(this);
2392 } 2413 }
2393 2414
2394 int bytesPerElement() { 2415 int bytesPerElement() {
2395 return _BYTES_PER_ELEMENT; 2416 return _BYTES_PER_ELEMENT;
2396 } 2417 }
2397 2418
2398 int lengthInBytes() { 2419 int lengthInBytes() {
2399 return _length * _BYTES_PER_ELEMENT; 2420 return _length * _BYTES_PER_ELEMENT;
2400 } 2421 }
2401 2422
2402 ByteArray asByteArray([int start = 0, int length]) { 2423 ByteArray asByteArray([int start = 0, int length]) {
2403 if (length == null) { 2424 if (length == null) {
2404 length = this.lengthInBytes(); 2425 length = this.lengthInBytes();
2405 } 2426 }
2406 _rangeCheck(start, length); 2427 _rangeCheck(this.length, start, length);
2407 return _array.subByteArray(_offset + start, length); 2428 return _array.subByteArray(_offset + start, length);
2408 } 2429 }
2409 2430
2410 static final int _BYTES_PER_ELEMENT = 1; 2431 static final int _BYTES_PER_ELEMENT = 1;
2411 final ByteArray _array; 2432 final ByteArray _array;
2412 final int _offset; 2433 final int _offset;
2413 final int _length; 2434 final int _length;
2414 } 2435 }
2415 2436
2416 2437
2417 class _Uint8ArrayView extends _ByteArrayViewBase implements Uint8List { 2438 class _Uint8ArrayView extends _ByteArrayViewBase implements Uint8List {
2418 _Uint8ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2439 _Uint8ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2419 : _array = array, 2440 : _array = array,
2420 _offset = offsetInBytes, 2441 _offset = _requireInteger(offsetInBytes),
2421 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2442 _length = _requireIntegerOrNull(
2422 : length { 2443 length,
2423 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2444 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2424 throw new IndexOutOfRangeException(offsetInBytes); 2445 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2425 }
2426 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2427 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2428 throw new IndexOutOfRangeException(length);
2429 }
2430 } 2446 }
2431 2447
2432 get length() { 2448 get length() {
2433 return _length; 2449 return _length;
2434 } 2450 }
2435 2451
2436 int operator[](int index) { 2452 int operator[](int index) {
2437 if (index < 0 || index >= _length) { 2453 if (index < 0 || index >= _length) {
2438 throw new IndexOutOfRangeException(index); 2454 throw new IndexOutOfRangeException(index);
2439 } 2455 }
2440 return _array.getUint8(_offset + (index * _BYTES_PER_ELEMENT)); 2456 return _array.getUint8(_offset + (index * _BYTES_PER_ELEMENT));
2441 } 2457 }
2442 2458
2443 void operator[]=(int index, int value) { 2459 void operator[]=(int index, int value) {
2444 if (index < 0 || index >= _length) { 2460 if (index < 0 || index >= _length) {
2445 throw new IndexOutOfRangeException(index); 2461 throw new IndexOutOfRangeException(index);
2446 } 2462 }
2447 _array.setUint8(_offset + (index * _BYTES_PER_ELEMENT), _toUint8(value)); 2463 _array.setUint8(_offset + (index * _BYTES_PER_ELEMENT), _toUint8(value));
2448 } 2464 }
2449 2465
2450 Iterator<int> iterator() { 2466 Iterator<int> iterator() {
2451 return new _ByteArrayIterator<int>(this); 2467 return new _ByteArrayIterator<int>(this);
2452 } 2468 }
2453 2469
2454 List<int> getRange(int start, int length) { 2470 List<int> getRange(int start, int length) {
2455 _rangeCheck(this, start, length); 2471 _rangeCheck(this.length, start, length);
2456 List<int> result = new Uint8List(length); 2472 List<int> result = new Uint8List(length);
2457 result.setRange(0, length, this, start); 2473 result.setRange(0, length, this, start);
2458 return result; 2474 return result;
2459 } 2475 }
2460 2476
2461 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2477 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2462 Arrays.copy(from, startFrom, this, start, length); 2478 Arrays.copy(from, startFrom, this, start, length);
2463 } 2479 }
2464 2480
2465 String toString() { 2481 String toString() {
2466 return Collections.collectionToString(this); 2482 return Collections.collectionToString(this);
2467 } 2483 }
2468 2484
2469 int bytesPerElement() { 2485 int bytesPerElement() {
2470 return _BYTES_PER_ELEMENT; 2486 return _BYTES_PER_ELEMENT;
2471 } 2487 }
2472 2488
2473 int lengthInBytes() { 2489 int lengthInBytes() {
2474 return _length * _BYTES_PER_ELEMENT; 2490 return _length * _BYTES_PER_ELEMENT;
2475 } 2491 }
2476 2492
2477 ByteArray asByteArray([int start = 0, int length]) { 2493 ByteArray asByteArray([int start = 0, int length]) {
2478 if (length == null) { 2494 if (length == null) {
2479 length = this.lengthInBytes(); 2495 length = this.lengthInBytes();
2480 } 2496 }
2481 _rangeCheck(start, length); 2497 _rangeCheck(this.length, start, length);
2482 return _array.subByteArray(_offset + start, length); 2498 return _array.subByteArray(_offset + start, length);
2483 } 2499 }
2484 2500
2485 static final int _BYTES_PER_ELEMENT = 1; 2501 static final int _BYTES_PER_ELEMENT = 1;
2486 final ByteArray _array; 2502 final ByteArray _array;
2487 final int _offset; 2503 final int _offset;
2488 final int _length; 2504 final int _length;
2489 } 2505 }
2490 2506
2491 2507
2492 class _Int16ArrayView extends _ByteArrayViewBase implements Int16List { 2508 class _Int16ArrayView extends _ByteArrayViewBase implements Int16List {
2493 _Int16ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2509 _Int16ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2494 : _array = array, 2510 : _array = array,
2495 _offset = offsetInBytes, 2511 _offset = _requireInteger(offsetInBytes),
2496 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2512 _length = _requireIntegerOrNull(
2497 : length { 2513 length,
2498 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2514 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2499 throw new IndexOutOfRangeException(offsetInBytes); 2515 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2500 }
2501 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2502 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2503 throw new IndexOutOfRangeException(length);
2504 }
2505 } 2516 }
2506 2517
2507 get length() { 2518 get length() {
2508 return _length; 2519 return _length;
2509 } 2520 }
2510 2521
2511 int operator[](int index) { 2522 int operator[](int index) {
2512 if (index < 0 || index >= _length) { 2523 if (index < 0 || index >= _length) {
2513 throw new IndexOutOfRangeException(index); 2524 throw new IndexOutOfRangeException(index);
2514 } 2525 }
2515 return _array.getInt16(_offset + (index * _BYTES_PER_ELEMENT)); 2526 return _array.getInt16(_offset + (index * _BYTES_PER_ELEMENT));
2516 } 2527 }
2517 2528
2518 void operator[]=(int index, int value) { 2529 void operator[]=(int index, int value) {
2519 if (index < 0 || index >= _length) { 2530 if (index < 0 || index >= _length) {
2520 throw new IndexOutOfRangeException(index); 2531 throw new IndexOutOfRangeException(index);
2521 } 2532 }
2522 _array.setInt16(_offset + (index * _BYTES_PER_ELEMENT), _toInt16(value)); 2533 _array.setInt16(_offset + (index * _BYTES_PER_ELEMENT), _toInt16(value));
2523 } 2534 }
2524 2535
2525 Iterator<int> iterator() { 2536 Iterator<int> iterator() {
2526 return new _ByteArrayIterator<int>(this); 2537 return new _ByteArrayIterator<int>(this);
2527 } 2538 }
2528 2539
2529 List<int> getRange(int start, int length) { 2540 List<int> getRange(int start, int length) {
2530 _rangeCheck(this, start, length); 2541 _rangeCheck(this.length, start, length);
2531 List<int> result = new Int16List(length); 2542 List<int> result = new Int16List(length);
2532 result.setRange(0, length, this, start); 2543 result.setRange(0, length, this, start);
2533 return result; 2544 return result;
2534 } 2545 }
2535 2546
2536 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2547 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2537 Arrays.copy(from, startFrom, this, start, length); 2548 Arrays.copy(from, startFrom, this, start, length);
2538 } 2549 }
2539 2550
2540 String toString() { 2551 String toString() {
2541 return Collections.collectionToString(this); 2552 return Collections.collectionToString(this);
2542 } 2553 }
2543 2554
2544 int bytesPerElement() { 2555 int bytesPerElement() {
2545 return _BYTES_PER_ELEMENT; 2556 return _BYTES_PER_ELEMENT;
2546 } 2557 }
2547 2558
2548 int lengthInBytes() { 2559 int lengthInBytes() {
2549 return _length * _BYTES_PER_ELEMENT; 2560 return _length * _BYTES_PER_ELEMENT;
2550 } 2561 }
2551 2562
2552 ByteArray asByteArray([int start = 0, int length]) { 2563 ByteArray asByteArray([int start = 0, int length]) {
2553 if (length == null) { 2564 if (length == null) {
2554 length = this.lengthInBytes(); 2565 length = this.lengthInBytes();
2555 } 2566 }
2556 _rangeCheck(start, length); 2567 _rangeCheck(this.length, start, length);
2557 return _array.subByteArray(_offset + start, length); 2568 return _array.subByteArray(_offset + start, length);
2558 } 2569 }
2559 2570
2560 static final int _BYTES_PER_ELEMENT = 2; 2571 static final int _BYTES_PER_ELEMENT = 2;
2561 final ByteArray _array; 2572 final ByteArray _array;
2562 final int _offset; 2573 final int _offset;
2563 final int _length; 2574 final int _length;
2564 } 2575 }
2565 2576
2566 2577
2567 class _Uint16ArrayView extends _ByteArrayViewBase implements Uint16List { 2578 class _Uint16ArrayView extends _ByteArrayViewBase implements Uint16List {
2568 _Uint16ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2579 _Uint16ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2569 : _array = array, 2580 : _array = array,
2570 _offset = offsetInBytes, 2581 _offset = _requireInteger(offsetInBytes),
2571 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2582 _length = _requireIntegerOrNull(
2572 : length { 2583 length,
2573 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2584 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2574 throw new IndexOutOfRangeException(offsetInBytes); 2585 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2575 }
2576 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2577 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2578 throw new IndexOutOfRangeException(length);
2579 }
2580 } 2586 }
2581 2587
2582 get length() { 2588 get length() {
2583 return _length; 2589 return _length;
2584 } 2590 }
2585 2591
2586 int operator[](int index) { 2592 int operator[](int index) {
2587 if (index < 0 || index >= _length) { 2593 if (index < 0 || index >= _length) {
2588 throw new IndexOutOfRangeException(index); 2594 throw new IndexOutOfRangeException(index);
2589 } 2595 }
2590 return _array.getUint16(_offset + (index * _BYTES_PER_ELEMENT)); 2596 return _array.getUint16(_offset + (index * _BYTES_PER_ELEMENT));
2591 } 2597 }
2592 2598
2593 void operator[]=(int index, int value) { 2599 void operator[]=(int index, int value) {
2594 if (index < 0 || index >= _length) { 2600 if (index < 0 || index >= _length) {
2595 throw new IndexOutOfRangeException(index); 2601 throw new IndexOutOfRangeException(index);
2596 } 2602 }
2597 _array.setUint16(_offset + (index * _BYTES_PER_ELEMENT), _toUint16(value)); 2603 _array.setUint16(_offset + (index * _BYTES_PER_ELEMENT), _toUint16(value));
2598 } 2604 }
2599 2605
2600 Iterator<int> iterator() { 2606 Iterator<int> iterator() {
2601 return new _ByteArrayIterator<int>(this); 2607 return new _ByteArrayIterator<int>(this);
2602 } 2608 }
2603 2609
2604 List<int> getRange(int start, int length) { 2610 List<int> getRange(int start, int length) {
2605 _rangeCheck(this, start, length); 2611 _rangeCheck(this.length, start, length);
2606 List<int> result = new Uint16List(length); 2612 List<int> result = new Uint16List(length);
2607 result.setRange(0, length, this, start); 2613 result.setRange(0, length, this, start);
2608 return result; 2614 return result;
2609 } 2615 }
2610 2616
2611 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2617 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2612 Arrays.copy(from, startFrom, this, start, length); 2618 Arrays.copy(from, startFrom, this, start, length);
2613 } 2619 }
2614 2620
2615 String toString() { 2621 String toString() {
2616 return Collections.collectionToString(this); 2622 return Collections.collectionToString(this);
2617 } 2623 }
2618 2624
2619 int bytesPerElement() { 2625 int bytesPerElement() {
2620 return _BYTES_PER_ELEMENT; 2626 return _BYTES_PER_ELEMENT;
2621 } 2627 }
2622 2628
2623 int lengthInBytes() { 2629 int lengthInBytes() {
2624 return _length * _BYTES_PER_ELEMENT; 2630 return _length * _BYTES_PER_ELEMENT;
2625 } 2631 }
2626 2632
2627 ByteArray asByteArray([int start = 0, int length]) { 2633 ByteArray asByteArray([int start = 0, int length]) {
2628 if (length == null) { 2634 if (length == null) {
2629 length = this.lengthInBytes(); 2635 length = this.lengthInBytes();
2630 } 2636 }
2631 _rangeCheck(start, length); 2637 _rangeCheck(this.length, start, length);
2632 return _array.subByteArray(_offset + start, length); 2638 return _array.subByteArray(_offset + start, length);
2633 } 2639 }
2634 2640
2635 static final int _BYTES_PER_ELEMENT = 2; 2641 static final int _BYTES_PER_ELEMENT = 2;
2636 final ByteArray _array; 2642 final ByteArray _array;
2637 final int _offset; 2643 final int _offset;
2638 final int _length; 2644 final int _length;
2639 } 2645 }
2640 2646
2641 2647
2642 class _Int32ArrayView extends _ByteArrayViewBase implements Int32List { 2648 class _Int32ArrayView extends _ByteArrayViewBase implements Int32List {
2643 _Int32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2649 _Int32ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2644 : _array = array, 2650 : _array = array,
2645 _offset = offsetInBytes, 2651 _offset = _requireInteger(offsetInBytes),
2646 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2652 _length = _requireIntegerOrNull(
2647 : length { 2653 length,
2648 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2654 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2649 throw new IndexOutOfRangeException(offsetInBytes); 2655 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2650 }
2651 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2652 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2653 throw new IndexOutOfRangeException(length);
2654 }
2655 } 2656 }
2656 2657
2657 get length() { 2658 get length() {
2658 return _length; 2659 return _length;
2659 } 2660 }
2660 2661
2661 int operator[](int index) { 2662 int operator[](int index) {
2662 if (index < 0 || index >= _length) { 2663 if (index < 0 || index >= _length) {
2663 throw new IndexOutOfRangeException(index); 2664 throw new IndexOutOfRangeException(index);
2664 } 2665 }
2665 return _array.getInt32(_offset + (index * _BYTES_PER_ELEMENT)); 2666 return _array.getInt32(_offset + (index * _BYTES_PER_ELEMENT));
2666 } 2667 }
2667 2668
2668 void operator[]=(int index, int value) { 2669 void operator[]=(int index, int value) {
2669 if (index < 0 || index >= _length) { 2670 if (index < 0 || index >= _length) {
2670 throw new IndexOutOfRangeException(index); 2671 throw new IndexOutOfRangeException(index);
2671 } 2672 }
2672 _array.setInt32(_offset + (index * _BYTES_PER_ELEMENT), _toInt32(value)); 2673 _array.setInt32(_offset + (index * _BYTES_PER_ELEMENT), _toInt32(value));
2673 } 2674 }
2674 2675
2675 Iterator<int> iterator() { 2676 Iterator<int> iterator() {
2676 return new _ByteArrayIterator<int>(this); 2677 return new _ByteArrayIterator<int>(this);
2677 } 2678 }
2678 2679
2679 List<int> getRange(int start, int length) { 2680 List<int> getRange(int start, int length) {
2680 _rangeCheck(this, start, length); 2681 _rangeCheck(this.length, start, length);
2681 List<int> result = new Int32List(length); 2682 List<int> result = new Int32List(length);
2682 result.setRange(0, length, this, start); 2683 result.setRange(0, length, this, start);
2683 return result; 2684 return result;
2684 } 2685 }
2685 2686
2686 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2687 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2687 Arrays.copy(from, startFrom, this, start, length); 2688 Arrays.copy(from, startFrom, this, start, length);
2688 } 2689 }
2689 2690
2690 String toString() { 2691 String toString() {
2691 return Collections.collectionToString(this); 2692 return Collections.collectionToString(this);
2692 } 2693 }
2693 2694
2694 int bytesPerElement() { 2695 int bytesPerElement() {
2695 return _BYTES_PER_ELEMENT; 2696 return _BYTES_PER_ELEMENT;
2696 } 2697 }
2697 2698
2698 int lengthInBytes() { 2699 int lengthInBytes() {
2699 return _length * _BYTES_PER_ELEMENT; 2700 return _length * _BYTES_PER_ELEMENT;
2700 } 2701 }
2701 2702
2702 ByteArray asByteArray([int start = 0, int length]) { 2703 ByteArray asByteArray([int start = 0, int length]) {
2703 if (length == null) { 2704 if (length == null) {
2704 length = this.lengthInBytes(); 2705 length = this.lengthInBytes();
2705 } 2706 }
2706 _rangeCheck(start, length); 2707 _rangeCheck(this.length, start, length);
2707 return _array.subByteArray(_offset + start, length); 2708 return _array.subByteArray(_offset + start, length);
2708 } 2709 }
2709 2710
2710 static final int _BYTES_PER_ELEMENT = 4; 2711 static final int _BYTES_PER_ELEMENT = 4;
2711 final ByteArray _array; 2712 final ByteArray _array;
2712 final int _offset; 2713 final int _offset;
2713 final int _length; 2714 final int _length;
2714 } 2715 }
2715 2716
2716 2717
2717 class _Uint32ArrayView extends _ByteArrayViewBase implements Uint32List { 2718 class _Uint32ArrayView extends _ByteArrayViewBase implements Uint32List {
2718 _Uint32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2719 _Uint32ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2719 : _array = array, 2720 : _array = array,
2720 _offset = offsetInBytes, 2721 _offset = _requireInteger(offsetInBytes),
2721 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2722 _length = _requireIntegerOrNull(
2722 : length { 2723 length,
2723 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2724 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2724 throw new IndexOutOfRangeException(offsetInBytes); 2725 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2725 }
2726 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2727 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2728 throw new IndexOutOfRangeException(length);
2729 }
2730 } 2726 }
2731 2727
2732 get length() { 2728 get length() {
2733 return _length; 2729 return _length;
2734 } 2730 }
2735 2731
2736 int operator[](int index) { 2732 int operator[](int index) {
2737 if (index < 0 || index >= _length) { 2733 if (index < 0 || index >= _length) {
2738 throw new IndexOutOfRangeException(index); 2734 throw new IndexOutOfRangeException(index);
2739 } 2735 }
2740 return _array.getUint32(_offset + (index * _BYTES_PER_ELEMENT)); 2736 return _array.getUint32(_offset + (index * _BYTES_PER_ELEMENT));
2741 } 2737 }
2742 2738
2743 void operator[]=(int index, int value) { 2739 void operator[]=(int index, int value) {
2744 if (index < 0 || index >= _length) { 2740 if (index < 0 || index >= _length) {
2745 throw new IndexOutOfRangeException(index); 2741 throw new IndexOutOfRangeException(index);
2746 } 2742 }
2747 _array.setUint32(_offset + (index * _BYTES_PER_ELEMENT), _toUint32(value)); 2743 _array.setUint32(_offset + (index * _BYTES_PER_ELEMENT), _toUint32(value));
2748 } 2744 }
2749 2745
2750 Iterator<int> iterator() { 2746 Iterator<int> iterator() {
2751 return new _ByteArrayIterator<int>(this); 2747 return new _ByteArrayIterator<int>(this);
2752 } 2748 }
2753 2749
2754 List<int> getRange(int start, int length) { 2750 List<int> getRange(int start, int length) {
2755 _rangeCheck(this, start, length); 2751 _rangeCheck(this.length, start, length);
2756 List<int> result = new Uint32List(length); 2752 List<int> result = new Uint32List(length);
2757 result.setRange(0, length, this, start); 2753 result.setRange(0, length, this, start);
2758 return result; 2754 return result;
2759 } 2755 }
2760 2756
2761 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2757 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2762 Arrays.copy(from, startFrom, this, start, length); 2758 Arrays.copy(from, startFrom, this, start, length);
2763 } 2759 }
2764 2760
2765 String toString() { 2761 String toString() {
2766 return Collections.collectionToString(this); 2762 return Collections.collectionToString(this);
2767 } 2763 }
2768 2764
2769 int bytesPerElement() { 2765 int bytesPerElement() {
2770 return _BYTES_PER_ELEMENT; 2766 return _BYTES_PER_ELEMENT;
2771 } 2767 }
2772 2768
2773 int lengthInBytes() { 2769 int lengthInBytes() {
2774 return _length * _BYTES_PER_ELEMENT; 2770 return _length * _BYTES_PER_ELEMENT;
2775 } 2771 }
2776 2772
2777 ByteArray asByteArray([int start = 0, int length]) { 2773 ByteArray asByteArray([int start = 0, int length]) {
2778 if (length == null) { 2774 if (length == null) {
2779 length = this.lengthInBytes(); 2775 length = this.lengthInBytes();
2780 } 2776 }
2781 _rangeCheck(start, length); 2777 _rangeCheck(this.length, start, length);
2782 return _array.subByteArray(_offset + start, length); 2778 return _array.subByteArray(_offset + start, length);
2783 } 2779 }
2784 2780
2785 static final int _BYTES_PER_ELEMENT = 4; 2781 static final int _BYTES_PER_ELEMENT = 4;
2786 final ByteArray _array; 2782 final ByteArray _array;
2787 final int _offset; 2783 final int _offset;
2788 final int _length; 2784 final int _length;
2789 } 2785 }
2790 2786
2791 2787
2792 class _Int64ArrayView extends _ByteArrayViewBase implements Int64List { 2788 class _Int64ArrayView extends _ByteArrayViewBase implements Int64List {
2793 _Int64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2789 _Int64ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2794 : _array = array, 2790 : _array = array,
2795 _offset = offsetInBytes, 2791 _offset = _requireInteger(offsetInBytes),
2796 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2792 _length = _requireIntegerOrNull(
2797 : length { 2793 length,
2798 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2794 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2799 throw new IndexOutOfRangeException(offsetInBytes); 2795 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2800 }
2801 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2802 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2803 throw new IndexOutOfRangeException(length);
2804 }
2805 } 2796 }
2806 2797
2807 get length() { 2798 get length() {
2808 return _length; 2799 return _length;
2809 } 2800 }
2810 2801
2811 int operator[](int index) { 2802 int operator[](int index) {
2812 if (index < 0 || index >= _length) { 2803 if (index < 0 || index >= _length) {
2813 throw new IndexOutOfRangeException(index); 2804 throw new IndexOutOfRangeException(index);
2814 } 2805 }
2815 return _array.getInt64(_offset + (index * _BYTES_PER_ELEMENT)); 2806 return _array.getInt64(_offset + (index * _BYTES_PER_ELEMENT));
2816 } 2807 }
2817 2808
2818 void operator[]=(int index, int value) { 2809 void operator[]=(int index, int value) {
2819 if (index < 0 || index >= _length) { 2810 if (index < 0 || index >= _length) {
2820 throw new IndexOutOfRangeException(index); 2811 throw new IndexOutOfRangeException(index);
2821 } 2812 }
2822 _array.setInt64(_offset + (index * _BYTES_PER_ELEMENT), _toInt64(value)); 2813 _array.setInt64(_offset + (index * _BYTES_PER_ELEMENT), _toInt64(value));
2823 } 2814 }
2824 2815
2825 Iterator<int> iterator() { 2816 Iterator<int> iterator() {
2826 return new _ByteArrayIterator<int>(this); 2817 return new _ByteArrayIterator<int>(this);
2827 } 2818 }
2828 2819
2829 List<int> getRange(int start, int length) { 2820 List<int> getRange(int start, int length) {
2830 _rangeCheck(this, start, length); 2821 _rangeCheck(this.length, start, length);
2831 List<int> result = new Int64List(length); 2822 List<int> result = new Int64List(length);
2832 result.setRange(0, length, this, start); 2823 result.setRange(0, length, this, start);
2833 return result; 2824 return result;
2834 } 2825 }
2835 2826
2836 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2827 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2837 Arrays.copy(from, startFrom, this, start, length); 2828 Arrays.copy(from, startFrom, this, start, length);
2838 } 2829 }
2839 2830
2840 String toString() { 2831 String toString() {
2841 return Collections.collectionToString(this); 2832 return Collections.collectionToString(this);
2842 } 2833 }
2843 2834
2844 int bytesPerElement() { 2835 int bytesPerElement() {
2845 return _BYTES_PER_ELEMENT; 2836 return _BYTES_PER_ELEMENT;
2846 } 2837 }
2847 2838
2848 int lengthInBytes() { 2839 int lengthInBytes() {
2849 return _length * _BYTES_PER_ELEMENT; 2840 return _length * _BYTES_PER_ELEMENT;
2850 } 2841 }
2851 2842
2852 ByteArray asByteArray([int start = 0, int length]) { 2843 ByteArray asByteArray([int start = 0, int length]) {
2853 if (length == null) { 2844 if (length == null) {
2854 length = this.lengthInBytes(); 2845 length = this.lengthInBytes();
2855 } 2846 }
2856 _rangeCheck(start, length); 2847 _rangeCheck(this.length, start, length);
2857 return _array.subByteArray(_offset + start, length); 2848 return _array.subByteArray(_offset + start, length);
2858 } 2849 }
2859 2850
2860 static final int _BYTES_PER_ELEMENT = 8; 2851 static final int _BYTES_PER_ELEMENT = 8;
2861 final ByteArray _array; 2852 final ByteArray _array;
2862 final int _offset; 2853 final int _offset;
2863 final int _length; 2854 final int _length;
2864 } 2855 }
2865 2856
2866 2857
2867 class _Uint64ArrayView extends _ByteArrayViewBase implements Uint64List { 2858 class _Uint64ArrayView extends _ByteArrayViewBase implements Uint64List {
2868 _Uint64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2859 _Uint64ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2869 : _array = array, 2860 : _array = array,
2870 _offset = offsetInBytes, 2861 _offset = _requireInteger(offsetInBytes),
2871 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2862 _length = _requireIntegerOrNull(
2872 : length { 2863 length,
2873 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2864 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2874 throw new IndexOutOfRangeException(offsetInBytes); 2865 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2875 }
2876 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2877 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2878 throw new IndexOutOfRangeException(length);
2879 }
2880 } 2866 }
2881 2867
2882 get length() { 2868 get length() {
2883 return _length; 2869 return _length;
2884 } 2870 }
2885 2871
2886 int operator[](int index) { 2872 int operator[](int index) {
2887 if (index < 0 || index >= _length) { 2873 if (index < 0 || index >= _length) {
2888 throw new IndexOutOfRangeException(index); 2874 throw new IndexOutOfRangeException(index);
2889 } 2875 }
2890 return _array.getUint64(_offset + (index * _BYTES_PER_ELEMENT)); 2876 return _array.getUint64(_offset + (index * _BYTES_PER_ELEMENT));
2891 } 2877 }
2892 2878
2893 void operator[]=(int index, int value) { 2879 void operator[]=(int index, int value) {
2894 if (index < 0 || index >= _length) { 2880 if (index < 0 || index >= _length) {
2895 throw new IndexOutOfRangeException(index); 2881 throw new IndexOutOfRangeException(index);
2896 } 2882 }
2897 _array.setUint64(_offset + (index * _BYTES_PER_ELEMENT), _toUint64(value)); 2883 _array.setUint64(_offset + (index * _BYTES_PER_ELEMENT), _toUint64(value));
2898 } 2884 }
2899 2885
2900 Iterator<int> iterator() { 2886 Iterator<int> iterator() {
2901 return new _ByteArrayIterator<int>(this); 2887 return new _ByteArrayIterator<int>(this);
2902 } 2888 }
2903 2889
2904 List<int> getRange(int start, int length) { 2890 List<int> getRange(int start, int length) {
2905 _rangeCheck(this, start, length); 2891 _rangeCheck(this.length, start, length);
2906 List<int> result = new Uint64List(length); 2892 List<int> result = new Uint64List(length);
2907 result.setRange(0, length, this, start); 2893 result.setRange(0, length, this, start);
2908 return result; 2894 return result;
2909 } 2895 }
2910 2896
2911 void setRange(int start, int length, List<int> from, [int startFrom = 0]) { 2897 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
2912 Arrays.copy(from, startFrom, this, start, length); 2898 Arrays.copy(from, startFrom, this, start, length);
2913 } 2899 }
2914 2900
2915 String toString() { 2901 String toString() {
2916 return Collections.collectionToString(this); 2902 return Collections.collectionToString(this);
2917 } 2903 }
2918 2904
2919 int bytesPerElement() { 2905 int bytesPerElement() {
2920 return _BYTES_PER_ELEMENT; 2906 return _BYTES_PER_ELEMENT;
2921 } 2907 }
2922 2908
2923 int lengthInBytes() { 2909 int lengthInBytes() {
2924 return _length * _BYTES_PER_ELEMENT; 2910 return _length * _BYTES_PER_ELEMENT;
2925 } 2911 }
2926 2912
2927 ByteArray asByteArray([int start = 0, int length]) { 2913 ByteArray asByteArray([int start = 0, int length]) {
2928 if (length == null) { 2914 if (length == null) {
2929 length = this.lengthInBytes(); 2915 length = this.lengthInBytes();
2930 } 2916 }
2931 _rangeCheck(start, length); 2917 _rangeCheck(this.length, start, length);
2932 return _array.subByteArray(_offset + start, length); 2918 return _array.subByteArray(_offset + start, length);
2933 } 2919 }
2934 2920
2935 static final int _BYTES_PER_ELEMENT = 8; 2921 static final int _BYTES_PER_ELEMENT = 8;
2936 final ByteArray _array; 2922 final ByteArray _array;
2937 final int _offset; 2923 final int _offset;
2938 final int _length; 2924 final int _length;
2939 } 2925 }
2940 2926
2941 2927
2942 class _Float32ArrayView extends _ByteArrayViewBase implements Float32List { 2928 class _Float32ArrayView extends _ByteArrayViewBase implements Float32List {
2943 _Float32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2929 _Float32ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2944 : _array = array, 2930 : _array = array,
2945 _offset = offsetInBytes, 2931 _offset = _requireInteger(offsetInBytes),
2946 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 2932 _length = _requireIntegerOrNull(
2947 : length { 2933 length,
2948 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 2934 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2949 throw new IndexOutOfRangeException(offsetInBytes); 2935 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2950 }
2951 int lengthInBytes = length * _BYTES_PER_ELEMENT;
2952 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
2953 throw new IndexOutOfRangeException(length);
2954 }
2955 } 2936 }
2956 2937
2957 get length() { 2938 get length() {
2958 return _length; 2939 return _length;
2959 } 2940 }
2960 2941
2961 double operator[](int index) { 2942 double operator[](int index) {
2962 if (index < 0 || index >= _length) { 2943 if (index < 0 || index >= _length) {
2963 throw new IndexOutOfRangeException(index); 2944 throw new IndexOutOfRangeException(index);
2964 } 2945 }
2965 return _array.getFloat32(_offset + (index * _BYTES_PER_ELEMENT)); 2946 return _array.getFloat32(_offset + (index * _BYTES_PER_ELEMENT));
2966 } 2947 }
2967 2948
2968 void operator[]=(int index, double value) { 2949 void operator[]=(int index, double value) {
2969 if (index < 0 || index >= _length) { 2950 if (index < 0 || index >= _length) {
2970 throw new IndexOutOfRangeException(index); 2951 throw new IndexOutOfRangeException(index);
2971 } 2952 }
2972 _array.setFloat32(_offset + (index * _BYTES_PER_ELEMENT), value); 2953 _array.setFloat32(_offset + (index * _BYTES_PER_ELEMENT), value);
2973 } 2954 }
2974 2955
2975 Iterator<double> iterator() { 2956 Iterator<double> iterator() {
2976 return new _ByteArrayIterator<double>(this); 2957 return new _ByteArrayIterator<double>(this);
2977 } 2958 }
2978 2959
2979 List<double> getRange(int start, int length) { 2960 List<double> getRange(int start, int length) {
2980 _rangeCheck(this, start, length); 2961 _rangeCheck(this.length, start, length);
2981 List<double> result = new Float32List(length); 2962 List<double> result = new Float32List(length);
2982 result.setRange(0, length, this, start); 2963 result.setRange(0, length, this, start);
2983 return result; 2964 return result;
2984 } 2965 }
2985 2966
2986 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { 2967 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
2987 Arrays.copy(from, startFrom, this, start, length); 2968 Arrays.copy(from, startFrom, this, start, length);
2988 } 2969 }
2989 2970
2990 String toString() { 2971 String toString() {
2991 return Collections.collectionToString(this); 2972 return Collections.collectionToString(this);
2992 } 2973 }
2993 2974
2994 int bytesPerElement() { 2975 int bytesPerElement() {
2995 return _BYTES_PER_ELEMENT; 2976 return _BYTES_PER_ELEMENT;
2996 } 2977 }
2997 2978
2998 int lengthInBytes() { 2979 int lengthInBytes() {
2999 return _length * _BYTES_PER_ELEMENT; 2980 return _length * _BYTES_PER_ELEMENT;
3000 } 2981 }
3001 2982
3002 ByteArray asByteArray([int start = 0, int length]) { 2983 ByteArray asByteArray([int start = 0, int length]) {
3003 if (length == null) { 2984 if (length == null) {
3004 length = this.lengthInBytes(); 2985 length = this.lengthInBytes();
3005 } 2986 }
3006 _rangeCheck(start, length); 2987 _rangeCheck(this.length, start, length);
3007 return _array.subByteArray(_offset + start, length); 2988 return _array.subByteArray(_offset + start, length);
3008 } 2989 }
3009 2990
3010 static final int _BYTES_PER_ELEMENT = 4; 2991 static final int _BYTES_PER_ELEMENT = 4;
3011 final ByteArray _array; 2992 final ByteArray _array;
3012 final int _offset; 2993 final int _offset;
3013 final int _length; 2994 final int _length;
3014 } 2995 }
3015 2996
3016 2997
3017 class _Float64ArrayView extends _ByteArrayViewBase implements Float64List { 2998 class _Float64ArrayView extends _ByteArrayViewBase implements Float64List {
3018 _Float64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2999 _Float64ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
3019 : _array = array, 3000 : _array = array,
3020 _offset = offsetInBytes, 3001 _offset = _requireInteger(offsetInBytes),
3021 _length = (length === null) ? (array.lengthInBytes() - offsetInBytes) 3002 _length = _requireIntegerOrNull(
3022 : length { 3003 length,
3023 if (offsetInBytes < 0 || offsetInBytes >= array.lengthInBytes()) { 3004 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
3024 throw new IndexOutOfRangeException(offsetInBytes); 3005 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
3025 }
3026 int lengthInBytes = length * _BYTES_PER_ELEMENT;
3027 if (length < 0 || (lengthInBytes + _offset) > array.lengthInBytes()) {
3028 throw new IndexOutOfRangeException(length);
3029 }
3030 } 3006 }
3031 3007
3032 get length() { 3008 get length() {
3033 return _length; 3009 return _length;
3034 } 3010 }
3035 3011
3036 double operator[](int index) { 3012 double operator[](int index) {
3037 if (index < 0 || index >= _length) { 3013 if (index < 0 || index >= _length) {
3038 throw new IndexOutOfRangeException(index); 3014 throw new IndexOutOfRangeException(index);
3039 } 3015 }
3040 return _array.getFloat64(_offset + (index * _BYTES_PER_ELEMENT)); 3016 return _array.getFloat64(_offset + (index * _BYTES_PER_ELEMENT));
3041 } 3017 }
3042 3018
3043 void operator[]=(int index, double value) { 3019 void operator[]=(int index, double value) {
3044 if (index < 0 || index >= _length) { 3020 if (index < 0 || index >= _length) {
3045 throw new IndexOutOfRangeException(index); 3021 throw new IndexOutOfRangeException(index);
3046 } 3022 }
3047 _array.setFloat64(_offset + (index * _BYTES_PER_ELEMENT), value); 3023 _array.setFloat64(_offset + (index * _BYTES_PER_ELEMENT), value);
3048 } 3024 }
3049 3025
3050 Iterator<double> iterator() { 3026 Iterator<double> iterator() {
3051 return new _ByteArrayIterator<double>(this); 3027 return new _ByteArrayIterator<double>(this);
3052 } 3028 }
3053 3029
3054 List<double> getRange(int start, int length) { 3030 List<double> getRange(int start, int length) {
3055 _rangeCheck(this, start, length); 3031 _rangeCheck(this.length, start, length);
3056 List<double> result = new Float64List(length); 3032 List<double> result = new Float64List(length);
3057 result.setRange(0, length, this, start); 3033 result.setRange(0, length, this, start);
3058 return result; 3034 return result;
3059 } 3035 }
3060 3036
3061 void setRange(int start, int length, List<double> from, [int startFrom = 0]) { 3037 void setRange(int start, int length, List<double> from, [int startFrom = 0]) {
3062 Arrays.copy(from, startFrom, this, start, length); 3038 Arrays.copy(from, startFrom, this, start, length);
3063 } 3039 }
3064 3040
3065 String toString() { 3041 String toString() {
3066 return Collections.collectionToString(this); 3042 return Collections.collectionToString(this);
3067 } 3043 }
3068 3044
3069 int bytesPerElement() { 3045 int bytesPerElement() {
3070 return _BYTES_PER_ELEMENT; 3046 return _BYTES_PER_ELEMENT;
3071 } 3047 }
3072 3048
3073 int lengthInBytes() { 3049 int lengthInBytes() {
3074 return _length * _BYTES_PER_ELEMENT; 3050 return _length * _BYTES_PER_ELEMENT;
3075 } 3051 }
3076 3052
3077 ByteArray asByteArray([int start = 0, int length]) { 3053 ByteArray asByteArray([int start = 0, int length]) {
3078 if (length == null) { 3054 if (length == null) {
3079 length = this.lengthInBytes(); 3055 length = this.lengthInBytes();
3080 } 3056 }
3081 _rangeCheck(start, length); 3057 _rangeCheck(this.length, start, length);
3082 return _array.subByteArray(_offset + start, length); 3058 return _array.subByteArray(_offset + start, length);
3083 } 3059 }
3084 3060
3085 static final int _BYTES_PER_ELEMENT = 8; 3061 static final int _BYTES_PER_ELEMENT = 8;
3086 final ByteArray _array; 3062 final ByteArray _array;
3087 final int _offset; 3063 final int _offset;
3088 final int _length; 3064 final int _length;
3089 } 3065 }
OLDNEW
« no previous file with comments | « corelib/src/string_buffer.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698