Skip to content

Commit 7a6c135

Browse files
committed
Update documentation on complexity of combinations(ofCount:)
1 parent dcf4054 commit 7a6c135

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/Algorithms/Combinations.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ extension Collection {
245245
/// - Parameter kRange: The range of numbers of elements to include in each
246246
/// combination.
247247
///
248-
/// - Complexity: O(1)
248+
/// - Complexity: O(1) for random-access base collections. O(*n*) where *n*
249+
/// is the number of elements in the base collection, since `Combinations`
250+
/// accesses the `count` of the base collection.
249251
@inlinable
250252
public func combinations<R: RangeExpression>(
251253
ofCount kRange: R
@@ -279,7 +281,9 @@ extension Collection {
279281
///
280282
/// - Parameter k: The number of elements to include in each combination.
281283
///
282-
/// - Complexity: O(1)
284+
/// - Complexity: O(1) for random-access base collections. O(*n*) where *n*
285+
/// is the number of elements in the base collection, since `Combinations`
286+
/// accesses the `count` of the base collection.
283287
@inlinable
284288
public func combinations(ofCount k: Int) -> Combinations<Self> {
285289
assert(k >= 0, "Can't have combinations with a negative number of elements.")

0 commit comments

Comments
 (0)