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

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

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 years, 9 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
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 // TODO(srdjan): Use shared array implementation. 6 // TODO(srdjan): Use shared array implementation.
7 class _ObjectArray<E> implements List<E> { 7 class _ObjectArray<E> implements List<E> {
8 8
9 factory _ObjectArray(int length) native "ObjectArray_allocate"; 9 factory _ObjectArray(int length) native "ObjectArray_allocate";
10 10
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 E get single { 221 E get single {
222 if (length == 1) return this[0]; 222 if (length == 1) return this[0];
223 if (length == 0) throw new StateError("No elements"); 223 if (length == 0) throw new StateError("No elements");
224 throw new StateError("More than one element"); 224 throw new StateError("More than one element");
225 } 225 }
226 226
227 E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare); 227 E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare);
228 228
229 E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare); 229 E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare);
230 230
231 List<E> toList() { 231 List<E> toList({ bool growable: false}) {
232 return new List<E>.from(this); 232 return new List<E>.from(this, growable: growable);
233 } 233 }
234 234
235 Set<E> toSet() { 235 Set<E> toSet() {
236 return new Set<E>.from(this); 236 return new Set<E>.from(this);
237 } 237 }
238 } 238 }
239 239
240 240
241 // This is essentially the same class as _ObjectArray, but it does not 241 // This is essentially the same class as _ObjectArray, but it does not
242 // permit any modification of array elements from Dart code. We use 242 // permit any modification of array elements from Dart code. We use
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 E get single { 460 E get single {
461 if (length == 1) return this[0]; 461 if (length == 1) return this[0];
462 if (length == 0) throw new StateError("No elements"); 462 if (length == 0) throw new StateError("No elements");
463 throw new StateError("More than one element"); 463 throw new StateError("More than one element");
464 } 464 }
465 465
466 E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare); 466 E min([int compare(E a, E b)]) => IterableMixinWorkaround.min(this, compare);
467 467
468 E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare); 468 E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare);
469 469
470 List<E> toList() { 470 List<E> toList({ bool growable: false }) {
471 return new List<E>.from(this); 471 return new List<E>.from(this, growable: growable);
472 } 472 }
473 473
474 Set<E> toSet() { 474 Set<E> toSet() {
475 return new Set<E>.from(this); 475 return new Set<E>.from(this);
476 } 476 }
477 } 477 }
478 478
479 479
480 // Iterator for arrays with fixed size. 480 // Iterator for arrays with fixed size.
481 class _FixedSizeArrayIterator<E> implements Iterator<E> { 481 class _FixedSizeArrayIterator<E> implements Iterator<E> {
(...skipping 16 matching lines...) Expand all
498 } 498 }
499 _position = _length; 499 _position = _length;
500 _current = null; 500 _current = null;
501 return false; 501 return false;
502 } 502 }
503 503
504 E get current { 504 E get current {
505 return _current; 505 return _current;
506 } 506 }
507 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698