OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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> factory ListFactory { | 9 interface List<E> extends Collection<E> factory ListFactory { |
10 | 10 |
11 /** | 11 /** |
12 * Creates a list of the given [length]. | 12 * Creates a list of the given [length]. |
13 */ | 13 */ |
14 List([int length]); | 14 List([int length]); |
15 | 15 |
16 /** | 16 /** |
17 * Creates a list with the elements of [other]. The order in | 17 * Creates a list with the elements of [other]. The order in |
18 * the list will be the order provided by the iterator of [other]. | 18 * the list will be the order provided by the iterator of [other]. |
19 */ | 19 */ |
20 List.from(Iterable<E> other); | 20 List.from(Iterable<E> other); |
21 | 21 |
22 /** | 22 /** |
23 * Creates a list which is a subcopy of [other], starting at | |
24 * [startIndex] (inclusive) and ending at [endIndex] (exclusive). If | |
25 * [startIndex] is negative, it has the same effect as if it were | |
26 * zero. If [endIndex] is greather than the length, it has the same | |
27 * effect as if it were [:other.length:]. If [:startIndex > endIndex:], | |
28 * the created list is of [length] 0. | |
29 */ | |
30 List.fromList(List<E> other, int startIndex, int endIndex); | |
31 | |
32 /** | |
33 * Returns the element at the given [index] in the list or throws | 23 * Returns the element at the given [index] in the list or throws |
34 * an [IndexOutOfRangeException] if [index] is out of bounds. | 24 * an [IndexOutOfRangeException] if [index] is out of bounds. |
35 */ | 25 */ |
36 E operator [](int index); | 26 E operator [](int index); |
37 | 27 |
38 /** | 28 /** |
39 * Sets the entry at the given [index] in the list to [value]. | 29 * Sets the entry at the given [index] in the list to [value]. |
40 * Throws an [IndexOutOfRangeException] if [index] is out of bounds. | 30 * Throws an [IndexOutOfRangeException] if [index] is out of bounds. |
41 */ | 31 */ |
42 void operator []=(int index, E value); | 32 void operator []=(int index, E value); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 * The comparator function [compare] must take two arguments [a] and [b] | 68 * The comparator function [compare] must take two arguments [a] and [b] |
79 * and return | 69 * and return |
80 * | 70 * |
81 * an integer strictly less than 0 if a < b, | 71 * an integer strictly less than 0 if a < b, |
82 * 0 if a = b, and | 72 * 0 if a = b, and |
83 * an integer strictly greater than 0 if a > b. | 73 * an integer strictly greater than 0 if a > b. |
84 */ | 74 */ |
85 void sort(int compare(E a, E b)); | 75 void sort(int compare(E a, E b)); |
86 | 76 |
87 /** | 77 /** |
88 * Copies [count] elements from the [src] list starting at index | |
89 * [srcStart] to this list starting at index [dstStart]. | |
90 * | |
91 * The type of [src] is List<Object> because one must be able to | |
92 * give a List<Object> only containing eg. String objects and copy | |
93 * its elements into a List<String>. | |
94 */ | |
95 void copyFrom(List<Object> src, int srcStart, int dstStart, int count); | |
96 | |
97 /** | |
98 * Returns the first index of [element] in this list. Searches this | 78 * Returns the first index of [element] in this list. Searches this |
99 * list from index [startIndex] to the length of the list. Returns | 79 * list from index [startIndex] to the length of the list. Returns |
100 * -1 if [element] is not found. | 80 * -1 if [element] is not found. |
101 */ | 81 */ |
102 int indexOf(E element, int startIndex); | 82 int indexOf(E element, int startIndex); |
103 | 83 |
104 /** | 84 /** |
105 * Returns the last index of [element] in this list. Searches this | 85 * Returns the last index of [element] in this list. Searches this |
106 * list from index [startIndex] to 0. Returns -1 if [element] is | 86 * list from index [startIndex] to 0. Returns -1 if [element] is |
107 * not found. | 87 * not found. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 * not extendable. | 150 * not extendable. |
171 * If [length] is 0, this method does not do anything. | 151 * If [length] is 0, this method does not do anything. |
172 * If [start] is the length of the array, this method inserts the | 152 * If [start] is the length of the array, this method inserts the |
173 * range at the end of the array. | 153 * range at the end of the array. |
174 * Throws an [IllegalArgumentException] if [length] is negative. | 154 * Throws an [IllegalArgumentException] if [length] is negative. |
175 * Throws an [IndexOutOfRangeException] if [start] or | 155 * Throws an [IndexOutOfRangeException] if [start] or |
176 * [:start + length:] are out of range. | 156 * [:start + length:] are out of range. |
177 */ | 157 */ |
178 void insertRange(int start, int length, [E initialValue]); | 158 void insertRange(int start, int length, [E initialValue]); |
179 } | 159 } |
OLD | NEW |