@@ -52,40 +52,6 @@ extension LazySplitSequence {
52
52
53
53
extension LazySplitSequence . Iterator : IteratorProtocol {
54
54
public mutating func next( ) -> Element ? {
55
- /// Separators mark the points where we want to split (cut in two) the base
56
- /// collection, removing the separator in the process.
57
- ///
58
- /// Each split yields two subsequences, though splitting at the start or end
59
- /// of a sequence yields an empty subsequence where there were no elements
60
- /// adjacent to the cut.
61
- ///
62
- /// Thus the maximum number of subsequences returned after iterating the
63
- /// entire base collection (including empty ones, if they are not omitted)
64
- /// will be at most one more than the number of splits made (equivalently,
65
- /// one more than the number of separators encountered).
66
- ///
67
- /// The number of splits is limited by `maxSplits`, and thus may be less
68
- /// than the total number of separators in the base collection.
69
- ///
70
- /// [1, 2, 42, 3, 4, 42, 5].split(separator: 42,
71
- /// omittingEmptySubsequences: false)
72
- /// // first split -> [1, 2], [3, 4, 42, 5]
73
- /// // last split -> [1, 2], [3, 4], [5]
74
- ///
75
- /// [1, 2, 42, 3, 4, 42, 5, 42].split(separator: 42,
76
- /// maxSplits: 2,
77
- /// omittingEmptySubsequences: false)
78
- /// // first split -> [1, 2], [3, 4, 42, 5, 42]
79
- /// // last split -> [1, 2], [3, 4], [5, 42]
80
- ///
81
- /// [42, 1, 42].split(separator: 42, omittingEmptySubsequences: false)
82
- /// // first split -> [], [1, 42]
83
- /// // last split -> [], [1], []
84
- ///
85
- /// [42, 42].split(separator: 42, omittingEmptySubsequences: false)
86
- /// // first split -> [], [42]
87
- /// // last split -> [], [], []
88
-
89
55
var currentElement = base. next ( )
90
56
var subsequence : Element = [ ]
91
57
@@ -136,18 +102,19 @@ extension LazySplitSequence: LazySequenceProtocol {
136
102
}
137
103
138
104
extension LazySequenceProtocol {
139
- /// Lazily returns the longest possible subsequences of the sequence, in order,
140
- /// that don't contain elements satisfying the given predicate.
105
+ /// Lazily returns the longest possible subsequences of the sequence, in
106
+ /// order, that don't contain elements satisfying the given predicate.
141
107
///
142
- /// The resulting lazy sequence consists of at most `maxSplits + 1` subsequences.
143
- /// Elements that are used to split the sequence are not returned as part of any
144
- /// subsequence (except possibly the last one, in the case where `maxSplits` is
145
- /// less than the number of separators in the sequence).
108
+ /// The resulting lazy sequence consists of at most `maxSplits + 1`
109
+ /// subsequences. Elements that are used to split the sequence are not
110
+ /// returned as part of any subsequence (except possibly the last one, in the
111
+ /// case where `maxSplits` is less than the number of separators in the
112
+ /// sequence).
146
113
///
147
114
/// The following examples show the effects of the `maxSplits` and
148
- /// `omittingEmptySubsequences` parameters when lazily splitting a string using a
149
- /// closure that matches spaces. The first use of `split` returns each word
150
- /// that was originally separated by one or more spaces.
115
+ /// `omittingEmptySubsequences` parameters when lazily splitting a string
116
+ /// using a closure that matches spaces. The first use of `split` returns each
117
+ /// word that was originally separated by one or more spaces.
151
118
///
152
119
/// let line = "BLANCHE: I don't want realism. I want magic!"
153
120
/// for spaceless in line.lazy.split(whereSeparator: { $0 == " " }) {
@@ -166,7 +133,10 @@ extension LazySequenceProtocol {
166
133
/// The second example passes `1` for the `maxSplits` parameter, so the
167
134
/// original string is split just once, into two new strings.
168
135
///
169
- /// for spaceless in line.lazy.split(maxSplits: 1, whereSeparator: { $0 == " " }) {
136
+ /// for spaceless in line.lazy.split(
137
+ /// maxSplits: 1,
138
+ /// whereSeparator: { $0 == " " }
139
+ /// ) {
170
140
/// print(spaceless)
171
141
/// }
172
142
/// // Prints
@@ -177,7 +147,10 @@ extension LazySequenceProtocol {
177
147
/// parameter, so the returned array contains empty strings where spaces
178
148
/// were repeated.
179
149
///
180
- /// for spaceless in line.lazy.split(omittingEmptySubsequences: false, whereSeparator: { $0 == " " }) {
150
+ /// for spaceless in line.lazy.split(
151
+ /// omittingEmptySubsequences: false,
152
+ /// whereSeparator: { $0 == " " }
153
+ /// ) {
181
154
/// print(spaceless)
182
155
/// }
183
156
/// // Prints
@@ -228,13 +201,14 @@ extension LazySequenceProtocol {
228
201
}
229
202
230
203
extension LazySequenceProtocol where Element: Equatable {
231
- /// Lazily returns the longest possible subsequences of the sequence, in order,
232
- /// around elements equal to the given element.
204
+ /// Lazily returns the longest possible subsequences of the sequence, in
205
+ /// order, around elements equal to the given element.
233
206
///
234
- /// The resulting lazy sequence consists of at most `maxSplits + 1` subsequences.
235
- /// Elements that are used to split the sequence are not returned as part of any
236
- /// subsequence (except possibly the last one, in the case where `maxSplits` is
237
- /// less than the number of separators in the sequence).
207
+ /// The resulting lazy sequence consists of at most `maxSplits + 1`
208
+ /// subsequences. Elements that are used to split the sequence are not
209
+ /// returned as part of any subsequence (except possibly the last one, in the
210
+ /// case where `maxSplits` is less than the number of separators in the
211
+ /// sequence).
238
212
///
239
213
/// The following examples show the effects of the `maxSplits` and
240
214
/// `omittingEmptySubsequences` parameters when splitting a string at each
@@ -269,7 +243,10 @@ extension LazySequenceProtocol where Element: Equatable {
269
243
/// parameter, so the returned array contains empty strings where spaces
270
244
/// were repeated.
271
245
///
272
- /// for spaceless in line.lazy.split(separator: " ", omittingEmptySubsequences: false) {
246
+ /// for spaceless in line.lazy.split(
247
+ /// separator: " ",
248
+ /// omittingEmptySubsequences: false
249
+ /// ) {
273
250
/// print(spaceless)
274
251
/// }
275
252
/// // Prints
0 commit comments