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; |
- } |
- } |
-} |