Skip to content

Commit 8f1c906

Browse files
committed
Rename duplicate-stripping functions
1 parent b4370c9 commit 8f1c906

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Sources/Algorithms/SortedDuplicates.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extension Sequence {
8585
///
8686
/// - Complexity: O(`n`), where *n* is the length of this sequence.
8787
@inlinable
88-
public func withoutSortedDuplicates(
88+
public func deduplicateSorted(
8989
by areInIncreasingOrder: (Element, Element) throws -> Bool
9090
) rethrows -> [Element] {
9191
try countSortedDuplicates(by: areInIncreasingOrder).map(\.value)
@@ -121,8 +121,8 @@ extension Sequence where Element: Comparable {
121121
///
122122
/// - Complexity: O(`n`), where *n* is the length of this sequence.
123123
@inlinable
124-
public func withoutSortedDuplicates() -> [Element] {
125-
withoutSortedDuplicates(by: <)
124+
public func deduplicateSorted() -> [Element] {
125+
deduplicateSorted(by: <)
126126
}
127127
}
128128

@@ -157,7 +157,7 @@ extension LazySequenceProtocol {
157157
/// - Returns: A sequence that lazily generates the first element of
158158
/// each equivalence class present in this sequence.
159159
@inlinable
160-
public func withoutSortedDuplicates(
160+
public func deduplicateSorted(
161161
by areInIncreasingOrder: @escaping (Element, Element) -> Bool
162162
) -> some (Sequence<Element> & LazySequenceProtocol) {
163163
countSortedDuplicates(by: areInIncreasingOrder).lazy.map(\.value)
@@ -188,10 +188,10 @@ extension LazySequenceProtocol where Element: Comparable {
188188
/// - Returns: A sequence that lazily generates the first element of
189189
/// each value.
190190
@inlinable
191-
public func withoutSortedDuplicates() -> some (
191+
public func deduplicateSorted() -> some (
192192
Sequence<Element> & LazySequenceProtocol
193193
) {
194-
withoutSortedDuplicates(by: <)
194+
deduplicateSorted(by: <)
195195
}
196196
}
197197

Tests/SwiftAlgorithmsTests/SortedDuplicatesTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@ final class SortedDuplicatesTests: XCTestCase {
2020
let emptyStringCounts = emptyString.countSortedDuplicates()
2121
expectEqualCollections(emptyStringCounts.map(\.value), [])
2222
expectEqualCollections(emptyStringCounts.map(\.count), [])
23-
expectEqualCollections(emptyString.withoutSortedDuplicates(), [])
23+
expectEqualCollections(emptyString.deduplicateSorted(), [])
2424

2525
let lazyEmptyStringCounts = emptyString.lazy.countSortedDuplicates()
2626
expectEqualSequences(lazyEmptyStringCounts.map(\.value), [])
2727
expectEqualSequences(lazyEmptyStringCounts.map(\.count), [])
28-
expectEqualSequences(emptyString.lazy.withoutSortedDuplicates(), [])
28+
expectEqualSequences(emptyString.lazy.deduplicateSorted(), [])
2929
}
3030

3131
/// Test counting over a single-element sequence.
3232
func testSingle() {
3333
let aString = "a"
3434
let aStringCounts = aString.countSortedDuplicates()
35-
let aStringValues = aString.withoutSortedDuplicates()
35+
let aStringValues = aString.deduplicateSorted()
3636
expectEqualCollections(aStringCounts.map(\.value), ["a"])
3737
expectEqualCollections(aStringCounts.map(\.count), [1])
3838
expectEqualCollections(aStringValues, ["a"])
3939

4040
let lazyAStringCounts = aString.lazy.countSortedDuplicates()
4141
expectEqualSequences(lazyAStringCounts.map(\.value), ["a"])
4242
expectEqualSequences(lazyAStringCounts.map(\.count), [1])
43-
expectEqualSequences(aString.lazy.withoutSortedDuplicates(), ["a"])
43+
expectEqualSequences(aString.lazy.deduplicateSorted(), ["a"])
4444
}
4545

4646
/// Test counting over a repeated element.
@@ -51,10 +51,10 @@ final class SortedDuplicatesTests: XCTestCase {
5151
let lazyLettersCounts = letters.lazy.countSortedDuplicates()
5252
expectEqualCollections(lettersCounts.map(\.value), ["b"])
5353
expectEqualCollections(lettersCounts.map(\.count), [count])
54-
expectEqualCollections(letters.withoutSortedDuplicates(), ["b"])
54+
expectEqualCollections(letters.deduplicateSorted(), ["b"])
5555
expectEqualSequences(lazyLettersCounts.map(\.value), ["b"])
5656
expectEqualSequences(lazyLettersCounts.map(\.count), [count])
57-
expectEqualSequences(letters.lazy.withoutSortedDuplicates(), ["b"])
57+
expectEqualSequences(letters.lazy.deduplicateSorted(), ["b"])
5858
}
5959

6060
/// Test multiple elements.
@@ -72,11 +72,11 @@ final class SortedDuplicatesTests: XCTestCase {
7272
]
7373
expectEqualCollections(sampleCounts.map(\.value), expected.map(\.0))
7474
expectEqualCollections(sampleCounts.map(\.count), expected.map(\.1))
75-
expectEqualCollections(sample.withoutSortedDuplicates(), "Xacdfxz")
75+
expectEqualCollections(sample.deduplicateSorted(), "Xacdfxz")
7676

7777
let lazySampleCounts = sample.lazy.countSortedDuplicates()
7878
expectEqualSequences(lazySampleCounts.map(\.value), expected.map(\.0))
7979
expectEqualSequences(lazySampleCounts.map(\.count), expected.map(\.1))
80-
expectEqualSequences(sample.lazy.withoutSortedDuplicates(), "Xacdfxz")
80+
expectEqualSequences(sample.lazy.deduplicateSorted(), "Xacdfxz")
8181
}
8282
}

0 commit comments

Comments
 (0)