Chromium Code Reviews| 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> default ListFactory<E> { | 9 interface List<E> extends Collection<E> default ListFactory<E> { |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 void add(E value); | 46 void add(E value); |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * Adds [value] at the end of the list, extending the length by | 49 * Adds [value] at the end of the list, extending the length by |
| 50 * one. Throws an [UnsupportedOperationException] if the list is not | 50 * one. Throws an [UnsupportedOperationException] if the list is not |
| 51 * extendable. | 51 * extendable. |
| 52 */ | 52 */ |
| 53 void addLast(E value); | 53 void addLast(E value); |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Appends all elements of the [collection] to the end of list. | 56 * Appends all elements of the [collection] to the end of the list. |
| 57 * Extends the length of the list by the length of [collection]. | 57 * Extends the length of the list by the length of [collection]. |
| 58 * Throws an [UnsupportedOperationException] if the list is not | 58 * Throws an [UnsupportedOperationException] if the list is not |
| 59 * extendable. | 59 * extendable. |
| 60 */ | 60 */ |
| 61 void addAll(Collection<E> collection); | 61 void addAll(Collection<E> collection); |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * Sorts the list according to the order specified by the comparator. | 64 * Sorts the list according to the order specified by the comparator. |
| 65 * The order specified by the comparator must be reflexive, | 65 * The order specified by the comparator must be reflexive, |
| 66 * anti-symmetric, and transitive. | 66 * anti-symmetric, and transitive. |
| 67 * | 67 * |
| 68 * The comparator function [compare] must take two arguments [a] and [b] | 68 * The comparator function [compare] must take two arguments [a] and [b] |
| 69 * and return | 69 * and return |
| 70 * | 70 * |
| 71 * an integer strictly less than 0 if a < b, | 71 * an integer strictly less than 0 if a < b, |
| 72 * 0 if a = b, and | 72 * 0 if a = b, and |
| 73 * an integer strictly greater than 0 if a > b. | 73 * an integer strictly greater than 0 if a > b. |
| 74 */ | 74 */ |
| 75 void sort(int compare(E a, E b)); | 75 void sort(int compare(E a, E b)); |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Returns the first index of [element] in this list. Searches this | 78 * Returns the first index of [element] in the list. Searches the |
| 79 * list from index [start] to the length of the list. Returns | 79 * list from index [start] to the length of the list. Returns |
| 80 * -1 if [element] is not found. | 80 * -1 if [element] is not found. |
| 81 */ | 81 */ |
| 82 int indexOf(E element, [int start]); | 82 int indexOf(E element, [int start]); |
| 83 | 83 |
| 84 /** | 84 /** |
| 85 * Returns the last index of [element] in this list. Searches this | 85 * Returns the last index of [element] in the list. Searches the |
| 86 * list from index [start] (inclusive) to 0. Returns -1 if | 86 * list from index [start] (inclusive) to 0. Returns -1 if |
| 87 * [element] is not found. | 87 * [element] is not found. |
| 88 */ | 88 */ |
| 89 int lastIndexOf(E element, [int start]); | 89 int lastIndexOf(E element, [int start]); |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Removes all elements in the list. The length of the list | 92 * Removes all elements in the list. The length of the list |
| 93 * becomes zero. Throws an [UnsupportedOperationException] if | 93 * becomes zero. Throws an [UnsupportedOperationException] if |
| 94 * the list is not extendable. | 94 * the list is not extendable. |
| 95 */ | 95 */ |
| 96 void clear(); | 96 void clear(); |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * Pops and returns the last element of the list. | 99 * Pops and returns the last element of the list. |
| 100 * Throws a [UnsupportedOperationException] if the length of the | 100 * Throws a [UnsupportedOperationException] if the length of the |
| 101 * list cannot be changed. | 101 * list cannot be changed. |
| 102 */ | 102 */ |
| 103 E removeLast(); | 103 E removeLast(); |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * Returns the last element of the list, or throws an out of bounds | 106 * Returns the last element of the list, or throws an out of bounds |
| 107 * exception if the list is empty. | 107 * exception if the list is empty. |
| 108 */ | 108 */ |
| 109 E last(); | 109 E last(); |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Returns a sub list copy of this list, from [start] to | 112 * Returns a sub list copy of the list, from [start] to |
|
Bob Nystrom
2012/05/16 16:22:37
"sub" isn't a word (or, at least, not in this cont
Bill Hesse
2012/05/21 10:26:01
Done.
| |
| 113 * [:start + length:]. | 113 * [:start + length - 1:] inclusive. |
| 114 * Returns an empty list if [length] is 0. | 114 * Returns an empty list if [length] is 0. |
| 115 * Throws an [IllegalArgumentException] if [length] is negative. | 115 * Throws an [IllegalArgumentException] if [length] is negative. |
| 116 * Throws an [IndexOutOfRangeException] if [start] or | 116 * Throws an [IndexOutOfRangeException] if [start] or |
| 117 * [:start + length:] are out of range. | 117 * [:start + length - 1:] are out of range. |
| 118 */ | 118 */ |
| 119 List<E> getRange(int start, int length); | 119 List<E> getRange(int start, int length); |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * Copies [length] elements of the [from] array, starting | 122 * Copies [length] elements of the [from] list, starting |
| 123 * from [startFrom], into [:this:], starting at [start]. | 123 * from [startFrom], into [:this:], starting at [start]. |
|
Bob Nystrom
2012/05/16 16:22:37
[:this:] -> this list
Bill Hesse
2012/05/21 10:26:01
Done.
| |
| 124 * If [length] is 0, this method does not do anything. | 124 * If [length] is 0, this method does not do anything. |
| 125 * Throws an [IllegalArgumentException] if [length] is negative. | 125 * Throws an [IllegalArgumentException] if [length] is negative. |
| 126 * Throws an [IndexOutOfRangeException] if [start] or | 126 * Throws an [IndexOutOfRangeException] if [start] or |
| 127 * [:start + length:] are out of range for [:this:], or if | 127 * [:start + length - 1:] are out of range for [:this:], or if |
| 128 * [startFrom] is out of range for [from]. | 128 * [startFrom] or [:startFrom + length - 1:] are out of range for [from]. |
| 129 */ | 129 */ |
| 130 void setRange(int start, int length, List<E> from, [int startFrom]); | 130 void setRange(int start, int length, List<E> from, [int startFrom]); |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * Removes the range in the list starting from [start] to | 133 * Removes from the list the range from [start] to |
|
Bob Nystrom
2012/05/16 16:22:37
"Removes [length] elements from this list, beginni
Bill Hesse
2012/05/21 10:26:01
Done.
| |
| 134 * [:start + length:]. | 134 * [:start + length - 1:], inclusive. |
| 135 * Throws an [UnsupportedOperationException] if the list is | 135 * Throws an [UnsupportedOperationException] if the list is |
| 136 * not extendable. | 136 * not extendable. |
| 137 * If [length] is 0, this method does not do anything. | 137 * If [length] is 0, this method does not do anything. |
| 138 * Throws an [IllegalArgumentException] if [length] is negative. | 138 * Throws an [IllegalArgumentException] if [length] is negative. |
| 139 * Throws an [IndexOutOfRangeException] if [start] or | 139 * Throws an [IndexOutOfRangeException] if [start] or |
| 140 * [:start + length:] are out of range. | 140 * [:start + length: - 1] are out of range. |
| 141 */ | 141 */ |
| 142 void removeRange(int start, int length); | 142 void removeRange(int start, int length); |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * Inserts a new range in the list, starting from [start] to | 145 * Inserts a new range into the list, starting from [start] to |
| 146 * [:start + length:]. The entries are filled with [initialValue]. | 146 * [:start + length - 1:]. The entries are filled with [initialValue]. |
| 147 * Throws an [UnsupportedOperationException] if the list is | 147 * Throws an [UnsupportedOperationException] if the list is |
| 148 * not extendable. | 148 * not extendable. |
| 149 * If [length] is 0, this method does not do anything. | 149 * If [length] is 0, this method does not do anything. |
| 150 * If [start] is the length of the array, this method inserts the | 150 * If [start] is the length of the list, this method inserts the |
| 151 * range at the end of the array. | 151 * range at the end of the list. |
| 152 * Throws an [IllegalArgumentException] if [length] is negative. | 152 * Throws an [IllegalArgumentException] if [length] is negative. |
| 153 * Throws an [IndexOutOfRangeException] if [start] or | 153 * Throws an [IndexOutOfRangeException] if [start] is negative or if |
| 154 * [:start + length:] are out of range. | 154 * [start] is greater than the length of the list. |
| 155 */ | 155 */ |
| 156 void insertRange(int start, int length, [E initialValue]); | 156 void insertRange(int start, int length, [E initialValue]); |
| 157 } | 157 } |
| OLD | NEW |