diff --git a/Sources/SortedCollections/SortedSet/SortedSet+SetAlgebra.swift b/Sources/SortedCollections/SortedSet/SortedSet+SetAlgebra.swift index 77923e40..0a852a17 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+SetAlgebra.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+SetAlgebra.swift @@ -380,9 +380,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public func union(_ other: __owned some Sequence) -> Self { if let other = other as? Self { @@ -395,9 +393,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public mutating func formUnion(_ other: __owned some Sequence) { self = union(other) @@ -408,9 +404,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public func intersection(_ other: some Sequence) -> Self { if let other = other as? Self { @@ -423,9 +417,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public mutating func formIntersection(_ other: some Sequence) { self = intersection(other) @@ -436,9 +428,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public func symmetricDifference( _ other: __owned some Sequence @@ -454,9 +444,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public mutating func formSymmetricDifference( _ other: __owned some Sequence @@ -469,9 +457,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public __consuming func subtracting( _ other: some Sequence @@ -486,9 +472,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public mutating func subtract(_ other: some Sequence) { self = subtracting(other) @@ -501,9 +485,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public func isSubset(of other: some Sequence) -> Bool { if let other = other as? Self { @@ -517,9 +499,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. + /// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public func isStrictSubset(of other: some Sequence) -> Bool { if let other = other as? Self { @@ -533,8 +513,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`other.count` log `self.count`) in the worst case; - /// O(`self.count` + `other.count`) when `other` is a `SortedSet`. + /// - Complexity: O(`n` * log(`self.count`)), where `n` is the length of `other`. @inlinable public func isSuperset(of other: some Sequence) -> Bool { if let other = other as? Self { @@ -548,9 +527,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`self.count` + `other.count`) when `other` is a - /// `SortedSet`; otherwise the sequence is first collected into a - /// temporary sorted set. +/// - Complexity: O(`self.count` + `n` * log(`n`)) where `n` is the length of `other`. @inlinable public func isStrictSuperset(of other: some Sequence) -> Bool { if let other = other as? Self { @@ -564,8 +541,7 @@ extension SortedSet { /// /// - Parameter other: An arbitrary finite sequence of elements, possibly /// containing duplicates. - /// - Complexity: O(`other.count` log `self.count`) in the worst case; - /// O(`self.count` + `other.count`) when `other` is a `SortedSet`. + /// - Complexity: O(`n` * log(`self.count`)) where `n` is the length of `other`. @inlinable public func isDisjoint(with other: some Sequence) -> Bool { guard !self.isEmpty else { return true } diff --git a/Tests/SortedCollectionsTests/SortedSet/SortedSet+SetAlgebra Sequence Tests.swift b/Tests/SortedCollectionsTests/SortedSet/SortedSet+SetAlgebra Sequence Tests.swift index 86576aa5..e2e7b316 100644 --- a/Tests/SortedCollectionsTests/SortedSet/SortedSet+SetAlgebra Sequence Tests.swift +++ b/Tests/SortedCollectionsTests/SortedSet/SortedSet+SetAlgebra Sequence Tests.swift @@ -21,10 +21,6 @@ import SortedCollections import _CollectionsTestSupport #endif -// Regression tests for https://github.com/apple/swift-collections/issues/743: -// SortedSet's set operations must accept arbitrary sequences, not just -// another SortedSet. Satisfying this shape is also what lets SortedSet -// conform to SetAPIChecker. extension SortedSet: SetAPIChecker {} class SortedSetSequenceOperationTests: CollectionTestCase {