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

Side by Side Diff: lib/core/list.dart

Issue 10942025: Convert String and List to abstract classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to tip-of-tree. Created 8 years, 2 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 * A [List] is an indexable collection with a length. It can be of 6 * A [List] is an indexable collection with a length. It can be of
7 * fixed size or extendable. 7 * fixed size or extendable.
8 */ 8 */
9 interface List<E> extends Collection<E> default ListImplementation<E> { 9 abstract class List<E> extends Collection<E> {
10
11 /** 10 /**
12 * Creates a list of the given [length]. 11 * Creates a list of the given [length].
13 * 12 *
14 * If no [length] argument is supplied an extendable list of 13 * If no [length] argument is supplied an extendable list of
15 * length 0 is created. 14 * length 0 is created.
16 * 15 *
17 * If a [length] argument is supplied, a fixed size list of that 16 * If a [length] argument is supplied, a fixed size list of that
18 * length is created. 17 * length is created.
19 */ 18 */
20 List([int length]); 19 external factory List([int length]);
21 20
22 /** 21 /**
23 * Creates a list with the elements of [other]. The order in 22 * Creates a list with the elements of [other]. The order in
24 * the list will be the order provided by the iterator of [other]. 23 * the list will be the order provided by the iterator of [other].
25 */ 24 */
26 List.from(Iterable<E> other); 25 factory List.from(Iterable<E> other) {
26 List<E> result = new List<E>();
27 for (E element in other) {
28 result.add(element);
29 }
30 return result;
31 }
27 32
28 /** 33 /**
29 * Returns the element at the given [index] in the list or throws 34 * Returns the element at the given [index] in the list or throws
30 * an [IndexOutOfRangeException] if [index] is out of bounds. 35 * an [IndexOutOfRangeException] if [index] is out of bounds.
31 */ 36 */
32 E operator [](int index); 37 E operator [](int index);
33 38
34 /** 39 /**
35 * Sets the entry at the given [index] in the list to [value]. 40 * Sets the entry at the given [index] in the list to [value].
36 * Throws an [IndexOutOfRangeException] if [index] is out of bounds. 41 * Throws an [IndexOutOfRangeException] if [index] is out of bounds.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 * not extendable. 172 * not extendable.
168 * If [length] is 0, this method does not do anything. 173 * If [length] is 0, this method does not do anything.
169 * If [start] is the length of the list, this method inserts the 174 * If [start] is the length of the list, this method inserts the
170 * range at the end of the list. 175 * range at the end of the list.
171 * Throws an [ArgumentError] if [length] is negative. 176 * Throws an [ArgumentError] if [length] is negative.
172 * Throws an [IndexOutOfRangeException] if [start] is negative or if 177 * Throws an [IndexOutOfRangeException] if [start] is negative or if
173 * [start] is greater than the length of the list. 178 * [start] is greater than the length of the list.
174 */ 179 */
175 void insertRange(int start, int length, [E initialValue]); 180 void insertRange(int start, int length, [E initialValue]);
176 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698