diff --git a/Guides/Partition.md b/Guides/Partition.md index 54678aa3a..4bfea2268 100644 --- a/Guides/Partition.md +++ b/Guides/Partition.md @@ -63,15 +63,18 @@ The `partitioningIndex(where:)` method is available on any `Collection` type. ```swift extension MutableCollection { + @discardableResult mutating func stablePartition( by belongsInSecondPartition: (Element) throws -> Bool ) rethrows -> Index + @discardableResult mutating func stablePartition( subrange: Range, by belongsInSecondPartition: (Element) throws -> Bool ) rethrows -> Index + @discardableResult mutating func partition( subrange: Range, by belongsInSecondPartition: (Element) throws -> Bool diff --git a/Sources/Algorithms/Partition.swift b/Sources/Algorithms/Partition.swift index 56fb8412a..647b5a744 100644 --- a/Sources/Algorithms/Partition.swift +++ b/Sources/Algorithms/Partition.swift @@ -22,6 +22,7 @@ extension MutableCollection { /// - Precondition: /// `n == distance(from: range.lowerBound, to: range.upperBound)` @inlinable + @discardableResult internal mutating func stablePartition( count n: Int, subrange: Range, @@ -63,6 +64,7 @@ extension MutableCollection { /// /// - Complexity: O(*n* log *n*), where *n* is the length of this collection. @inlinable + @discardableResult public mutating func stablePartition( subrange: Range, by belongsInSecondPartition: (Element) throws -> Bool @@ -87,6 +89,7 @@ extension MutableCollection { /// /// - Complexity: O(*n* log *n*), where *n* is the length of this collection. @inlinable + @discardableResult public mutating func stablePartition( by belongsInSecondPartition: (Element) throws -> Bool ) rethrows -> Index { @@ -122,6 +125,7 @@ extension MutableCollection { /// /// - Complexity: O(*n*) where n is the length of the collection. @inlinable + @discardableResult public mutating func partition( subrange: Range, by belongsInSecondPartition: (Element) throws -> Bool @@ -166,6 +170,7 @@ extension MutableCollection where Self: BidirectionalCollection { /// /// - Complexity: O(*n*) where n is the length of the collection. @inlinable + @discardableResult public mutating func partition( subrange: Range, by belongsInSecondPartition: (Element) throws -> Bool