@@ -66,32 +66,31 @@ public func max<T : Comparable>(x: T, _ y: T, _ z: T, _ rest: T...) -> T {
66
66
return r
67
67
}
68
68
69
- /// The `IteratorProtocol` for `EnumeratedSequence`. `EnumeratedIterator`
70
- /// wraps a `Base` `IteratorProtocol` and yields successive `Int` values,
69
+ /// The iterator for `EnumeratedSequence`. `EnumeratedIterator`
70
+ /// wraps a `Base` iterator and yields successive `Int` values,
71
71
/// starting at zero, along with the elements of the underlying
72
72
/// `Base`:
73
73
///
74
- /// var iterator = ["foo", "bar"].enumerate ()
74
+ /// var iterator = ["foo", "bar"].enumerated.iterator ()
75
75
/// iterator.next() // (0, "foo")
76
76
/// iterator.next() // (1, "bar")
77
77
/// iterator.next() // nil
78
- ///
79
- /// - Note: Idiomatic usage is to call `enumerate` instead of
80
- /// constructing an `EnumeratedIterator` directly.
81
78
public struct EnumeratedIterator <
82
79
Base : IteratorProtocol
83
80
> : IteratorProtocol , SequenceType {
84
- /// The type of element returned by `next()`.
85
- public typealias Element = ( offset: Int , element: Base . Element )
86
- var _base : Base
87
- var _count : Int
81
+
82
+ internal var _base : Base
83
+ internal var _count : Int
88
84
89
85
/// Construct from a `Base` iterator.
90
86
internal init ( _base: Base ) {
91
87
self . _base = _base
92
88
self . _count = 0
93
89
}
94
90
91
+ /// The type of element returned by `next()`.
92
+ public typealias Element = ( offset: Int , element: Base . Element )
93
+
95
94
/// Advance to the next element and return it, or `nil` if no next
96
95
/// element exists.
97
96
///
@@ -102,16 +101,14 @@ public struct EnumeratedIterator<
102
101
}
103
102
}
104
103
105
- /// The `SequenceType` returned by `enumerate()`. `EnumeratedSequence`
106
- /// is a sequence of pairs (*n*, *x*), where *n*s are consecutive
107
- /// `Int`s starting at zero, and *x*s are the elements of a `Base`
108
- /// `SequenceType`:
104
+ /// The type of the `enumerated` property.
109
105
///
110
- /// var s = EnumeratedSequence(["foo", "bar"])
111
- /// Array(s) // [(0, "foo"), (1, "bar")]
106
+ /// `EnumeratedSequence` is a sequence of pairs (*n*, *x*), where *n*s
107
+ /// are consecutive `Int`s starting at zero, and *x*s are the elements
108
+ /// of a `Base` `SequenceType`:
112
109
///
113
- /// - Note: Idiomatic usage is to call `enumerate` instead of
114
- /// constructing an `EnumeratedSequence` directly.
110
+ /// var s = ["foo", "bar"].enumerated
111
+ /// Array(s) // [(0, "foo"), (1, "bar")]
115
112
public struct EnumeratedSequence < Base : SequenceType > : SequenceType {
116
113
internal var _base : Base
117
114
0 commit comments