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

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

Issue 11366111: Make Iterable more powerful (and lazy). (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Undo unintended change. Created 8 years, 1 month 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
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 /** 5 /**
6 * The [Iterator] class provides methods to iterate over an object. It 6 * The [Iterator] class provides methods to iterate over an object. It
7 * is transparently used by the for-in construct to test for the end 7 * is transparently used by the for-in construct to test for the end
8 * of the iteration, and to get the elements. 8 * of the iteration, and to get the elements.
9 * 9 *
10 * If the object iterated over is changed during the iteration, the 10 * If the object iterated over is changed during the iteration, the
11 * behavior is unspecified. 11 * behavior is unspecified.
12 *
13 * The [Iterator] is initially positioned before the first element. Before
14 * accessing the first element the iterator must thus be advanced ([moveNext])
15 * to point to the first element. If there is no element left, then [moveNext]
16 * returns false.
12 */ 17 */
13 abstract class Iterator<E> { 18 abstract class Iterator<E> {
14 /** 19 /**
15 * Gets the next element in the iteration. Throws a 20 * Moves to the next element. Returns true if [current] contains the next
16 * [StateError] if no element is left. 21 * element. Returns false, if no element was left. It the latter case
22 * trying to read [current] will throw a [StateError].
23 *
24 * It is safe to invoke [moveNext] even when the iterator is already
25 * positioned after the last element. In this case [moveNext] has no effect.
17 */ 26 */
18 E next(); 27 bool moveNext();
19 28
20 /** 29 /**
21 * Returns whether the [Iterator] has elements left. 30 * Returns the current element.
31 *
32 * Throws a [StateError] if the iterator has not yet been moved to the first
33 * element, or if the iterator has been moved after the last element of the
34 * [Iterable].
22 */ 35 */
23 bool hasNext; 36 bool hasNext;
Lasse Reichstein Nielsen 2012/11/12 09:38:03 Change to 'T get current'?
floitsch 2012/11/16 22:31:07 Done.
24 } 37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698