| 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 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An object that uses an [Iterator] to serve objects one at a time. | 8 * An object that uses an [Iterator] to serve objects one at a time. |
| 9 * | 9 * |
| 10 * You can iterate over all objects served by an Iterable object | 10 * You can iterate over all objects served by an Iterable object |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 /** | 65 /** |
| 66 * Returns a new lazy [Iterable] with elements that are created by | 66 * Returns a new lazy [Iterable] with elements that are created by |
| 67 * calling `f` on the elements of this `Iterable`. | 67 * calling `f` on the elements of this `Iterable`. |
| 68 * | 68 * |
| 69 * This method returns a view of the mapped elements. As long as the | 69 * This method returns a view of the mapped elements. As long as the |
| 70 * returned [Iterable] is not iterated over, the supplied function [f] will | 70 * returned [Iterable] is not iterated over, the supplied function [f] will |
| 71 * not be invoked. The transformed elements will not be cached. Iterating | 71 * not be invoked. The transformed elements will not be cached. Iterating |
| 72 * multiple times over the the returned [Iterable] will invoke the supplied | 72 * multiple times over the the returned [Iterable] will invoke the supplied |
| 73 * function [f] multiple times on the same element. | 73 * function [f] multiple times on the same element. |
| 74 */ | 74 */ |
| 75 Iterable map(f(E element)); | 75 Iterable/*<T>*/ map/*<T>*/(/*=T*/ f(E element)); |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Returns a new lazy [Iterable] with all elements that satisfy the | 78 * Returns a new lazy [Iterable] with all elements that satisfy the |
| 79 * predicate [test]. | 79 * predicate [test]. |
| 80 * | 80 * |
| 81 * This method returns a view of the mapped elements. As long as the | 81 * This method returns a view of the mapped elements. As long as the |
| 82 * returned [Iterable] is not iterated over, the supplied function [test] will | 82 * returned [Iterable] is not iterated over, the supplied function [test] will |
| 83 * not be invoked. Iterating will not cache results, and thus iterating | 83 * not be invoked. Iterating will not cache results, and thus iterating |
| 84 * multiple times over the returned [Iterable] will invoke the supplied | 84 * multiple times over the returned [Iterable] will invoke the supplied |
| 85 * function [test] multiple times on the same element. | 85 * function [test] multiple times on the same element. |
| 86 */ | 86 */ |
| 87 Iterable<E> where(bool test(E element)); | 87 Iterable<E> where(bool test(E element)); |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * Expands each element of this [Iterable] into zero or more elements. | 90 * Expands each element of this [Iterable] into zero or more elements. |
| 91 * | 91 * |
| 92 * The resulting Iterable runs through the elements returned | 92 * The resulting Iterable runs through the elements returned |
| 93 * by [f] for each element of this, in order. | 93 * by [f] for each element of this, in order. |
| 94 * | 94 * |
| 95 * The returned [Iterable] is lazy, and calls [f] for each element | 95 * The returned [Iterable] is lazy, and calls [f] for each element |
| 96 * of this every time it's iterated. | 96 * of this every time it's iterated. |
| 97 */ | 97 */ |
| 98 Iterable expand(Iterable f(E element)); | 98 Iterable/*<T>*/ expand/*<T>*/(Iterable/*<T>*/ f(E element)); |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Returns true if the collection contains an element equal to [element]. | 101 * Returns true if the collection contains an element equal to [element]. |
| 102 * | 102 * |
| 103 * The equality used to determine whether [element] is equal to an element of | 103 * The equality used to determine whether [element] is equal to an element of |
| 104 * the iterable, depends on the type of iterable. | 104 * the iterable, depends on the type of iterable. |
| 105 * For example, a [Set] may have a custom equality | 105 * For example, a [Set] may have a custom equality |
| 106 * (see, e.g., [Set.identical]) that its `contains` uses. | 106 * (see, e.g., [Set.identical]) that its `contains` uses. |
| 107 * Likewise the `Iterable` returned by a [Map.keys] call | 107 * Likewise the `Iterable` returned by a [Map.keys] call |
| 108 * will likely use the same equality that the `Map` uses for keys. | 108 * will likely use the same equality that the `Map` uses for keys. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 131 * function. | 131 * function. |
| 132 * | 132 * |
| 133 * Use [initialValue] as the initial value, and the function [combine] to | 133 * Use [initialValue] as the initial value, and the function [combine] to |
| 134 * create a new value from the previous one and an element. | 134 * create a new value from the previous one and an element. |
| 135 * | 135 * |
| 136 * Example of calculating the sum of an iterable: | 136 * Example of calculating the sum of an iterable: |
| 137 * | 137 * |
| 138 * iterable.fold(0, (prev, element) => prev + element); | 138 * iterable.fold(0, (prev, element) => prev + element); |
| 139 * | 139 * |
| 140 */ | 140 */ |
| 141 dynamic fold(var initialValue, | 141 dynamic/*=T*/ fold/*<T>*/(var/*=T*/ initialValue, |
| 142 dynamic combine(var previousValue, E element)); | 142 dynamic/*=T*/ combine(var/*=T*/ previousValue, E element)); |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * Returns true if every elements of this collection satisify the | 145 * Returns true if every elements of this collection satisify the |
| 146 * predicate [test]. Returns `false` otherwise. | 146 * predicate [test]. Returns `false` otherwise. |
| 147 */ | 147 */ |
| 148 bool every(bool test(E element)); | 148 bool every(bool test(E element)); |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * Converts each element to a [String] and concatenates the strings. | 151 * Converts each element to a [String] and concatenates the strings. |
| 152 * | 152 * |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 */ | 370 */ |
| 371 abstract class BidirectionalIterator<E> implements Iterator<E> { | 371 abstract class BidirectionalIterator<E> implements Iterator<E> { |
| 372 /** | 372 /** |
| 373 * Move back to the previous element. | 373 * Move back to the previous element. |
| 374 * | 374 * |
| 375 * Returns true and updates [current] if successful. Returns false | 375 * Returns true and updates [current] if successful. Returns false |
| 376 * and sets [current] to null if there is no previous element. | 376 * and sets [current] to null if there is no previous element. |
| 377 */ | 377 */ |
| 378 bool movePrevious(); | 378 bool movePrevious(); |
| 379 } | 379 } |
| OLD | NEW |