Skip to content

Commit 36dc3d4

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

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/Algorithms/Chunked.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ 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
209211
/// - Complexity: O(*n*), because the start index is pre-computed.
210212
@inlinable
211213
public func chunked(
@@ -220,6 +222,9 @@ extension LazySequenceProtocol where Self: Collection, Elements: Collection {
220222
/// Returns a lazy collection of subsequences of this collection, chunked by
221223
/// grouping elements that project to the equal values.
222224
///
225+
/// - Parameter projection: A closure that takes an element in the collection
226+
/// and returns an `Equatable` value that can be used to determine if adjacent
227+
/// elements belong in the same group
223228
/// - Complexity: O(*n*), because the start index is pre-computed.
224229
@inlinable
225230
public func chunked<Subject>(
@@ -239,6 +244,8 @@ extension Collection {
239244
/// Returns a collection of subsequences of this collection, chunked by the
240245
/// given predicate.
241246
///
247+
/// - Parameter belongInSameGroup: A closure that takes two adjacent elements
248+
/// of the collection and returns whether or not they belong in the same group
242249
/// - Complexity: O(*n*), where *n* is the length of this collection.
243250
@inlinable
244251
public func chunked(
@@ -268,6 +275,9 @@ extension Collection {
268275
/// Returns a collection of subsequences of this collection, chunked by
269276
/// grouping elements that project to equal values.
270277
///
278+
/// - Parameter projection: A closure that takes an element in the collection
279+
/// and returns an `Equatable` value that can be used to determine if adjacent
280+
/// elements belong in the same group
271281
/// - Complexity: O(*n*), where *n* is the length of this collection.
272282
@inlinable
273283
public func chunked<Subject: Equatable>(

0 commit comments

Comments
 (0)