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

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

Issue 23190016: editing doc comments for List class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of dart.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * A [List] is an indexable collection with a length. 8 * An indexable collection of objects with a length.
9 * 9 *
10 * A `List` implementation can choose not to support all methods 10 * Subclasses of this class implement different kinds of lists.
11 * of the `List` interface. 11 * The most common kinds of lists are:
12 * 12 *
13 * The most common list types are: 13 * * Fixed-length list.
14 * * Fixed length list. It is an error to use operations that can change 14 * An error occurs when attempting to use operations
15 * the list's length. 15 * that can change the length of the list.
16 * * Growable list. Full implementation of the interface. 16 *
17 * * Unmodifiable list. It is an error to use operations that can change 17 * * Growable list. Full implementation of the API defined in this class.
18 * the list's length, or that can change the values of the list. 18 *
19 * * Unmodifiable list.
sethladd 2013/08/19 15:59:28 There's also http://api.dartlang.org/docs/releases
mem 2013/08/20 21:14:07 Done.
20 * An error occurs when attempting to use operations that can change
21 * the length of the list or the values of the list.
19 * If an unmodifable list is backed by another modifiable data structure, 22 * If an unmodifable list is backed by another modifiable data structure,
20 * the values read from it may still change over time. 23 * the values read from it may still change over time.
21 * 24 *
22 * Example: 25 * A List implementation might not support all methods
26 * of the List interface.
27 *
28 * Examples:
Kathy Walrath 2013/08/19 22:41:10 Add some more words here. I wasn't sure what these
mem 2013/08/20 21:14:07 Done.
23 * 29 *
24 * var fixedLengthList = new List(5); 30 * var fixedLengthList = new List(5);
25 * fixedLengthList.length = 0; // throws. 31 * fixedLengthList.length = 0; // Error.
26 * fixedLengthList.add(499); // throws 32 * fixedLengthList.add(499); // Error.
27 * fixedLengthList[0] = 87; 33 * fixedLengthList[0] = 87;
34 *
28 * var growableList = [1, 2]; 35 * var growableList = [1, 2];
29 * growableList.length = 0; 36 * growableList.length = 0;
30 * growableList.add(499); 37 * growableList.add(499);
31 * growableList[0] = 87; 38 * growableList[0] = 87;
39 *
32 * var unmodifiableList = const [1, 2]; 40 * var unmodifiableList = const [1, 2];
Kathy Walrath 2013/08/19 22:41:10 delete unmodifiableList example if you remove it f
mem 2013/08/20 21:14:07 Done.
33 * unmodifiableList.length = 0; // throws. 41 * unmodifiableList.length = 0; // Error.
34 * unmodifiableList.add(499); // throws 42 * unmodifiableList.add(499); // Error.
35 * unmodifiableList[0] = 87; // throws. 43 * unmodifiableList[0] = 87; // Error.
36 * 44 *
37 * Lists are [Iterable]. 45 * Lists are [Iterable].
38 * List iteration iterates over values in index order. 46 * Iteration occurs over values in index order.
39 * Changing the values will not affect iteration, 47 * Changing the values does not affect iteration,
40 * but changing the valid indices - 48 * but changing the valid indices—that is,
41 * that is, changing the list's length - 49 * changing the list's length—between
42 * between iteration steps 50 * iteration steps
43 * will cause a [ConcurrentModificationError]. 51 * causes a [ConcurrentModificationError].
44 * This means that only growable lists can throw [ConcurrentModificationError]. 52 * This means that only growable lists can throw [ConcurrentModificationError].
45 * If the length changes temporarily 53 * If the length changes temporarily
46 * and is restored before continuing the iteration, 54 * and is restored before continuing the iteration,
47 * the iterator will not detect it. 55 * the iterator does not detect it.
48 */ 56 */
49 abstract class List<E> implements Iterable<E> { 57 abstract class List<E> implements Iterable<E> {
50 /** 58 /**
51 * Creates a list of the given [length]. 59 * Creates a list of the given [length].
52 * 60 *
53 * The list is a fixed-length list if [length] is provided, and an empty 61 * The list is fixed-length if [length] is provided.
54 * growable list if [length] is omitted. 62 * The list has length 0 and is growable if [length] is omitted.
55 * 63 *
56 * It is an error if [length] is not a non-negative integer. 64 * An error occurs if [length] is negative.
57 */ 65 */
58 external factory List([int length]); 66 external factory List([int length]);
59 67
60 /** 68 /**
61 * Creates a fixed-length list of the given [length] where each entry 69 * Creates a fixed-length list of the given [length]
62 * contains [fill]. 70 * and initializes the value at each position with [fill].
63 */ 71 */
64 external factory List.filled(int length, E fill); 72 external factory List.filled(int length, E fill);
65 73
66 /** 74 /**
67 * Creates an list with the elements of [other]. 75 * Creates a list and initializes it using the contents of [other].
68 * 76 *
69 * The order in the list will be 77 * The [Iterator] of [other] provides the order of the objects.
70 * the order provided by the iterator of [other].
71 * 78 *
72 * The returned list is growable if [growable] is true, otherwise it's 79 * This constructor returns a growable list if [growable] is true,
Kathy Walrath 2013/08/19 22:41:10 true, -> true;
mem 2013/08/20 21:14:07 Done.
73 * a fixed length list. 80 * otherwise, it returns a fixed-length list.
74 */ 81 */
75 factory List.from(Iterable other, { bool growable: true }) { 82 factory List.from(Iterable other, { bool growable: true }) {
76 List<E> list = new List<E>(); 83 List<E> list = new List<E>();
77 for (E e in other) { 84 for (E e in other) {
78 list.add(e); 85 list.add(e);
79 } 86 }
80 if (growable) return list; 87 if (growable) return list;
81 int length = list.length; 88 int length = list.length;
82 List<E> fixedList = new List<E>(length); 89 List<E> fixedList = new List<E>(length);
83 for (int i = 0; i < length; i++) { 90 for (int i = 0; i < length; i++) {
84 fixedList[i] = list[i]; 91 fixedList[i] = list[i];
85 } 92 }
86 return fixedList; 93 return fixedList;
87 } 94 }
88 95
89 /** 96 /**
90 * Generate a `List` of values. 97 * Generates a list of values.
91 * 98 *
92 * Creates a list with [length] positions 99 * Creates a list with _length_ positions
Kathy Walrath 2013/08/19 22:41:10 shouldn't _length_ be [length]? We should figure o
mem 2013/08/20 21:14:07 The word length in this context is overloaded. Her
93 * and fills them by values created by calling [generator] 100 * and fills it with values created by calling [generator]
94 * for each index in the range `0` .. `[length] - 1` 101 * for each index in the range `0` .. `length - 1`
95 * in increasing order. 102 * in increasing order.
96 * 103 *
97 * The created list's length is fixed unless [growable] is true. 104 * The length of the created list is fixed unless [growable] is true.
Kathy Walrath 2013/08/19 22:41:10 Use "fixed-length" here?
mem 2013/08/20 21:14:07 Done.
98 */ 105 */
99 factory List.generate(int length, E generator(int index), 106 factory List.generate(int length, E generator(int index),
100 { bool growable: true }) { 107 { bool growable: true }) {
101 List<E> result; 108 List<E> result;
102 if (growable) { 109 if (growable) {
103 result = <E>[]..length = length; 110 result = <E>[]..length = length;
104 } else { 111 } else {
105 result = new List<E>(length); 112 result = new List<E>(length);
106 } 113 }
107 for (int i = 0; i < length; i++) { 114 for (int i = 0; i < length; i++) {
108 result[i] = generator(i); 115 result[i] = generator(i);
109 } 116 }
110 return result; 117 return result;
111 } 118 }
112 119
113 /** 120 /**
114 * Returns the element at the given [index] in the list or throws 121 * Returns the object at the given [index] in the list
115 * an [RangeError] if [index] is out of bounds. 122 * or throws a [RangeError] if [index] is out of bounds.
116 */ 123 */
117 E operator [](int index); 124 E operator [](int index);
118 125
119 /** 126 /**
120 * Sets the entry at the given [index] in the list to [value]. 127 * Sets the value at the given [index] in the list to [value]
121 * 128 * or throws a [RangeError] if [index] is out of bounds.
122 * Throws an [RangeError] if [index] is out of bounds.
123 */ 129 */
124 void operator []=(int index, E value); 130 void operator []=(int index, E value);
125 131
126 /** 132 /**
127 * Returns the number of elements in the list. 133 * Returns the number of objects in the list.
128 * 134 *
129 * The valid indices for a list are 0 through `length - 1`. 135 * The valid indices for a list are 0 through `length - 1`.
130 */ 136 */
131 int get length; 137 int get length;
132 138
133 /** 139 /**
134 * Changes the length of the list. If [newLength] is greater than 140 * Changes the length of the list. If [newLength] is greater than
Kathy Walrath 2013/08/19 22:41:10 add blank line before "If"
mem 2013/08/20 21:14:07 Done.
135 * the current [length], entries are initialized to [:null:]. 141 * the current [length], entries are initialized to [:null:].
136 * 142 *
137 * Throws an [UnsupportedError] if the list is not extendable. 143 * Throws an [UnsupportedError] if the list is not growable.
138 */ 144 */
139 void set length(int newLength); 145 void set length(int newLength);
140 146
141 /** 147 /**
142 * Adds [value] at the end of the list, extending the length by 148 * Adds [value] to the end of the list,
143 * one. 149 * extending the length by one.
144 * 150 *
145 * Throws an [UnsupportedError] if the list is not extendable. 151 * Throws an [UnsupportedError] if the list is not growable.
Kathy Walrath 2013/08/19 22:41:10 the list is not growable -> this is a fixed-length
mem 2013/08/20 21:14:07 Done.
146 */ 152 */
147 void add(E value); 153 void add(E value);
148 154
149 /** 155 /**
150 * Appends all elements of the [iterable] to the end of this list. 156 * Appends all objects of [iterable] to the end of this list.
151 * 157 *
152 * Extends the length of the list by the number of elements in [iterable]. 158 * Extends the length of the list by the number of objects in [iterable].
153 * Throws an [UnsupportedError] if this list is not extensible. 159 * Throws an [UnsupportedError] if this list is not growable.
Kathy Walrath 2013/08/19 22:41:10 see comment for add()
mem 2013/08/20 21:14:07 Done.
154 */ 160 */
155 void addAll(Iterable<E> iterable); 161 void addAll(Iterable<E> iterable);
156 162
157 /** 163 /**
158 * Returns an [Iterable] of the elements of this [List] in reverse order. 164 * Returns an [Iterable] of the objects in this List in reverse order.
159 */ 165 */
160 Iterable<E> get reversed; 166 Iterable<E> get reversed;
161 167
162 /** 168 /**
163 * Sorts the list according to the order specified by the [compare] function. 169 * Sorts the list according to the order specified by the [compare] function.
164 * 170 *
165 * The [compare] function must act as a [Comparator]. 171 * The [compare] function must act as a [Comparator].
166 * 172 *
167 * The default [List] implementations use [Comparable.compare] if 173 * The default List implementations use [Comparable.compare] if
168 * [compare] is omitted. 174 * [compare] is omitted.
169 */ 175 */
170 void sort([int compare(E a, E b)]); 176 void sort([int compare(E a, E b)]);
171 177
172 /** 178 /**
173 * Returns the first index of [element] in the list. 179 * Returns the first index of [element] in the list.
174 * 180 *
175 * Searches the list from index [start] to the length of the list. 181 * Searches the list from index [start] to the length of the list.
176 * The first time an element [:e:] is encountered so that [:e == element:], 182 * The first time an object [:o:] is encountered so that [:o == element:],
177 * the index of [:e:] is returned. 183 * the index of [:o:] is returned.
178 * Returns -1 if [element] is not found. 184 * Returns -1 if [element] is not found.
179 */ 185 */
180 int indexOf(E element, [int start = 0]); 186 int indexOf(E element, [int start = 0]);
181 187
182 /** 188 /**
183 * Returns the last index of [element] in the list. 189 * Returns the last index of [element] in the list.
184 * 190 *
185 * Searches the list backwards from index [start] (inclusive) to 0. 191 * Searches the list backwards from index [start] to 0.
186 * 192 *
187 * The first time an element [:e:] is encountered so that [:e == element:], 193 * The first time an object [:o:] is encountered so that [:o == element:],
188 * the index of [:e:] is returned. 194 * the index of [:o:] is returned.
189 * 195 *
190 * If start is not provided, it defaults to [:this.length - 1:]. 196 * If [start] is not provided, it defaults to [:this.length - 1:].
191 * 197 *
192 * Returns -1 if [element] is not found. 198 * Returns -1 if [element] is not found.
193 */ 199 */
194 int lastIndexOf(E element, [int start]); 200 int lastIndexOf(E element, [int start]);
195 201
196 /** 202 /**
197 * Removes all elements in the list. 203 * Removes all objects from the list.
198 *
199 * The length of the list becomes zero. 204 * The length of the list becomes zero.
200 * 205 *
201 * Throws an [UnsupportedError], and retains all elements, if the 206 * Throws an [UnsupportedError], and retains all objects, if the
202 * length of the list cannot be changed. 207 * length of the list cannot be changed.
Kathy Walrath 2013/08/19 22:41:10 the length... -> this is a fixed-length list
mem 2013/08/20 21:14:07 Done.
203 */ 208 */
204 void clear(); 209 void clear();
205 210
206 /** 211 /**
207 * Inserts the element at position [index] in the list. 212 * Inserts the object at position [index] in the list.
208 * 213 *
209 * This increases the length of the list by one and shifts all elements 214 * This increases the length of the list by one and shifts all objects
210 * at or after the index towards the end of the list. 215 * at or after the index towards the end of the list.
211 * 216 *
212 * It is an error if the [index] does not point inside the list or at the 217 * An error occurs if the [index] is less than 0 or greater than length.
Kathy Walrath 2013/08/19 22:41:10 isn't there an UnsupportedException if this is a f
mem 2013/08/20 21:14:07 Why yes there is. UnsupportedError. On 2013/08/19
213 * position after the last element.
214 */ 218 */
215 void insert(int index, E element); 219 void insert(int index, E element);
216 220
217 /** 221 /**
218 * Inserts all elements of [iterable] at position [index] in the list. 222 * Inserts all objects of [iterable] at position [index] in the list.
219 * 223 *
220 * This increases the length of the list by the length of [iterable] and 224 * This increases the length of the list by the length of [iterable] and
221 * shifts all later elements towards the end of the list. 225 * shifts all later objects towards the end of the list.
222 * 226 *
223 * It is an error if the [index] does not point inside the list or at the 227 * An error occurs if the [index] is less than 0 or greater than length.
Kathy Walrath 2013/08/19 22:41:10 isn't there an UnsupportedException if this is a f
mem 2013/08/20 21:14:07 Done.
224 * position after the last element.
225 */ 228 */
226 void insertAll(int index, Iterable<E> iterable); 229 void insertAll(int index, Iterable<E> iterable);
227 230
228 /** 231 /**
229 * Overwrites elements of `this` with the elemenst of [iterable] starting 232 * Overwrites objects of `this` with the objects of [iterable] starting
Kathy Walrath 2013/08/19 22:41:10 starting -> , starting
mem 2013/08/20 21:14:07 Done.
230 * at position [index] in the list. 233 * at position [index] in the list.
231 * 234 *
232 * This operation does not increase the length of `this`. 235 * This operation does not increase the length of `this`.
233 * 236 *
234 * It is an error if the [index] does not point inside the list or at the 237 * An error occurs if the [index] is less than 0 or greater than length.
Kathy Walrath 2013/08/19 22:41:10 It seems like both errors could go in a single par
mem 2013/08/20 21:14:07 Done.
235 * position after the last element.
236 * 238 *
237 * It is an error if the [iterable] is longer than [length] - [index]. 239 * An error occurs if the [iterable] is longer than [length] - [index].
238 */ 240 */
239 void setAll(int index, Iterable<E> iterable); 241 void setAll(int index, Iterable<E> iterable);
240 242
241 /** 243 /**
242 * Removes [value] from the list. Returns true if [value] was 244 * Removes [value] from the list. Returns true if [value] was
Kathy Walrath 2013/08/19 22:41:10 convert to one-sentence first paragraph.
mem 2013/08/20 21:14:07 Done.
243 * in the list. Returns false otherwise. The method has no effect 245 * in the list. Returns false otherwise. The method has no effect
244 * if [value] value was not in the list. 246 * if [value] was not in the list.
245 */ 247 */
246 bool remove(Object value); 248 bool remove(Object value);
247 249
248 /** 250 /**
249 * Removes the element at position [index] from the list. 251 * Removes the object at position [index] from the list.
250 * 252 *
251 * This reduces the length of `this` by one and moves all later elements 253 * This reduces the length of `this` by one and moves all later objects
Kathy Walrath 2013/08/19 22:41:10 This -> This method
mem 2013/08/20 21:14:08 Done.
252 * down by one position. 254 * down by one position.
253 * 255 *
254 * Returns the removed element. 256 * Returns the removed object.
255 * 257 *
256 * Throws an [ArgumentError] if [index] is not an [int]. 258 * Throws an [ArgumentError] if [index] is not an [int].
Kathy Walrath 2013/08/19 22:41:10 It seems excessive to have a paragraph per "Throws
mem 2013/08/20 21:14:08 Done.
257 * 259 *
258 * Throws an [RangeError] if the [index] does not point inside 260 * Throws a [RangeError] if the [index] is out of range for this list.
259 * the list.
260 * 261 *
261 * Throws an [UnsupportedError], and doesn't remove the element, 262 * Throws an [UnsupportedError], and doesn't remove the object,
262 * if the length of `this` cannot be changed. 263 * if the length of `this` cannot be changed.
Kathy Walrath 2013/08/19 22:41:10 See the "fixed-length" comment for removeLast().
mem 2013/08/20 21:14:08 Done.
263 */ 264 */
264 E removeAt(int index); 265 E removeAt(int index);
265 266
266 /** 267 /**
267 * Pops and returns the last element of the list. 268 * Pops and returns the last object of the list.
Kathy Walrath 2013/08/19 22:41:10 add blank line after this one
mem 2013/08/20 21:14:08 Done.
268 * Throws a [UnsupportedError] if the length of the 269 * Throws a [UnsupportedError] if the length of the
Kathy Walrath 2013/08/19 22:41:10 a -> an how about "if the length..." -> "this is
mem 2013/08/20 21:14:08 Done.
269 * list cannot be changed. 270 * list cannot be changed.
270 */ 271 */
271 E removeLast(); 272 E removeLast();
272 273
273 /** 274 /**
274 * Removes all elements of this list that satisfy [test]. 275 * Removes all objects from this list that satisfy [test].
275 * 276 *
276 * An elements [:e:] satisfies [test] if [:test(e):] is true. 277 * An object [:o:] satisfies [test] if [:test(o):] is true.
Kathy Walrath 2013/08/19 22:41:10 Probably throws an UnsupportedError if this is a f
mem 2013/08/20 21:14:08 Done.
277 */ 278 */
278 void removeWhere(bool test(E element)); 279 void removeWhere(bool test(E element));
279 280
280 /** 281 /**
281 * Removes all elements of this list that fail to satisfy [test]. 282 * Removes all objects from this list that fail to satisfy [test].
282 * 283 *
283 * An elements [:e:] satisfies [test] if [:test(e):] is true. 284 * An object [:o:] satisfies [test] if [:test(o):] is true.
Kathy Walrath 2013/08/19 22:41:10 Probably throws an UnsupportedError if this is a f
mem 2013/08/20 21:14:08 Done.
284 */ 285 */
285 void retainWhere(bool test(E element)); 286 void retainWhere(bool test(E element));
286 287
287 /** 288 /**
288 * Returns a new list containing the elements from [start] to [end]. 289 * Returns a new list containing the objects
289 * 290 * from [start] inclusive to [end] exclusive.
290 * The result contains elements of this list with indices greater than or
291 * equal to [start] and less than [end].
292 * 291 *
293 * If [end] is omitted, the [length] of `this` is used. 292 * If [end] is omitted, the [length] of `this` is used.
294 * 293 *
295 * It is an error if [start] is outside the range `0` .. `[length]` or if 294 * An error occurs if [start] is outside the range `0` .. `length` or if
296 * [end] is outside the range `[start]` .. `[length]`. 295 * [end] is outside the range `start` .. `length`.
297 */ 296 */
298 List<E> sublist(int start, [int end]); 297 List<E> sublist(int start, [int end]);
299 298
300 /** 299 /**
301 * Returns an [Iterable] that iterates over the elements in the range 300 * Returns an [Iterable] that iterates over the objects in the range
302 * [start] to [end] exclusive. The result of this function 301 * [start] inclusive to [end] exclusive. The result of this function
Kathy Walrath 2013/08/19 22:41:10 Add blank line before "The result"
mem 2013/08/20 21:14:08 Done.
303 * is backed by `this`. 302 * is backed by `this`.
Kathy Walrath 2013/08/19 22:41:10 I don't know what this means.
mem 2013/08/20 21:14:08 Done.
304 * 303 *
305 * It is an error if [end] is before [start]. 304 * An error occurs if [end] is before [start].
306 * 305 *
307 * It is an error if the [start] and [end] are not valid ranges at the time 306 * An error occurs if the [start] and [end] are not valid ranges at the time
308 * of the call to this method. The returned [Iterable] behaves similar to 307 * of the call to this method. The returned [Iterable] behaves similar to
Kathy Walrath 2013/08/19 22:41:10 similar to -> similarly to OR -> like
mem 2013/08/20 21:14:08 Done.
309 * `skip(start).take(end - start)`. That is, it will not throw exceptions 308 * `skip(start).take(end - start)`. That is, it will not throw exceptions
Kathy Walrath 2013/08/19 22:41:10 will -> does
mem 2013/08/20 21:14:08 Done.
310 * if `this` changes size. 309 * if `this` changes size.
311 * 310 *
312 * Example: 311 * Example:
313 * 312 *
314 * var list = [1, 2, 3, 4, 5]; 313 * var list = [1, 2, 3, 4, 5];
315 * var range = list.getRange(1, 4); 314 * var range = list.getRange(1, 4);
316 * print(range.join(', ')); // => 2, 3, 4 315 * print(range.join(', ')); // => 2, 3, 4
317 * list.length = 3; 316 * list.length = 3;
318 * print(range.join(', ')); // => 2, 3 317 * print(range.join(', ')); // => 2, 3
319 */ 318 */
320 Iterable<E> getRange(int start, int end); 319 Iterable<E> getRange(int start, int end);
321 320
322 /** 321 /**
323 * Copies the elements of [iterable], skipping the [skipCount] first elements, 322 * Copies the objects of [iterable], skipping [skipCount] objects first,
324 * into the range [start] to [end] exclusive of `this`. 323 * into the range [start] inclusive to [end] exclusive of `this`.
325 * 324 *
326 * If [start] equals [end] and [start]..[end] represents a legal range, this 325 * If [start] equals [end] and [start]..[end] represents a legal range, this
327 * method has no effect. 326 * method has no effect.
328 * 327 *
329 * It is an error if [start]..[end] is not a valid range pointing into the 328 * An error occurs if [start]..[end] is not a valid range for `this`.
330 * `this`.
331 * 329 *
332 * It is an error if the [iterable] does not have enough elements after 330 * An error occurs if the [iterable] does not have enough objects after
333 * skipping [skipCount] elements. 331 * skipping [skipCount] objects.
334 * 332 *
335 * Example: 333 * Example:
336 * 334 *
337 * var list = [1, 2, 3, 4]; 335 * var list = [1, 2, 3, 4];
338 * var list2 = [5, 6, 7, 8, 9]; 336 * var list2 = [5, 6, 7, 8, 9];
339 * list.setRange(1, 3, list2, 3); 337 * list.setRange(1, 3, list2, 3);
340 * print(list); // => [1, 8, 9, 4] 338 * print(list); // => [1, 8, 9, 4]
341 */ 339 */
342 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]); 340 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]);
343 341
344 /** 342 /**
345 * Removes the elements in the range [start] to [end] exclusive. 343 * Removes the objects in the range [start] inclusive to [end] exclusive.
346 * 344 *
347 * It is an error if [start]..[end] is not a valid range pointing into the 345 * An error occurs if [start]..[end] is not a valid range for `this`.
Kathy Walrath 2013/08/19 22:41:10 isn't there an UnsupportedException if this is a f
mem 2013/08/20 21:14:08 Done.
348 * `this`.
349 */ 346 */
350 void removeRange(int start, int end); 347 void removeRange(int start, int end);
351 348
352 /** 349 /**
353 * Sets the elements in the range [start] to [end] exclusive to the given 350 * Sets the objects in the range [start] inclusive to [end] exclusive
354 * [fillValue]. 351 * to the given [fillValue].
355 * 352 *
356 * It is an error if [start]..[end] is not a valid range pointing into the 353 * An error occurs if [start]..[end] is not a valid range for `this`.
357 * `this`.
358 */ 354 */
359 void fillRange(int start, int end, [E fillValue]); 355 void fillRange(int start, int end, [E fillValue]);
360 356
361 /** 357 /**
362 * Removes the elements in the range [start] to [end] exclusive and replaces 358 * Removes the objects in the range [start] inclusive to [end] exclusive
363 * them with the contents of the [iterable]. 359 * and replaces them with the contents of the [iterable].
364 * 360 *
365 * It is an error if [start]..[end] is not a valid range pointing into the 361 * An error occurs if [start]..[end] is not a valid range for `this`.
366 * `this`.
367 * 362 *
368 * Example: 363 * Example:
369 * 364 *
370 * var list = [1, 2, 3, 4, 5]; 365 * var list = [1, 2, 3, 4, 5];
371 * list.replaceRange(1, 3, [6, 7, 8, 9]); 366 * list.replaceRange(1, 3, [6, 7, 8, 9]);
372 * print(list); // [1, 6, 7, 8, 9, 4, 5] 367 * print(list); // [1, 6, 7, 8, 9, 4, 5]
373 */ 368 */
374 void replaceRange(int start, int end, Iterable<E> iterable); 369 void replaceRange(int start, int end, Iterable<E> iterable);
375 370
376 /** 371 /**
377 * Returns an unmodifiable [Map] view of `this`. 372 * Returns an unmodifiable [Map] view of `this`.
378 * 373 *
379 * It has the indices of this list as keys, and the corresponding elements 374 * The map uses the indices of this list as keys and the corresponding objects
380 * as values. The [Map.keys] [Iterable] will iterate the indices of this list 375 * as values. The `Map.keys` [Iterable] iterates the indices of this list
381 * in numerical order. 376 * in numerical order.
382 */ 377 */
383 Map<int, E> asMap(); 378 Map<int, E> asMap();
384 } 379 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698