Skip to content

Commit f1e40c2

Browse files
committed
Document belongInSameGroup and projection
1 parent 440698f commit f1e40c2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sources/Algorithms/Chunked.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ extension LazySequenceProtocol where Self: Collection, Elements: Collection {
206206
/// Returns a lazy collection of subsequences of this collection, chunked by
207207
/// the given predicate.
208208
///
209+
/// - Parameter belongInSameGroup: A closure that takes two adjacent elements
210+
/// of the collection and returns whether or not they belong in the same group
211+
///
209212
/// - Complexity: O(*n*), because the start index is pre-computed.
210213
@inlinable
211214
public func chunked(
@@ -220,6 +223,10 @@ extension LazySequenceProtocol where Self: Collection, Elements: Collection {
220223
/// Returns a lazy collection of subsequences of this collection, chunked by
221224
/// grouping elements that project to the equal values.
222225
///
226+
/// - Parameter projection: A closure that takes an element in the collection
227+
/// and returns an `Equatable` value that can be used to determine if adjacent
228+
/// elements belong in the same group
229+
///
223230
/// - Complexity: O(*n*), because the start index is pre-computed.
224231
@inlinable
225232
public func chunked<Subject>(
@@ -239,6 +246,9 @@ extension Collection {
239246
/// Returns a collection of subsequences of this collection, chunked by the
240247
/// given predicate.
241248
///
249+
/// - Parameter belongInSameGroup: A closure that takes two adjacent elements
250+
/// of the collection and returns whether or not they belong in the same group
251+
///
242252
/// - Complexity: O(*n*), where *n* is the length of this collection.
243253
@inlinable
244254
public func chunked(
@@ -268,6 +278,10 @@ extension Collection {
268278
/// Returns a collection of subsequences of this collection, chunked by
269279
/// grouping elements that project to equal values.
270280
///
281+
/// - Parameter projection: A closure that takes an element in the collection
282+
/// and returns an `Equatable` value that can be used to determine if adjacent
283+
/// elements belong in the same group
284+
///
271285
/// - Complexity: O(*n*), where *n* is the length of this collection.
272286
@inlinable
273287
public func chunked<Subject: Equatable>(

0 commit comments

Comments
 (0)