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

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

Issue 11956039: Revert "Create IterableMixinWorkaround and move most of the Collections methods there." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « runtime/lib/array.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 patch class Int8List { 5 patch class Int8List {
6 /* patch */ factory Int8List(int length) { 6 /* patch */ factory Int8List(int length) {
7 return new _Int8Array(length); 7 return new _Int8Array(length);
8 } 8 }
9 9
10 /* patch */ factory Int8List.transferable(int length) { 10 /* patch */ factory Int8List.transferable(int length) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 abstract class _ByteArrayBase { 181 abstract class _ByteArrayBase {
182 int lengthInBytes(); 182 int lengthInBytes();
183 183
184 int bytesPerElement(); 184 int bytesPerElement();
185 185
186 operator[](int index); 186 operator[](int index);
187 187
188 // Methods implementing the Collection interface. 188 // Methods implementing the Collection interface.
189 189
190 bool contains(element) => IterableMixinWorkaround.contains(this, element); 190 bool contains(element) => Collections.contains(this, element);
191 191
192 void forEach(void f(element)) { 192 void forEach(void f(element)) {
193 var len = this.length; 193 var len = this.length;
194 for (var i = 0; i < len; i++) { 194 for (var i = 0; i < len; i++) {
195 f(this[i]); 195 f(this[i]);
196 } 196 }
197 } 197 }
198 198
199 List mappedBy(f(int element)) { 199 List mappedBy(f(int element)) {
200 return IterableMixinWorkaround.mappedByList(this, f); 200 return new MappedList<int, dynamic>(this, f);
201 } 201 }
202 202
203 String join([String separator]) { 203 String join([String separator]) {
204 return IterableMixinWorkaround.join(this, separator); 204 return Collections.join(this, separator);
205 } 205 }
206 206
207 dynamic reduce(dynamic initialValue, 207 dynamic reduce(dynamic initialValue,
208 dynamic combine(dynamic initialValue, element)) { 208 dynamic combine(dynamic initialValue, element)) {
209 return IterableMixinWorkaround.reduce(this, initialValue, combine); 209 return Collections.reduce(this, initialValue, combine);
210 } 210 }
211 211
212 Collection where(bool f(element)) { 212 Collection where(bool f(element)) {
213 return IterableMixinWorkaround.where(this, f); 213 return new WhereIterable<int>(this, f);
214 } 214 }
215 215
216 List<int> take(int n) { 216 List<int> take(int n) {
217 return IterableMixinWorkaround.takeList(this, n); 217 return new ListView<int>(this, 0, n);
218 } 218 }
219 219
220 Iterable<int> takeWhile(bool test(int value)) { 220 Iterable<int> takeWhile(bool test(int value)) {
221 return IterableMixinWorkaround.takeWhile(this, test); 221 return new TakeWhileIterable<int>(this, test);
222 } 222 }
223 223
224 List<int> skip(int n) { 224 List<int> skip(int n) {
225 return IterableMixinWorkaround.skipList(this, n); 225 return new ListView<int>(this, n, null);
226 } 226 }
227 227
228 Iterable<int> skipWhile(bool test(int value)) { 228 Iterable<int> skipWhile(bool test(int value)) {
229 return IterableMixinWorkaround.skipWhile(this, test); 229 return new SkipWhileIterable<int>(this, test);
230 } 230 }
231 231
232 bool every(bool f(element)) { 232 bool every(bool f(element)) {
233 return IterableMixinWorkaround.every(this, f); 233 return Collections.every(this, f);
234 } 234 }
235 235
236 bool any(bool f(element)) { 236 bool any(bool f(element)) {
237 return IterableMixinWorkaround.any(this, f); 237 return Collections.any(this, f);
238 } 238 }
239 239
240 int firstMatching(bool test(int value), {int orElse()}) { 240 int firstMatching(bool test(int value), {int orElse()}) {
241 return IterableMixinWorkaround.firstMatching(this, test, orElse); 241 return Collections.firstMatching(this, test, orElse);
242 } 242 }
243 243
244 int lastMatching(bool test(int value), {int orElse()}) { 244 int lastMatching(bool test(int value), {int orElse()}) {
245 return IterableMixinWorkaround.lastMatchingInList(this, test, orElse); 245 return Collections.lastMatchingInList(this, test, orElse);
246 } 246 }
247 247
248 int singleMatching(bool test(int value)) { 248 int singleMatching(bool test(int value)) {
249 return IterableMixinWorkaround.singleMatching(this, test); 249 return Collections.singleMatching(this, test);
250 } 250 }
251 251
252 int elementAt(int index) { 252 int elementAt(int index) {
253 return this[index]; 253 return this[index];
254 } 254 }
255 255
256 bool get isEmpty { 256 bool get isEmpty {
257 return this.length == 0; 257 return this.length == 0;
258 } 258 }
259 259
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 if (length > 0) return this[length - 1]; 316 if (length > 0) return this[length - 1];
317 throw new StateError("No elements"); 317 throw new StateError("No elements");
318 } 318 }
319 319
320 int get single { 320 int get single {
321 if (length == 1) return this[0]; 321 if (length == 1) return this[0];
322 if (length == 0) throw new StateError("No elements"); 322 if (length == 0) throw new StateError("No elements");
323 throw new StateError("More than one element"); 323 throw new StateError("More than one element");
324 } 324 }
325 325
326 int min([int compare(int a, int b)]) => IterableMixinWorkaround.min(this, comp are); 326 int min([int compare(int a, int b)]) => Collections.min(this, compare);
327 327
328 int max([int compare(int a, int b)]) => IterableMixinWorkaround.max(this, comp are); 328 int max([int compare(int a, int b)]) => Collections.max(this, compare);
329 329
330 void removeRange(int start, int length) { 330 void removeRange(int start, int length) {
331 throw new UnsupportedError( 331 throw new UnsupportedError(
332 "Cannot remove from a non-extendable array"); 332 "Cannot remove from a non-extendable array");
333 } 333 }
334 334
335 void insertRange(int start, int length, [initialValue]) { 335 void insertRange(int start, int length, [initialValue]) {
336 throw new UnsupportedError( 336 throw new UnsupportedError(
337 "Cannot add to a non-extendable array"); 337 "Cannot add to a non-extendable array");
338 } 338 }
(...skipping 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 ByteArray asByteArray([int start = 0, int length]) { 2649 ByteArray asByteArray([int start = 0, int length]) {
2650 if (length == null) { 2650 if (length == null) {
2651 length = this.lengthInBytes(); 2651 length = this.lengthInBytes();
2652 } 2652 }
2653 _rangeCheck(this.length, start, length); 2653 _rangeCheck(this.length, start, length);
2654 return _array.subByteArray(_offset + start, length); 2654 return _array.subByteArray(_offset + start, length);
2655 } 2655 }
2656 2656
2657 static const int _BYTES_PER_ELEMENT = 8; 2657 static const int _BYTES_PER_ELEMENT = 8;
2658 } 2658 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/growable_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698