Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A [List] is an indexable collection with a length. It can be of | 8 * A [List] is an indexable collection with a length. It can be of |
| 9 * fixed size or extendable. | 9 * fixed size or extendable. |
| 10 */ | 10 */ |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 * The length of the returned list is not fixed. | 29 * The length of the returned list is not fixed. |
| 30 */ | 30 */ |
| 31 external factory List.filled(int length, E fill); | 31 external factory List.filled(int length, E fill); |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Creates an list with the elements of [other]. The order in | 34 * Creates an list with the elements of [other]. The order in |
| 35 * the list will be the order provided by the iterator of [other]. | 35 * the list will be the order provided by the iterator of [other]. |
| 36 * | 36 * |
| 37 * The length of the returned list is not fixed. | 37 * The length of the returned list is not fixed. |
| 38 */ | 38 */ |
| 39 factory List.from(Iterable<E> other) { | 39 factory List.from(Iterable other) { |
| 40 var list = new List<E>(); | 40 var list = new List<E>(); |
| 41 for (var e in other) { | 41 for (var e in other) { |
|
floitsch
2013/01/07 14:59:02
for (E e in other) {
| |
| 42 list.add(e); | 42 list.add(e); |
| 43 } | 43 } |
| 44 return list; | 44 return list; |
| 45 } | 45 } |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Returns the element at the given [index] in the list or throws | 48 * Returns the element at the given [index] in the list or throws |
| 49 * an [RangeError] if [index] is out of bounds. | 49 * an [RangeError] if [index] is out of bounds. |
| 50 */ | 50 */ |
| 51 E operator [](int index); | 51 E operator [](int index); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 | 424 |
| 425 ListView<E> take(int takeCount) { | 425 ListView<E> take(int takeCount) { |
| 426 if (takeCount is! int || takeCount < 0) { | 426 if (takeCount is! int || takeCount < 0) { |
| 427 throw new ArgumentError(takeCount); | 427 throw new ArgumentError(takeCount); |
| 428 } | 428 } |
| 429 int newLength = takeCount; | 429 int newLength = takeCount; |
| 430 if (_length != null && takeCount > _length) newLength = _length; | 430 if (_length != null && takeCount > _length) newLength = _length; |
| 431 return new ListView(_list, _offset, newLength); | 431 return new ListView(_list, _offset, newLength); |
| 432 } | 432 } |
| 433 } | 433 } |
| OLD | NEW |