File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -636,4 +636,25 @@ extension _NativeSet {
636
636
return false
637
637
}
638
638
}
639
+
640
+ @_alwaysEmitIntoClient
641
+ internal func isStrictSuperset< S: Sequence > ( of possibleSubset: S ) -> Bool
642
+ where S. Element == Element {
643
+ _UnsafeBitset. withTemporaryBitset ( capacity: self . bucketCount) { seen in
644
+ // Mark elements in self that we've seen in `possibleStrictSubset`.
645
+ var seenCount = 0
646
+ for element in possibleSubset {
647
+ let ( bucket, found) = find ( element)
648
+ guard found else { return false }
649
+ let inserted = seen. uncheckedInsert ( bucket. offset)
650
+ if inserted {
651
+ seenCount += 1
652
+ if seenCount == self . count {
653
+ return false
654
+ }
655
+ }
656
+ }
657
+ return true
658
+ }
659
+ }
639
660
}
Original file line number Diff line number Diff line change @@ -796,8 +796,11 @@ extension Set: SetAlgebra {
796
796
@inlinable
797
797
public func isStrictSuperset< S: Sequence > ( of possibleStrictSubset: S ) -> Bool
798
798
where S. Element == Element {
799
- let other = Set ( possibleStrictSubset)
800
- return other. isStrictSubset ( of: self )
799
+ if isEmpty { return false }
800
+ if let s = possibleStrictSubset as? Set < Element > {
801
+ return isStrictSuperset ( of: s)
802
+ }
803
+ return _variant. convertedToNative. isStrictSuperset ( of: possibleStrictSubset)
801
804
}
802
805
803
806
/// Returns a Boolean value that indicates whether the set has no members in
@@ -1191,7 +1194,7 @@ extension Set {
1191
1194
/// `other`; otherwise, `false`.
1192
1195
@inlinable
1193
1196
public func isStrictSuperset( of other: Set < Element > ) -> Bool {
1194
- return self . isSuperset ( of : other) && self != other
1197
+ return self . count > other. count && other. isSubset ( of : self )
1195
1198
}
1196
1199
1197
1200
/// Returns a Boolean value that indicates whether the set is a strict subset
You can’t perform that action at this time.
0 commit comments