| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of dart.core; | |
| 6 | |
| 7 /** | |
| 8 * An interface for getting items, one at a time, from an object. | |
| 9 * | |
| 10 * The for-in construct transparently uses Iterator to test for the end | |
| 11 * of the iteration, and to get each item (or _element_). | |
| 12 * | |
| 13 * If the object iterated over is changed during the iteration, the | |
| 14 * behavior is unspecified. | |
| 15 * | |
| 16 * The Iterator is initially positioned before the first element. Before | |
| 17 * accessing the first element the iterator must thus be advanced ([moveNext]) | |
| 18 * to point to the first element. If no element is left, then [moveNext] | |
| 19 * returns false. | |
| 20 * | |
| 21 * A typical usage of an Iterator looks as follows: | |
| 22 * | |
| 23 * var it = obj.iterator; | |
| 24 * while (it.moveNext()) { | |
| 25 * use(it.current); | |
| 26 * } | |
| 27 * | |
| 28 * **See also:** [Iteration] | |
| 29 * (http://www.dartlang.org/docs/dart-up-and-running/contents/ch03.html#ch03-ite
ration) | |
| 30 * in the [library tour] | |
| 31 * (http://www.dartlang.org/docs/dart-up-and-running/contents/ch03.html) | |
| 32 */ | |
| 33 abstract class Iterator<E> { | |
| 34 /** | |
| 35 * Moves to the next element. Returns true if [current] contains the next | |
| 36 * element. Returns false, if no element was left. | |
| 37 * | |
| 38 * It is safe to invoke [moveNext] even when the iterator is already | |
| 39 * positioned after the last element. In this case [moveNext] has no effect. | |
| 40 */ | |
| 41 bool moveNext(); | |
| 42 | |
| 43 /** | |
| 44 * Returns the current element. | |
| 45 * | |
| 46 * Return [:null:] if the iterator has not yet been moved to the first | |
| 47 * element, or if the iterator has been moved after the last element of the | |
| 48 * [Iterable]. | |
| 49 */ | |
| 50 E get current; | |
| 51 } | |
| OLD | NEW |