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 /** | 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 abstract class List<E> implements Collection<E>, Sequence<E> { | 9 abstract class List<E> implements Collection<E>, Sequence<E> { |
10 /** | 10 /** |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 /** | 66 /** |
67 * Appends all elements of the [collection] to the end of this list. | 67 * Appends all elements of the [collection] to the end of this list. |
68 * Extends the length of the list by the number of elements in [collection]. | 68 * Extends the length of the list by the number of elements in [collection]. |
69 * Throws an [UnsupportedError] if this list is not | 69 * Throws an [UnsupportedError] if this list is not |
70 * extendable. | 70 * extendable. |
71 */ | 71 */ |
72 void addAll(Collection<E> collection); | 72 void addAll(Collection<E> collection); |
73 | 73 |
74 /** | 74 /** |
75 * Sorts the list according to the order specified by the [Comparator]. | 75 * Sorts the list according to the order specified by the [compare] function. |
| 76 * |
| 77 * The [compare] function must act as a [Comparator]. |
| 78 * The default [List] implementations use [Comparable.compare] if |
| 79 * [compare] is omitted. |
76 */ | 80 */ |
77 void sort([Comparator<E> compare = Comparable.compare]); | 81 void sort([int compare(E a, E b)]); |
78 | 82 |
79 /** | 83 /** |
80 * Returns the first index of [element] in the list. | 84 * Returns the first index of [element] in the list. |
81 * | 85 * |
82 * Searches the list from index [start] to the length of the list. | 86 * Searches the list from index [start] to the length of the list. |
83 * The first time an element [:e:] is encountered so that [:e == element:], | 87 * The first time an element [:e:] is encountered so that [:e == element:], |
84 * the index of [:e:] is returned. | 88 * the index of [:e:] is returned. |
85 * Returns -1 if [element] is not found. | 89 * Returns -1 if [element] is not found. |
86 */ | 90 */ |
87 int indexOf(E element, [int start = 0]); | 91 int indexOf(E element, [int start = 0]); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 * not extendable. | 182 * not extendable. |
179 * If [length] is 0, this method does not do anything. | 183 * If [length] is 0, this method does not do anything. |
180 * If [start] is the length of the list, this method inserts the | 184 * If [start] is the length of the list, this method inserts the |
181 * range at the end of the list. | 185 * range at the end of the list. |
182 * Throws an [ArgumentError] if [length] is negative. | 186 * Throws an [ArgumentError] if [length] is negative. |
183 * Throws an [RangeError] if [start] is negative or if | 187 * Throws an [RangeError] if [start] is negative or if |
184 * [start] is greater than the length of the list. | 188 * [start] is greater than the length of the list. |
185 */ | 189 */ |
186 void insertRange(int start, int length, [E initialValue]); | 190 void insertRange(int start, int length, [E initialValue]); |
187 } | 191 } |
OLD | NEW |