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

Unified Diff: sdk/lib/core/iterator.dart

Issue 11867024: Move some core classes to collection library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with bug number. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/corelib_sources.gypi ('k') | sdk/lib/core/map.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/iterator.dart
diff --git a/sdk/lib/core/iterator.dart b/sdk/lib/core/iterator.dart
index 12c4a72a97652d78177ab6c1b19b93d73ec2716f..e251df62fb35a052c90f29c69f314d99e64e2bcb 100644
--- a/sdk/lib/core/iterator.dart
+++ b/sdk/lib/core/iterator.dart
@@ -16,6 +16,13 @@ part of dart.core;
* 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.
+ *
+ * A typical usage of an [Iterator] looks as follows:
+ *
+ * var it = obj.iterator;
+ * while (it.moveNext()) {
+ * use(it.current);
+ * }
*/
abstract class Iterator<E> {
/**
@@ -36,37 +43,3 @@ abstract class Iterator<E> {
*/
E get current;
}
-
-class HasNextIterator<E> {
- static const int _HAS_NEXT_AND_NEXT_IN_CURRENT = 0;
- static const int _NO_NEXT = 1;
- static const int _NOT_MOVED_YET = 2;
-
- Iterator _iterator;
- int _state = _NOT_MOVED_YET;
-
- HasNextIterator(this._iterator);
-
- bool get hasNext {
- if (_state == _NOT_MOVED_YET) _move();
- return _state == _HAS_NEXT_AND_NEXT_IN_CURRENT;
- }
-
- E next() {
- // Call to hasNext is necessary to make sure we are positioned at the first
- // element when we start iterating.
- if (!hasNext) throw new StateError("No more elements");
- assert(_state == _HAS_NEXT_AND_NEXT_IN_CURRENT);
- E result = _iterator.current;
- _move();
- return result;
- }
-
- void _move() {
- if (_iterator.moveNext()) {
- _state = _HAS_NEXT_AND_NEXT_IN_CURRENT;
- } else {
- _state = _NO_NEXT;
- }
- }
-}
« no previous file with comments | « sdk/lib/core/corelib_sources.gypi ('k') | sdk/lib/core/map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698