@@ -32,12 +32,12 @@ extension Sequence {
32
32
}
33
33
}
34
34
35
+ /// A wrapper that strides over a base sequence or collection.
35
36
public struct Stride < Base: Sequence > {
37
+ internal let base : Base
38
+ internal let stride : Int
36
39
37
- let base : Base
38
- let stride : Int
39
-
40
- init ( base: Base , stride: Int ) {
40
+ internal init ( base: Base , stride: Int ) {
41
41
precondition ( stride > 0 , " striding must be greater than zero " )
42
42
self . base = base
43
43
self . stride = stride
@@ -51,12 +51,11 @@ extension Stride {
51
51
}
52
52
53
53
extension Stride : Sequence {
54
-
54
+ /// An iterator over a `Stride` sequence.
55
55
public struct Iterator : IteratorProtocol {
56
-
57
- var iterator : Base . Iterator
58
- let stride : Int
59
- var striding : Bool = false
56
+ internal var iterator : Base . Iterator
57
+ internal let stride : Int
58
+ internal var striding : Bool = false
60
59
61
60
public mutating func next( ) -> Base . Element ? {
62
61
guard striding else {
@@ -76,12 +75,11 @@ extension Stride: Sequence {
76
75
}
77
76
78
77
extension Stride : Collection where Base: Collection {
79
-
78
+ /// A position in a `Stride` collection.
80
79
public struct Index : Comparable {
80
+ internal let base : Base . Index
81
81
82
- let base : Base . Index
83
-
84
- init ( _ base: Base . Index ) {
82
+ internal init ( _ base: Base . Index ) {
85
83
self . base = base
86
84
}
87
85
@@ -192,29 +190,21 @@ extension Stride: BidirectionalCollection
192
190
}
193
191
}
194
192
195
- extension Stride : RandomAccessCollection
196
- where Base: RandomAccessCollection { }
193
+ extension Stride : RandomAccessCollection where Base: RandomAccessCollection { }
197
194
198
- extension Stride : Equatable
199
- where Base. Element: Equatable {
200
-
195
+ extension Stride : Equatable where Base. Element: Equatable {
201
196
public static func == ( lhs: Stride , rhs: Stride ) -> Bool {
202
197
lhs. elementsEqual ( rhs, by: == )
203
198
}
204
-
205
199
}
206
200
207
- extension Stride : Hashable
208
- where Base. Element: Hashable {
209
-
201
+ extension Stride : Hashable where Base. Element: Hashable {
210
202
public func hash( into hasher: inout Hasher ) {
211
203
hasher. combine ( stride)
212
204
for element in self {
213
205
hasher. combine ( element)
214
206
}
215
207
}
216
-
217
208
}
218
209
219
- extension Stride . Index : Hashable
220
- where Base. Index: Hashable { }
210
+ extension Stride . Index : Hashable where Base. Index: Hashable { }
0 commit comments