Chromium Code Reviews| Index: sdk/lib/core/iterator.dart |
| diff --git a/sdk/lib/core/iterator.dart b/sdk/lib/core/iterator.dart |
| index 2e324f6a9b26ead8b7d201a25dfc34f52855ebba..b7841b892139a3369f9c15da0a19a2e87a05d4a7 100644 |
| --- a/sdk/lib/core/iterator.dart |
| +++ b/sdk/lib/core/iterator.dart |
| @@ -9,16 +9,29 @@ |
| * |
| * If the object iterated over is changed during the iteration, the |
| * behavior is unspecified. |
| + * |
| + * The [Iterator] is initially positioned before the first element. Before |
| + * accessing the first element the iterator must thus be advanced ([moveNext]) |
| + * to point to the first element. If there is no element left, then [moveNext] |
| + * returns false. |
| */ |
| abstract class Iterator<E> { |
| /** |
| - * Gets the next element in the iteration. Throws a |
| - * [StateError] if no element is left. |
| + * Moves to the next element. Returns true if [current] contains the next |
| + * element. Returns false, if no element was left. It the latter case |
| + * trying to read [current] will throw a [StateError]. |
| + * |
| + * It is safe to invoke [moveNext] even when the iterator is already |
| + * positioned after the last element. In this case [moveNext] has no effect. |
| */ |
| - E next(); |
| + bool moveNext(); |
| /** |
| - * Returns whether the [Iterator] has elements left. |
| + * Returns the current element. |
| + * |
| + * Throws a [StateError] if the iterator has not yet been moved to the first |
| + * element, or if the iterator has been moved after the last element of the |
| + * [Iterable]. |
| */ |
| bool hasNext; |
|
Lasse Reichstein Nielsen
2012/11/12 09:38:03
Change to 'T get current'?
floitsch
2012/11/16 22:31:07
Done.
|
| } |