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

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

Issue 23908003: Added examples to list.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 * An indexable collection of objects with a length. 8 * An indexable collection of objects with a length.
9 * 9 *
10 * Subclasses of this class implement different kinds of lists. 10 * Subclasses of this class implement different kinds of lists.
11 * The most common kinds of lists are: 11 * The most common kinds of lists are:
12 * 12 *
13 * * Fixed-length list. 13 * * Fixed-length list.
14 * An error occurs when attempting to use operations 14 * An error occurs when attempting to use operations
15 * that can change the length of the list. 15 * that can change the length of the list.
16 * 16 *
17 * * Growable list. Full implementation of the API defined in this class. 17 * * Growable list. Full implementation of the API defined in this class.
18 * 18 *
19 * The following code illustrates that some List implementations support 19 * The following code illustrates that some List implementations support
20 * only a subset of the API. 20 * only a subset of the API.
21 * 21 *
22 * var fixedLengthList = new List(5); 22 List<int> fixedLengthList = new List(5);
23 * fixedLengthList.length = 0; // Error. 23 fixedLengthList.length = 0; // Error.
24 * fixedLengthList.add(499); // Error. 24 fixedLengthList.add(499); // Error.
25 * fixedLengthList[0] = 87; 25 fixedLengthList[0] = 87;
26
27 List<int> growableList = [1, 2];
28 growableList.length = 0;
29 growableList.add(499);
30 growableList[0] = 87;
26 * 31 *
27 * var growableList = [1, 2]; 32 * Lists are [Iterable]. Iteration occurs over values in index order. Changing
28 * growableList.length = 0; 33 * the values does not affect iteration, but changing the valid
29 * growableList.add(499); 34 * indices&mdash;that is, changing the list's length&mdash;between iteration
30 * growableList[0] = 87; 35 * steps causes a [ConcurrentModificationError]. This means that only growable
31 * 36 * lists can throw ConcurrentModificationError. If the length changes
32 * Lists are [Iterable]. 37 * temporarily and is restored before continuing the iteration, the iterator
33 * Iteration occurs over values in index order. 38 * does not detect it.
34 * Changing the values does not affect iteration,
35 * but changing the valid indices&mdash;that is,
36 * changing the list's length&mdash;between
37 * iteration steps
38 * causes a [ConcurrentModificationError].
39 * This means that only growable lists can throw ConcurrentModificationError.
40 * If the length changes temporarily
41 * and is restored before continuing the iteration,
42 * the iterator does not detect it.
43 */ 39 */
44 abstract class List<E> implements Iterable<E> { 40 abstract class List<E> implements Iterable<E> {
45 /** 41 /**
46 * Creates a list of the given _length_. 42 * Creates a list of the given _length_.
47 * 43 *
48 * The created list is fixed-length if _length_ is provided. 44 * The created list is fixed-length if _length_ is provided.
45 *
46 * List fixedLengthList = new List(3);
47 * fixedLengthList.length; // 3
48 fixedLengthList.length = 1; // Error
mem 2013/09/06 16:28:16 Error. With a period. We're using this convention
shailentuli 2013/09/23 11:48:54 Done.
49 *
50 *
49 * The list has length 0 and is growable if _length_ is omitted. 51 * The list has length 0 and is growable if _length_ is omitted.
50 * 52 *
53 * List growableList = new List();
54 * growableList.length; // 0;
55 * growableList.length = 3;
56 *
51 * An error occurs if _length_ is negative. 57 * An error occurs if _length_ is negative.
52 */ 58 */
53 external factory List([int length]); 59 external factory List([int length]);
54 60
55 /** 61 /**
56 * Creates a fixed-length list of the given _length_ 62 * Creates a fixed-length list of the given _length_
57 * and initializes the value at each position with [fill]. 63 * and initializes the value at each position with [fill]:
64 *
65 * new List<int>.filled(3, 0); // [0, 0, 0]
58 */ 66 */
59 external factory List.filled(int length, E fill); 67 external factory List.filled(int length, E fill);
60 68
61 /** 69 /**
62 * Creates a list and initializes it using the contents of [other]. 70 * Creates a list and initializes it using the contents of [other].
63 * 71 *
64 * The [Iterator] of [other] provides the order of the objects. 72 * The [Iterator] of [other] provides the order of the objects.
65 * 73 *
66 * This constructor returns a growable list if [growable] is true; 74 * This constructor returns a growable list if [growable] is true;
67 * otherwise, it returns a fixed-length list. 75 * otherwise, it returns a fixed-length list.
mem 2013/09/06 16:28:16 no example? ...There are other methods and things
68 */ 76 */
69 factory List.from(Iterable other, { bool growable: true }) { 77 factory List.from(Iterable other, { bool growable: true }) {
70 List<E> list = new List<E>(); 78 List<E> list = new List<E>();
71 for (E e in other) { 79 for (E e in other) {
72 list.add(e); 80 list.add(e);
73 } 81 }
74 if (growable) return list; 82 if (growable) return list;
75 int length = list.length; 83 int length = list.length;
76 List<E> fixedList = new List<E>(length); 84 List<E> fixedList = new List<E>(length);
77 for (int i = 0; i < length; i++) { 85 for (int i = 0; i < length; i++) {
78 fixedList[i] = list[i]; 86 fixedList[i] = list[i];
79 } 87 }
80 return fixedList; 88 return fixedList;
81 } 89 }
82 90
83 /** 91 /**
84 * Generates a list of values. 92 * Generates a list of values.
85 * 93 *
86 * Creates a list with _length_ positions 94 * Creates a list with _length_ positions
87 * and fills it with values created by calling [generator] 95 * and fills it with values created by calling [generator]
88 * for each index in the range `0` .. `length - 1` 96 * for each index in the range `0` .. `length - 1`
89 * in increasing order. 97 * in increasing order.
90 * 98 *
99 * new List<int>.generate(3, (int index) => index * index); // [0, 1, 4]
100 *
91 * The created list is fixed-length unless [growable] is true. 101 * The created list is fixed-length unless [growable] is true.
92 */ 102 */
93 factory List.generate(int length, E generator(int index), 103 factory List.generate(int length, E generator(int index),
94 { bool growable: true }) { 104 { bool growable: true }) {
95 List<E> result; 105 List<E> result;
96 if (growable) { 106 if (growable) {
97 result = <E>[]..length = length; 107 result = <E>[]..length = length;
98 } else { 108 } else {
99 result = new List<E>(length); 109 result = new List<E>(length);
100 } 110 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 161
152 /** 162 /**
153 * Returns an [Iterable] of the objects in this list in reverse order. 163 * Returns an [Iterable] of the objects in this list in reverse order.
154 */ 164 */
155 Iterable<E> get reversed; 165 Iterable<E> get reversed;
156 166
157 /** 167 /**
158 * Sorts this list according to the order specified by the [compare] function. 168 * Sorts this list according to the order specified by the [compare] function.
159 * 169 *
160 * The [compare] function must act as a [Comparator]. 170 * The [compare] function must act as a [Comparator].
171
172 * List<String> numbers = ['one', 'two', 'three', 'four'];
173 * // Sort from shortest to longest.
174 * numbers.sort((x, y) => x.length.compareTo(y.length));
mem 2013/09/06 16:28:16 it's a pity sort() doesn't return the list.
shailentuli 2013/09/23 11:48:54 Yup, it's an in-place sort.
175 * numbers.join(', '); // 'one, two, four, three'
161 * 176 *
162 * The default List implementations use [Comparable.compare] if 177 * The default List implementations use [Comparable.compare] if
163 * [compare] is omitted. 178 * [compare] is omitted.
179 *
180 * List<int> nums = [13, 2, -11];
181 * nums.sort();
mem 2013/09/06 16:28:16 add comment-> nums.sort(); // [ -11, 2, 13]
shailentuli 2013/09/23 11:48:54 This goes against our convention that the // signi
182 nums.join(', '); // '-11, 2, 13'
164 */ 183 */
165 void sort([int compare(E a, E b)]); 184 void sort([int compare(E a, E b)]);
166 185
167 /** 186 /**
168 * Returns the first index of [element] in this list. 187 * Returns the first index of [element] in this list.
mem 2013/09/06 16:28:16 Technically... it Returns the index of the first
169 * 188 *
170 * Searches the list from index [start] to the length of the list. 189 * Searches the list from index [start] to the length of the list.
mem 2013/09/06 16:28:16 length -> end
171 * The first time an object [:o:] is encountered so that [:o == element:], 190 * The first time an object [:o:] is encountered so that [:o == element:],
172 * the index of [:o:] is returned. 191 * the index of [:o:] is returned.
192 *
193 * List<String> notes = ['do', 're', 'mi', 're'];
194 * notes.indexOf('re'); // 1
195 * notes.indexOf('re', 1); // 1
mem 2013/09/06 16:28:16 better if start is 2 and it finds the second one a
shailentuli 2013/09/23 11:48:54 Done.
196 *
173 * Returns -1 if [element] is not found. 197 * Returns -1 if [element] is not found.
198 *
199 * notes.indexOf('fa'); // -1
174 */ 200 */
175 int indexOf(E element, [int start = 0]); 201 int indexOf(E element, [int start = 0]);
176 202
177 /** 203 /**
178 * Returns the last index of [element] in this list. 204 * Returns the last index of [element] in this list.
mem 2013/09/06 16:28:16 Technically... it Returns the index of the last o
179 * 205 *
180 * Searches the list backwards from index [start] to 0. 206 * Searches the list backwards from index [start] to 0.
mem 2013/09/06 16:28:16 Searches the list backwards for [element] from ind
181 * 207 *
182 * The first time an object [:o:] is encountered so that [:o == element:], 208 * The first time an object [:o:] is encountered so that [:o == element:],
183 * the index of [:o:] is returned. 209 * the index of [:o:] is returned.
184 * 210 *
211 * List<String> notes = ['do', 're', 'mi', 're'];
212 * notes.lastIndexOf('re', 2); // 1
213 *
185 * If [start] is not provided, it defaults to [:this.length - 1:]. 214 * If [start] is not provided, it defaults to [:this.length - 1:].
mem 2013/09/06 16:28:16 it defaults ... -> this method searches from the e
shailentuli 2013/09/23 11:48:54 Done.
186 * 215 *
216 * notes.lastIndexOf('re'); // 3
217 *
187 * Returns -1 if [element] is not found. 218 * Returns -1 if [element] is not found.
219 *
220 * notes.lastIndexOf('fa'); // -1
188 */ 221 */
189 int lastIndexOf(E element, [int start]); 222 int lastIndexOf(E element, [int start]);
190 223
191 /** 224 /**
192 * Removes all objects from this list; 225 * Removes all objects from this list;
193 * the length of the list becomes zero. 226 * the length of the list becomes zero.
194 * 227 *
195 * Throws an [UnsupportedError], and retains all objects, if this 228 * Throws an [UnsupportedError], and retains all objects, if this
196 * is a fixed-length list. 229 * is a fixed-length list.
197 */ 230 */
198 void clear(); 231 void clear();
199 232
200 /** 233 /**
201 * Inserts the object at position [index] in this list. 234 * Inserts the object at position [index] in this list.
202 * 235 *
203 * This increases the length of the list by one and shifts all objects 236 * This increases the length of the list by one and shifts all objects
204 * at or after the index towards the end of the list. 237 * at or after the index towards the end of the list.
205 * 238 *
206 * An error occurs if the [index] is less than 0 or greater than length. 239 * An error occurs if the [index] is less than 0 or greater than length.
207 * An [UnsupportedError] occurs if the list is fixed-length. 240 * An [UnsupportedError] occurs if the list is fixed-length.
mem 2013/09/06 16:28:16 no example?
208 */ 241 */
209 void insert(int index, E element); 242 void insert(int index, E element);
210 243
211 /** 244 /**
212 * Inserts all objects of [iterable] at position [index] in this list. 245 * Inserts all objects of [iterable] at position [index] in this list.
213 * 246 *
214 * This increases the length of the list by the length of [iterable] and 247 * This increases the length of the list by the length of [iterable] and
215 * shifts all later objects towards the end of the list. 248 * shifts all later objects towards the end of the list.
216 * 249 *
217 * An error occurs if the [index] is less than 0 or greater than length. 250 * An error occurs if the [index] is less than 0 or greater than length.
218 * An [UnsupportedError] occurs if the list is fixed-length. 251 * An [UnsupportedError] occurs if the list is fixed-length.
219 */ 252 */
220 void insertAll(int index, Iterable<E> iterable); 253 void insertAll(int index, Iterable<E> iterable);
221 254
222 /** 255 /**
223 * Overwrites objects of `this` with the objects of [iterable], starting 256 * Overwrites objects of `this` with the objects of [iterable], starting
224 * at position [index] in this list. 257 * at position [index] in this list.
225 * 258 *
259 * List<String> list = ['a', 'b', 'c'];
260 * list.setAll(1, ['bee', 'sea']);
261 * list.join(', '); // 'a, bee, sea'
262 *
226 * This operation does not increase the length of `this`. 263 * This operation does not increase the length of `this`.
227 * 264 *
228 * An error occurs if the [index] is less than 0 or greater than length. 265 * An error occurs if the [index] is less than 0 or greater than length.
229 * An error occurs if the [iterable] is longer than [length] - [index]. 266 * An error occurs if the [iterable] is longer than [length] - [index].
230 */ 267 */
231 void setAll(int index, Iterable<E> iterable); 268 void setAll(int index, Iterable<E> iterable);
232 269
233 /** 270 /**
234 * Removes the first occurence of [value] from this list. 271 * Removes the first occurence of [value] from this list.
mem 2013/09/06 16:28:16 occurence -> occurrence prolly should search for
235 * 272 *
236 * Returns true if [value] was in the list. 273 * Returns true if [value] was in the list.
mem 2013/09/06 16:28:16 ... in the list, false otherwise. then delete "Re
shailentuli 2013/09/23 11:48:54 Done.
237 * Returns false otherwise. 274 * Returns false otherwise.
238 * 275 *
276 * List<String> parts = ['head', 'shoulders', 'knees', 'toes'];
277 * parts.remove('head'); // true
mem 2013/09/06 16:28:16 oh no! a decapitation!
shailentuli 2013/09/23 11:48:54 oh yes!
278 * parts.join(', '); // 'shoulders, knees, toes'
279 *
239 * The method has no effect if [value] was not in the list. 280 * The method has no effect if [value] was not in the list.
240 * 281 *
282 * // Note: 'head' has already been removed.
283 * parts.remove('head'); // false
mem 2013/09/06 16:28:16 maybe use 'elbow' here and you can remove the "not
shailentuli 2013/09/23 11:48:54 No, it has to be 'head' to show that `remove()` re
284 * parts.join(', '); // 'shoulders, knees, toes'
285 *
241 * An [UnsupportedError] occurs if the list is fixed-length. 286 * An [UnsupportedError] occurs if the list is fixed-length.
242 */ 287 */
243 bool remove(Object value); 288 bool remove(Object value);
244 289
245 /** 290 /**
246 * Removes the object at position [index] from this list. 291 * Removes the object at position [index] from this list.
247 * 292 *
248 * This method reduces the length of `this` by one and moves all later objects 293 * This method reduces the length of `this` by one and moves all later objects
249 * down by one position. 294 * down by one position.
250 * 295 *
(...skipping 11 matching lines...) Expand all
262 * 307 *
263 * Throws an [UnsupportedError] if this is a fixed-length list. 308 * Throws an [UnsupportedError] if this is a fixed-length list.
264 */ 309 */
265 E removeLast(); 310 E removeLast();
266 311
267 /** 312 /**
268 * Removes all objects from this list that satisfy [test]. 313 * Removes all objects from this list that satisfy [test].
269 * 314 *
270 * An object [:o:] satisfies [test] if [:test(o):] is true. 315 * An object [:o:] satisfies [test] if [:test(o):] is true.
271 * 316 *
317 * List<String> numbers = ['one', 'two', 'three', 'four'];
318 * numbers.removeWhere((item) => item.length == 3);
319 * numbers.join(', '); // 'three, four'
320 *
272 * Throws an [UnsupportedError] if this is a fixed-length list. 321 * Throws an [UnsupportedError] if this is a fixed-length list.
273 */ 322 */
274 void removeWhere(bool test(E element)); 323 void removeWhere(bool test(E element));
275 324
276 /** 325 /**
277 * Removes all objects from this list that fail to satisfy [test]. 326 * Removes all objects from this list that fail to satisfy [test].
278 * 327 *
279 * An object [:o:] satisfies [test] if [:test(o):] is true. 328 * An object [:o:] satisfies [test] if [:test(o):] is true.
280 * 329 *
330 * List<String> numbers = ['one', 'two', 'three', 'four'];
331 * numbers.retainWhere((item) => item.length == 3);
332 * numbers.join(', '); // 'one, two'
333 *
281 * Throws an [UnsupportedError] if this is a fixed-length list. 334 * Throws an [UnsupportedError] if this is a fixed-length list.
282 */ 335 */
283 void retainWhere(bool test(E element)); 336 void retainWhere(bool test(E element));
284 337
285 /** 338 /**
286 * Returns a new list containing the objects 339 * Returns a new list containing the objects from [start] inclusive to [end]
287 * from [start] inclusive to [end] exclusive. 340 * exclusive.
341 *
342 * List<String> colors = ['red', 'green', 'blue', 'orange', 'pink'];
343 * colors.sublist(1, 3); // ['green', 'blue']
288 * 344 *
289 * If [end] is omitted, the [length] of `this` is used. 345 * If [end] is omitted, the [length] of `this` is used.
290 * 346 *
347 * colors.sublist(1); // ['green', 'blue', 'orange', 'pink']
348 *
291 * An error occurs if [start] is outside the range `0` .. `length` or if 349 * An error occurs if [start] is outside the range `0` .. `length` or if
292 * [end] is outside the range `start` .. `length`. 350 * [end] is outside the range `start` .. `length`.
293 */ 351 */
294 List<E> sublist(int start, [int end]); 352 List<E> sublist(int start, [int end]);
295 353
296 /** 354 /**
297 * Returns an [Iterable] that iterates over the objects in the range 355 * Returns an [Iterable] that iterates over the objects in the range
298 * [start] inclusive to [end] exclusive. 356 * [start] inclusive to [end] exclusive.
299 * 357 *
300 * An error occurs if [end] is before [start]. 358 * An error occurs if [end] is before [start].
301 * 359 *
302 * An error occurs if the [start] and [end] are not valid ranges at the time 360 * An error occurs if the [start] and [end] are not valid ranges at the time
303 * of the call to this method. The returned [Iterable] behaves like 361 * of the call to this method. The returned [Iterable] behaves like
mem 2013/09/06 16:28:16 The last sentence here illuminates the example, bu
304 * `skip(start).take(end - start)`. That is, it does not throw exceptions 362 * `skip(start).take(end - start)`. That is, it does not throw exceptions
305 * if `this` changes size. 363 * if `this` changes size.
306 * 364 *
307 * Example: 365 * List<String> colors = ['red', 'green', 'blue', 'orange', 'pink'];
308 * 366 * Iterable<String> range = colors.getRange(1, 4);
309 * var list = [1, 2, 3, 4, 5]; 367 * range.join(', '); // 'green, blue, orange'
310 * var range = list.getRange(1, 4); 368 * colors.length = 3;
311 * print(range.join(', ')); // => 2, 3, 4 369 * range.join(', '); // 'green, blue'
312 * list.length = 3;
313 * print(range.join(', ')); // => 2, 3
314 */ 370 */
315 Iterable<E> getRange(int start, int end); 371 Iterable<E> getRange(int start, int end);
316 372
317 /** 373 /**
318 * Copies the objects of [iterable], skipping [skipCount] objects first, 374 * Copies the objects of [iterable], skipping [skipCount] objects first,
319 * into the range [start] inclusive to [end] exclusive of `this`. 375 * into the range [start] inclusive to [end] exclusive of `this`.
320 * 376 *
377 * List<int> list1 = [1, 2, 3, 4];
378 * List<int> list2 = [5, 6, 7, 8, 9];
379 * // Copies the 4th and 5th items in list2 as the 2nd and 3rd items of
380 * // list1
mem 2013/09/06 16:28:16 Orphan! Bad form to put one word on a line by itse
shailentuli 2013/09/23 11:48:54 Done.
381 * list1.setRange(1, 3, list2, 3);
382 * list1.join(', '); // '1, 8, 9, 4'
383 *
321 * If [start] equals [end] and [start]..[end] represents a legal range, this 384 * If [start] equals [end] and [start]..[end] represents a legal range, this
322 * method has no effect. 385 * method has no effect.
323 * 386 *
324 * An error occurs if [start]..[end] is not a valid range for `this`. 387 * An error occurs if [start]..[end] is not a valid range for `this`.
325 * An error occurs if the [iterable] does not have enough objects after 388 * An error occurs if the [iterable] does not have enough objects after
326 * skipping [skipCount] objects. 389 * skipping [skipCount] objects.
327 * 390 *
328 * Example:
329 *
330 * var list = [1, 2, 3, 4];
331 * var list2 = [5, 6, 7, 8, 9];
332 * list.setRange(1, 3, list2, 3);
333 * print(list); // => [1, 8, 9, 4]
334 */ 391 */
335 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]); 392 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]);
336 393
337 /** 394 /**
338 * Removes the objects in the range [start] inclusive to [end] exclusive. 395 * Removes the objects in the range [start] inclusive to [end] exclusive.
339 * 396 *
340 * An error occurs if [start]..[end] is not a valid range for `this`. 397 * An error occurs if [start]..[end] is not a valid range for `this`.
341 * Throws an [UnsupportedError] if this is a fixed-length list. 398 * Throws an [UnsupportedError] if this is a fixed-length list.
342 */ 399 */
343 void removeRange(int start, int end); 400 void removeRange(int start, int end);
344 401
345 /** 402 /**
346 * Sets the objects in the range [start] inclusive to [end] exclusive 403 * Sets the objects in the range [start] inclusive to [end] exclusive
347 * to the given [fillValue]. 404 * to the given [fillValue].
348 * 405 *
349 * An error occurs if [start]..[end] is not a valid range for `this`. 406 * An error occurs if [start]..[end] is not a valid range for `this`.
350 */ 407 */
351 void fillRange(int start, int end, [E fillValue]); 408 void fillRange(int start, int end, [E fillValue]);
352 409
353 /** 410 /**
354 * Removes the objects in the range [start] inclusive to [end] exclusive 411 * Removes the objects in the range [start] inclusive to [end] exclusive
355 * and replaces them with the contents of the [iterable]. 412 * and replaces them with the contents of the [iterable].
356 * 413 *
414 * List<int> list = [1, 2, 3, 4];
415 * list.replaceRange(1, 3, [6, 7]);
416 * list.join(', '); // '1, 6, 7, 4'
417 *
357 * An error occurs if [start]..[end] is not a valid range for `this`. 418 * An error occurs if [start]..[end] is not a valid range for `this`.
358 *
359 * Example:
360 *
361 * var list = [1, 2, 3, 4, 5];
362 * list.replaceRange(1, 3, [6, 7, 8, 9]);
363 * print(list); // [1, 6, 7, 8, 9, 4, 5]
364 */ 419 */
365 void replaceRange(int start, int end, Iterable<E> iterable); 420 void replaceRange(int start, int end, Iterable<E> iterable);
366 421
367 /** 422 /**
368 * Returns an unmodifiable [Map] view of `this`. 423 * Returns an unmodifiable [Map] view of `this`.
369 * 424 *
370 * The map uses the indices of this list as keys and the corresponding objects 425 * The map uses the indices of this list as keys and the corresponding objects
371 * as values. The `Map.keys` [Iterable] iterates the indices of this list 426 * as values. The `Map.keys` [Iterable] iterates the indices of this list
372 * in numerical order. 427 * in numerical order.
428 *
429 * List<String> words = ['fee', 'fi', 'fo', 'fum'];
430 * Map<int, String> map = words.asMap();
431 * map[0] + map[1]; // 'feefi';
432 * map.keys.toList(); // [0, 1, 2, 3]
373 */ 433 */
374 Map<int, E> asMap(); 434 Map<int, E> asMap();
375 } 435 }
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