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 ListImplementation<E> { | 9 interface List<E> extends Collection<E> default ListImplementation<E> { |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 * length of the list cannot be changed. | 94 * length of the list cannot be changed. |
95 */ | 95 */ |
96 void clear(); | 96 void clear(); |
97 | 97 |
98 /** | 98 /** |
99 * Removes the element at position[index] from the list. | 99 * Removes the element at position[index] from the list. |
100 * | 100 * |
101 * This reduces the length of the list by one and moves all later elements | 101 * This reduces the length of the list by one and moves all later elements |
102 * down by one position. | 102 * down by one position. |
103 * Returns the removed element. | 103 * Returns the removed element. |
104 * Throws an [IllegalArgumentException] if [index] is not an [int]. | 104 * Throws an [ArgumentError] if [index] is not an [int]. |
105 * Throws an [IndexOutOfRangeException] if the [index] does not point inside | 105 * Throws an [IndexOutOfRangeException] if the [index] does not point inside |
106 * the list. | 106 * the list. |
107 * Throws an [UnsupportedOperationException], and doesn't remove the element, | 107 * Throws an [UnsupportedOperationException], and doesn't remove the element, |
108 * if the length of the list cannot be changed. | 108 * if the length of the list cannot be changed. |
109 */ | 109 */ |
110 E removeAt(int index); | 110 E removeAt(int index); |
111 | 111 |
112 /** | 112 /** |
113 * Pops and returns the last element of the list. | 113 * Pops and returns the last element of the list. |
114 * Throws a [UnsupportedOperationException] if the length of the | 114 * Throws a [UnsupportedOperationException] if the length of the |
115 * list cannot be changed. | 115 * list cannot be changed. |
116 */ | 116 */ |
117 E removeLast(); | 117 E removeLast(); |
118 | 118 |
119 /** | 119 /** |
120 * Returns the last element of the list, or throws an out of bounds | 120 * Returns the last element of the list, or throws an out of bounds |
121 * exception if the list is empty. | 121 * exception if the list is empty. |
122 */ | 122 */ |
123 E last(); | 123 E last(); |
124 | 124 |
125 /** | 125 /** |
126 * Returns a new list containing [length] elements from the list, | 126 * Returns a new list containing [length] elements from the list, |
127 * starting at [start]. | 127 * starting at [start]. |
128 * Returns an empty list if [length] is 0. | 128 * Returns an empty list if [length] is 0. |
129 * Throws an [IllegalArgumentException] if [length] is negative. | 129 * Throws an [ArgumentError] if [length] is negative. |
130 * Throws an [IndexOutOfRangeException] if [start] or | 130 * Throws an [IndexOutOfRangeException] if [start] or |
131 * [:start + length - 1:] are out of range. | 131 * [:start + length - 1:] are out of range. |
132 */ | 132 */ |
133 List<E> getRange(int start, int length); | 133 List<E> getRange(int start, int length); |
134 | 134 |
135 /** | 135 /** |
136 * Copies [length] elements of [from], starting | 136 * Copies [length] elements of [from], starting |
137 * at [startFrom], into the list, starting at [start]. | 137 * at [startFrom], into the list, starting at [start]. |
138 * If [length] is 0, this method does not do anything. | 138 * If [length] is 0, this method does not do anything. |
139 * Throws an [IllegalArgumentException] if [length] is negative. | 139 * Throws an [ArgumentError] if [length] is negative. |
140 * Throws an [IndexOutOfRangeException] if [start] or | 140 * Throws an [IndexOutOfRangeException] if [start] or |
141 * [:start + length - 1:] are out of range for [:this:], or if | 141 * [:start + length - 1:] are out of range for [:this:], or if |
142 * [startFrom] or [:startFrom + length - 1:] are out of range for [from]. | 142 * [startFrom] or [:startFrom + length - 1:] are out of range for [from]. |
143 */ | 143 */ |
144 void setRange(int start, int length, List<E> from, [int startFrom]); | 144 void setRange(int start, int length, List<E> from, [int startFrom]); |
145 | 145 |
146 /** | 146 /** |
147 * Removes [length] elements from the list, beginning at [start]. | 147 * Removes [length] elements from the list, beginning at [start]. |
148 * Throws an [UnsupportedOperationException] if the list is | 148 * Throws an [UnsupportedOperationException] if the list is |
149 * not extendable. | 149 * not extendable. |
150 * If [length] is 0, this method does not do anything. | 150 * If [length] is 0, this method does not do anything. |
151 * Throws an [IllegalArgumentException] if [length] is negative. | 151 * Throws an [ArgumentError] if [length] is negative. |
152 * Throws an [IndexOutOfRangeException] if [start] or | 152 * Throws an [IndexOutOfRangeException] if [start] or |
153 * [:start + length: - 1] are out of range. | 153 * [:start + length: - 1] are out of range. |
154 */ | 154 */ |
155 void removeRange(int start, int length); | 155 void removeRange(int start, int length); |
156 | 156 |
157 /** | 157 /** |
158 * Inserts a new range into the list, starting from [start] to | 158 * Inserts a new range into the list, starting from [start] to |
159 * [:start + length - 1:]. The entries are filled with [initialValue]. | 159 * [:start + length - 1:]. The entries are filled with [initialValue]. |
160 * Throws an [UnsupportedOperationException] if the list is | 160 * Throws an [UnsupportedOperationException] if the list is |
161 * not extendable. | 161 * not extendable. |
162 * If [length] is 0, this method does not do anything. | 162 * If [length] is 0, this method does not do anything. |
163 * If [start] is the length of the list, this method inserts the | 163 * If [start] is the length of the list, this method inserts the |
164 * range at the end of the list. | 164 * range at the end of the list. |
165 * Throws an [IllegalArgumentException] if [length] is negative. | 165 * Throws an [ArgumentError] if [length] is negative. |
166 * Throws an [IndexOutOfRangeException] if [start] is negative or if | 166 * Throws an [IndexOutOfRangeException] if [start] is negative or if |
167 * [start] is greater than the length of the list. | 167 * [start] is greater than the length of the list. |
168 */ | 168 */ |
169 void insertRange(int start, int length, [E initialValue]); | 169 void insertRange(int start, int length, [E initialValue]); |
170 } | 170 } |
OLD | NEW |