19
19
// This protocol is almost an implementation detail of the standard
20
20
// library; it is used to deduce things like the `SubSequence` and
21
21
// `Iterator` type from a minimal collection, but it is also used in
22
- // exposed places like as a constraint on IndexingGenerator .
22
+ // exposed places like as a constraint on CollectionDefaultIterator .
23
23
public protocol Indexable {
24
24
/// A type that represents a valid position in the collection.
25
25
///
@@ -46,11 +46,11 @@ public protocol Indexable {
46
46
// The declaration of _Element and subscript here is a trick used to
47
47
// break a cyclic conformance/deduction that Swift can't handle. We
48
48
// need something other than a CollectionType.Iterator.Element that can
49
- // be used as IndexingGenerator <T>'s Element. Here we arrange for the
50
- // CollectionType itself to have an Element type that's deducible from
51
- // its subscript. Ideally we'd like to constrain this
52
- // Element to be the same as CollectionType.Iterator.Element (see
53
- // below), but we have no way of expressing it today.
49
+ // be used as CollectionDefaultIterator <T>'s Element. Here we arrange for
50
+ // the CollectionType itself to have an Element type that's deducible from
51
+ // its subscript. Ideally we'd like to constrain this Element to be the same
52
+ // as CollectionType.Iterator.Element (see below), but we have no way of
53
+ // expressing it today.
54
54
typealias _Element
55
55
56
56
/// Returns the element at the given `position`.
@@ -70,19 +70,8 @@ public protocol MutableIndexable {
70
70
subscript( position: Index ) -> _Element { get set }
71
71
}
72
72
73
- /// An *iterator* for an arbitrary *collection*. Provided `C`
74
- /// conforms to the other requirements of `Indexable`,
75
- /// `IndexingGenerator<C>` can be used as the result of `C`'s
76
- /// `iterator()` method. For example:
77
- ///
78
- /// struct MyCollection : CollectionType {
79
- /// struct Index : ForwardIndexType { /* implementation hidden */ }
80
- /// subscript(i: Index) -> MyElement { /* implementation hidden */ }
81
- /// func iterator() -> IndexingGenerator<MyCollection> { // <===
82
- /// return IndexingGenerator(self)
83
- /// }
84
- /// }
85
- public struct IndexingGenerator < Elements : Indexable >
73
+ /// The iterator used for collections that don't specify one.
74
+ public struct CollectionDefaultIterator < Elements : Indexable >
86
75
: IteratorProtocol , SequenceType {
87
76
88
77
/// Create a *iterator* over the given collection.
@@ -123,13 +112,13 @@ public protocol CollectionType : Indexable, SequenceType {
123
112
/// encapsulates its iteration state.
124
113
///
125
114
/// By default, a `CollectionType` satisfies `SequenceType` by
126
- /// supplying an `IndexingGenerator ` as its associated `Iterator`
115
+ /// supplying a `CollectionDefaultIterator ` as its associated `Iterator`
127
116
/// type.
128
- typealias Iterator : IteratorProtocol = IndexingGenerator < Self >
117
+ typealias Iterator : IteratorProtocol = CollectionDefaultIterator < Self >
129
118
130
119
// FIXME: Needed here so that the Iterator is properly deduced from
131
120
// a custom iterator() function. Otherwise we get an
132
- // IndexingGenerator . <rdar://problem/21539115>
121
+ // CollectionDefaultIterator . <rdar://problem/21539115>
133
122
func iterator( ) -> Iterator
134
123
135
124
// FIXME: should be constrained to CollectionType
@@ -197,10 +186,10 @@ public protocol CollectionType : Indexable, SequenceType {
197
186
198
187
/// Supply the default `iterator()` method for `CollectionType` models
199
188
/// that accept the default associated `Iterator`,
200
- /// `IndexingGenerator <Self>`.
201
- extension CollectionType where Iterator == IndexingGenerator < Self > {
202
- public func iterator( ) -> IndexingGenerator < Self > {
203
- return IndexingGenerator ( self )
189
+ /// `CollectionDefaultIterator <Self>`.
190
+ extension CollectionType where Iterator == CollectionDefaultIterator < Self > {
191
+ public func iterator( ) -> CollectionDefaultIterator < Self > {
192
+ return CollectionDefaultIterator ( self )
204
193
}
205
194
}
206
195
0 commit comments