[OrderedCollections] Adopt modern generic declaration syntax and _specialize

This commit is contained in:
Karoy Lorentey committed 2024-02-02 16:20:21 -08:00
1 parent 540348f147
commit f59aeeb56a
25 files changed
+157 -176

No files matched your search

@@ -511,8 +511,8 @@ extension OrderedDictionary.Elements {
/// change when your program is compiled using a different version of
/// Swift.
@inlinable
public mutating func shuffle<T: RandomNumberGenerator>(
using generator: inout T
public mutating func shuffle(
using generator: inout some RandomNumberGenerator
) {
_base.shuffle(using: &generator)
}
@@ -585,9 +585,9 @@ extension OrderedDictionary.Elements {
///
/// - Complexity: O(`count`)
@inlinable
public mutating func removeSubrange<R: RangeExpression>(
_ bounds: R
) where R.Bound == Int {
public mutating func removeSubrange(
_ bounds: some RangeExpression<Int>
) {
_base.removeSubrange(bounds)
}
@@ -9,6 +9,10 @@
//
//===----------------------------------------------------------------------===//
#if !COLLECTIONS_SINGLE_MODULE
import _CollectionsUtilities
#endif
extension OrderedDictionary {
/// Creates an empty dictionary.
///
@@ -77,10 +81,12 @@ extension OrderedDictionary {
/// key-value pairs, if `Key` implements high-quality hashing.
@_disfavoredOverload // https://github.com/apple/swift-collections/issues/125
@inlinable
public init<S: Sequence>(
uniqueKeysWithValues keysAndValues: S
) where S.Element == (key: Key, value: Value) {
if S.self == Dictionary<Key, Value>.self {
public init(
uniqueKeysWithValues keysAndValues: some Sequence<(key: Key, value: Value)>
) {
if let keysAndValues = _specialize(
keysAndValues, for: Dictionary<Key, Value>.self
) {
self.init(_uncheckedUniqueKeysWithValues: keysAndValues)
return
}
@@ -113,9 +119,9 @@ extension OrderedDictionary {
/// - Complexity: Expected O(*n*) on average, where *n* is the count if
/// key-value pairs, if `Key` implements high-quality hashing.
@inlinable
public init<S: Sequence>(
uniqueKeysWithValues keysAndValues: S
) where S.Element == (Key, Value) {
public init(
uniqueKeysWithValues keysAndValues: some Sequence<(Key, Value)>
) {
self.init()
reserveCapacity(keysAndValues.underestimatedCount)
for (key, value) in keysAndValues {
@@ -148,10 +154,10 @@ extension OrderedDictionary {
/// - Complexity: Expected O(*n*) on average, where *n* is the count if
/// key-value pairs, if `Key` implements high-quality hashing.
@inlinable
public init<Keys: Sequence, Values: Sequence>(
uniqueKeys keys: Keys,
values: Values
) where Keys.Element == Key, Values.Element == Value {
public init(
uniqueKeys keys: some Sequence<Key>,
values: some Sequence<Value>
) {
let keys = ContiguousArray(keys)
let values = ContiguousArray(values)
precondition(keys.count == values.count,
@@ -199,10 +205,10 @@ extension OrderedDictionary {
@_disfavoredOverload // https://github.com/apple/swift-collections/issues/125
@inlinable
@inline(__always)
public init<S: Sequence>(
_ keysAndValues: S,
public init(
_ keysAndValues: some Sequence<(key: Key, value: Value)>,
uniquingKeysWith combine: (Value, Value) throws -> Value
) rethrows where S.Element == (key: Key, value: Value) {
) rethrows {
self.init()
try self.merge(keysAndValues, uniquingKeysWith: combine)
}
@@ -241,10 +247,10 @@ extension OrderedDictionary {
/// key-value pairs, if `Key` implements high-quality hashing.
@inlinable
@inline(__always)
public init<S: Sequence>(
_ keysAndValues: S,
public init(
_ keysAndValues: some Sequence<(Key, Value)>,
uniquingKeysWith combine: (Value, Value) throws -> Value
) rethrows where S.Element == (Key, Value) {
) rethrows {
self.init()
try self.merge(keysAndValues, uniquingKeysWith: combine)
}
@@ -337,9 +343,10 @@ extension OrderedDictionary {
extension OrderedDictionary {
@inlinable
internal init<S: Sequence>(
_uncheckedUniqueKeysWithValues keysAndValues: S
) where S.Element == (key: Key, value: Value) {
internal init(
_uncheckedUniqueKeysWithValues keysAndValues:
some Sequence<(key: Key, value: Value)>
) {
self.init()
reserveCapacity(keysAndValues.underestimatedCount)
for (key, value) in keysAndValues {
@@ -372,9 +379,10 @@ extension OrderedDictionary {
/// key-value pairs, if `Key` implements high-quality hashing.
@_disfavoredOverload // https://github.com/apple/swift-collections/issues/125
@inlinable
public init<S: Sequence>(
uncheckedUniqueKeysWithValues keysAndValues: S
) where S.Element == (key: Key, value: Value) {
public init(
uncheckedUniqueKeysWithValues keysAndValues:
some Sequence<(key: Key, value: Value)>
) {
#if DEBUG
self.init(uniqueKeysWithValues: keysAndValues)
#else
@@ -404,9 +412,9 @@ extension OrderedDictionary {
/// - Complexity: Expected O(*n*) on average, where *n* is the count if
/// key-value pairs, if `Key` implements high-quality hashing.
@inlinable
public init<S: Sequence>(
uncheckedUniqueKeysWithValues keysAndValues: S
) where S.Element == (Key, Value) {
public init(
uncheckedUniqueKeysWithValues keysAndValues: some Sequence<(Key, Value)>
) {
// Add tuple labels
let keysAndValues = keysAndValues.lazy.map { (key: $0.0, value: $0.1) }
self.init(uncheckedUniqueKeysWithValues: keysAndValues)
@@ -439,10 +447,10 @@ extension OrderedDictionary {
/// key-value pairs, if `Key` implements high-quality hashing.
@inlinable
@inline(__always)
public init<Keys: Sequence, Values: Sequence>(
uncheckedUniqueKeys keys: Keys,
values: Values
) where Keys.Element == Key, Values.Element == Value {
public init(
uncheckedUniqueKeys keys: some Sequence<Key>,
values: some Sequence<Value>
) {
#if DEBUG
self.init(uniqueKeys: keys, values: values)
#else
@@ -160,8 +160,8 @@ extension OrderedDictionary {
/// change when your program is compiled using a different version of
/// Swift.
@inlinable
public mutating func shuffle<T: RandomNumberGenerator>(
using generator: inout T
public mutating func shuffle(
using generator: inout some RandomNumberGenerator
) {
guard count > 1 else { return }
var keys = self._keys.elements
@@ -93,9 +93,9 @@ extension OrderedDictionary {
///
/// - Complexity: O(`count`)
@inlinable
public mutating func removeSubrange<R: RangeExpression>(
_ bounds: R
) where R.Bound == Int {
public mutating func removeSubrange(
_ bounds: some RangeExpression<Int>
) {
removeSubrange(bounds.relative(to: elements))
}
@@ -819,10 +819,10 @@ extension OrderedDictionary {
/// elements in `keysAndValues`, if `Key` implements high-quality hashing.
@_disfavoredOverload // https://github.com/apple/swift-collections/issues/125
@inlinable
public mutating func merge<S: Sequence>(
_ keysAndValues: __owned S,
public mutating func merge(
_ keysAndValues: __owned some Sequence<(key: Key, value: Value)>,
uniquingKeysWith combine: (Value, Value) throws -> Value
) rethrows where S.Element == (key: Key, value: Value) {
) rethrows {
for (key, value) in keysAndValues {
let (index, bucket) = _keys._find(key)
if let index = index {
@@ -869,10 +869,10 @@ extension OrderedDictionary {
/// - Complexity: Expected to be O(*n*) on average, where *n* is the number of
/// elements in `keysAndValues`, if `Key` implements high-quality hashing.
@inlinable
public mutating func merge<S: Sequence>(
_ keysAndValues: __owned S,
public mutating func merge(
_ keysAndValues: __owned some Sequence<(Key, Value)>,
uniquingKeysWith combine: (Value, Value) throws -> Value
) rethrows where S.Element == (Key, Value) {
) rethrows {
let mapped: LazyMapSequence =
keysAndValues.lazy.map { (key: $0.0, value: $0.1) }
try merge(mapped, uniquingKeysWith: combine)
@@ -915,10 +915,10 @@ extension OrderedDictionary {
/// hashing.
@_disfavoredOverload // https://github.com/apple/swift-collections/issues/125
@inlinable
public __consuming func merging<S: Sequence>(
_ other: __owned S,
public __consuming func merging(
_ other: __owned some Sequence<(key: Key, value: Value)>,
uniquingKeysWith combine: (Value, Value) throws -> Value
) rethrows -> Self where S.Element == (key: Key, value: Value) {
) rethrows -> Self {
var copy = self
try copy.merge(other, uniquingKeysWith: combine)
return copy
@@ -960,10 +960,10 @@ extension OrderedDictionary {
/// number of elements in `keysAndValues`, if `Key` implements high-quality
/// hashing.
@inlinable
public __consuming func merging<S: Sequence>(
_ other: __owned S,
public __consuming func merging(
_ other: __owned some Sequence<(Key, Value)>,
uniquingKeysWith combine: (Value, Value) throws -> Value
) rethrows -> Self where S.Element == (Key, Value) {
) rethrows -> Self {
var copy = self
try copy.merge(other, uniquingKeysWith: combine)
return copy
@@ -32,8 +32,7 @@ extension OrderedSet {
/// high-quality hashing.
@inlinable
@inline(__always)
public init<S: Sequence>(uncheckedUniqueElements elements: S)
where S.Element == Element {
public init(uncheckedUniqueElements elements: some Sequence<Element>) {
let elements = ContiguousArray<Element>(elements)
#if DEBUG
let (table, firstDupe) = _HashTable.create(untilFirstDuplicateIn: elements)
@@ -61,9 +60,9 @@ extension OrderedSet {
/// is the number of elements in the sequence), provided that
/// `Element` properly implements hashing.
@inlinable
public init<S: Sequence>(_ elements: S) where S.Element == Element {
if S.self == Self.self {
self = elements as! Self
public init(_ elements: some Sequence<Element>) {
if let elements = _specialize(elements, for: Self.self) {
self = elements
return
}
// Fast paths for when we know elements are all unique
@@ -136,9 +135,7 @@ extension OrderedSet {
/// in the sequence), provided that `Element` implements
/// high-quality hashing.
@inlinable
public init<C: RandomAccessCollection>(
_ elements: C
) where C.Element == Element {
public init(_ elements: some RandomAccessCollection<Element>) {
// This code is careful not to copy storage if `C` is an Array
// or ContiguousArray and the elements are already unique.
let (table, firstDupe) = _HashTable.create(
@@ -62,7 +62,9 @@ extension OrderedSet {
@inlinable
@discardableResult
internal mutating func _append(_ item: Element) -> (inserted: Bool, index: Int) {
internal mutating func _append(
_ item: Element
) -> (inserted: Bool, index: Int) {
let (index, bucket) = _find(item)
if let index = index { return (false, index) }
_appendNew(item, in: bucket)
@@ -102,9 +104,9 @@ extension OrderedSet {
/// hash, and compare operations on the `Element` type, if it implements
/// high-quality hashing.
@inlinable
public mutating func append<S: Sequence>(
contentsOf elements: S
) where S.Element == Element {
public mutating func append(
contentsOf elements: some Sequence<Element>
) {
for item in elements {
_append(item)
}
@@ -332,8 +332,8 @@ extension OrderedSet {
/// change when your program is compiled using a different version of
/// Swift.
@inlinable
public mutating func shuffle<T: RandomNumberGenerator>(
using generator: inout T
public mutating func shuffle(
using generator: inout some RandomNumberGenerator
) {
_elements.shuffle(using: &generator)
_regenerateExistingHashTable()
@@ -111,9 +111,7 @@ extension OrderedSet {
///
/// - Complexity: O(`count`)
@inlinable
public mutating func removeSubrange<R: RangeExpression>(
_ bounds: R
) where R.Bound == Int {
public mutating func removeSubrange(_ bounds: some RangeExpression<Int>) {
removeSubrange(bounds.relative(to: self))
}
@@ -77,9 +77,9 @@ extension OrderedSet {
/// - Complexity: Expected to be O(*n*) on average where *n* is the number of
/// elements in `other`, if `Element` implements high-quality hashing.
@inlinable
public mutating func formIntersection<S: Sequence>(
_ other: S
) where S.Element == Element {
public mutating func formIntersection(
_ other: some Sequence<Element>
) {
self = self.intersection(other)
}
}
@@ -79,9 +79,9 @@ extension OrderedSet {
/// the number of elements in `other`, if `Element` implements high-quality
/// hashing.
@inlinable
public mutating func formSymmetricDifference<S: Sequence>(
_ other: __owned S
) where S.Element == Element {
public mutating func formSymmetricDifference(
_ other: __owned some Sequence<Element>
) {
self = self.symmetricDifference(other)
}
}
@@ -94,9 +94,9 @@ extension OrderedSet {
/// - Complexity: Expected to be O(`self.count` + `other.count`) on average,
/// if `Element` implements high-quality hashing.
@inlinable
public mutating func formUnion<S: Sequence>(
_ other: __owned S
) where S.Element == Element {
public mutating func formUnion(
_ other: __owned some Sequence<Element>
) {
append(contentsOf: other)
}
}
@@ -94,9 +94,9 @@ extension OrderedSet {
/// - Complexity: Expected to be O(*n*) on average where *n* is the number of
/// elements in `other`, if `Element` implements high-quality hashing.
@inlinable
public __consuming func intersection<S: Sequence>(
_ other: S
) -> Self where S.Element == Element {
public __consuming func intersection(
_ other: some Sequence<Element>
) -> Self {
_UnsafeBitSet.withTemporaryBitSet(capacity: self.count) { bitset in
for item in other {
if let index = self._find_inlined(item).index {
@@ -118,9 +118,9 @@ extension OrderedSet {
/// - Complexity: Expected to be O(*n*) on average, where *n* is the number of
/// elements in `other`, if `Element` implements high-quality hashing.
@inlinable
public func isDisjoint<S: Sequence>(
with other: S
) -> Bool where S.Element == Element {
public func isDisjoint(
with other: some Sequence<Element>
) -> Bool {
guard !self.isEmpty else { return true }
for item in other {
if self.contains(item) { return false }
@@ -46,10 +46,9 @@ extension OrderedSet {
///
/// - Complexity: O(*n*), where *n* is the number of items in
/// `other`, as long as`Element` properly implements hashing.
public func isEqualSet<S: Sequence>(to other: S) -> Bool
where S.Element == Element {
if S.self == Self.self {
return isEqualSet(to: other as! Self)
public func isEqualSet(to other: some Sequence<Element>) -> Bool {
if let other = _specialize(other, for: Self.self) {
return isEqualSet(to: other)
}
if self.isEmpty {
@@ -67,7 +66,7 @@ extension OrderedSet {
precondition(
seen <= self.count,
// Otherwise other.underestimatedCount != other.count
"Invalid Collection '\(S.self)' (bad underestimatedCount)")
"Invalid Collection '\(type(of: other))' (bad underestimatedCount)")
return seen == self.count
}
@@ -115,14 +115,14 @@ extension OrderedSet {
/// is the number of elements in `other`, if `Element` implements
/// high-quality hashing.
@inlinable
public func isStrictSubset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
if S.self == Self.self {
return self.isStrictSubset(of: other as! Self)
public func isStrictSubset(
of other: some Sequence<Element>
) -> Bool {
if let other = _specialize(other, for: Self.self) {
return self.isStrictSubset(of: other)
}
if S.self == Set<Element>.self {
return self.isStrictSubset(of: other as! Set<Element>)
if let other = _specialize(other, for: Set<Element>.self) {
return self.isStrictSubset(of: other)
}
var it = self.makeIterator()
@@ -116,14 +116,14 @@ extension OrderedSet {
/// is the number of elements in `other`, if `Element` implements
/// high-quality hashing.
@inlinable
public func isStrictSuperset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
if S.self == Self.self {
return self.isStrictSuperset(of: other as! Self)
public func isStrictSuperset(
of other: some Sequence<Element>
) -> Bool {
if let other = _specialize(other, for: Self.self) {
return self.isStrictSuperset(of: other)
}
if S.self == Set<Element>.self {
return self.isStrictSuperset(of: other as! Set<Element>)
if let other = _specialize(other, for: Set<Element>.self) {
return self.isStrictSuperset(of: other)
}
var it = self.makeIterator()
@@ -115,13 +115,13 @@ extension OrderedSet {
/// is the number of elements in `other`, if `Element` implements
/// high-quality hashing.
@inlinable
public func isSubset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
public func isSubset(
of other: some Sequence<Element>
) -> Bool {
guard !isEmpty else { return true }
if S.self == Self.self {
return isSubset(of: other as! Self)
if let other = _specialize(other, for: Self.self) {
return isSubset(of: other)
}
var it = self.makeIterator()
@@ -9,6 +9,10 @@
//
//===----------------------------------------------------------------------===//
#if !COLLECTIONS_SINGLE_MODULE
import _CollectionsUtilities
#endif
// `OrderedSet` does not directly conform to `SetAlgebra` because its definition
// of equality conflicts with `SetAlgebra` requirements. However, it still
// implements most `SetAlgebra` requirements (except `insert`, which is replaced
@@ -103,18 +107,14 @@ extension OrderedSet {
/// - Complexity: Expected to be O(*n*) on average, where *n* is the number of
/// elements in `other`, if `Element` implements high-quality hashing.
@inlinable
public func isSuperset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
public func isSuperset(of other: some Sequence<Element>) -> Bool {
_isSuperset(of: other)
}
@inlinable
internal func _isSuperset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
if S.self == Self.self {
return self.isSuperset(of: other as! Self)
internal func _isSuperset(of other: some Sequence<Element>) -> Bool {
if let other = _specialize(other, for: Self.self) {
return self.isSuperset(of: other)
}
for item in other {
guard self.contains(item) else { return false }
@@ -68,9 +68,7 @@ extension OrderedSet {
/// high-quality hashing.
@inlinable
@inline(__always)
public mutating func subtract<S: Sequence>(
_ other: S
) where S.Element == Element {
public mutating func subtract(_ other: some Sequence<Element>) {
self = _subtracting(other)
}
}
@@ -83,16 +83,12 @@ extension OrderedSet {
/// `Element` implements high-quality hashing.
@inlinable
@inline(__always)
public __consuming func subtracting<S: Sequence>(
_ other: S
) -> Self where S.Element == Element {
public __consuming func subtracting(_ other: some Sequence<Element>) -> Self {
_subtracting(other)
}
@inlinable
__consuming func _subtracting<S: Sequence>(
_ other: S
) -> Self where S.Element == Element {
__consuming func _subtracting(_ other: some Sequence<Element>) -> Self {
guard count > 0 else { return Self() }
return _UnsafeBitSet.withTemporaryBitSet(capacity: count) { difference in
difference.insertAll(upTo: count)
@@ -113,9 +113,9 @@ extension OrderedSet {
/// the number of elements in `other`, if `Element` implements high-quality
/// hashing.
@inlinable
public __consuming func symmetricDifference<S: Sequence>(
_ other: __owned S
) -> Self where S.Element == Element {
public __consuming func symmetricDifference(
_ other: __owned some Sequence<Element>
) -> Self {
_UnsafeBitSet.withTemporaryBitSet(capacity: self.count) { bitset in
var new = Self()
bitset.insertAll(upTo: self.count)
@@ -74,9 +74,9 @@ extension OrderedSet {
/// - Complexity: Expected to be O(`self.count` + `other.count`) on average,
/// if `Element` implements high-quality hashing.
@inlinable
public __consuming func union<S: Sequence>(
_ other: __owned S
) -> Self where S.Element == Element {
public __consuming func union(
_ other: __owned some Sequence<Element>
) -> Self {
var result = self
result.formUnion(other)
return result
@@ -110,11 +110,11 @@ extension OrderedSet._UnstableInternals {
extension OrderedSet {
@_spi(Testing)
public init<S: Sequence>(
public init(
_scale scale: Int,
bias: Int,
contents: S
) where S.Element == Element {
contents: some Sequence<Element>
) {
let contents = ContiguousArray(contents)
precondition(scale >= _HashTable.scale(forCapacity: contents.count))
precondition(scale <= _HashTable.maximumScale)
@@ -167,7 +167,7 @@ extension OrderedSet.UnorderedView {
/// high-quality hashing.
@inlinable
@inline(__always)
public init<S: Sequence>(_ elements: S) where S.Element == Element {
public init(_ elements: some Sequence<Element>) {
_base = OrderedSet(elements)
}
@@ -368,9 +368,7 @@ extension OrderedSet.UnorderedView {
/// - Complexity: Expected to be O(`other.count`) on average, if `Element`
/// implements high-quality hashing.
@inlinable
public mutating func formUnion<S: Sequence>(
_ other: __owned S
) where S.Element == Element {
public mutating func formUnion(_ other: __owned some Sequence<Element>) {
_base.formUnion(other)
}
@@ -387,9 +385,9 @@ extension OrderedSet.UnorderedView {
/// - Complexity: Expected to be O(`self.count` + `other.count`) on average,
/// if `Element` implements high-quality hashing.
@inlinable
public __consuming func union<S: Sequence>(
_ other: __owned S
) -> Self where S.Element == Element {
public __consuming func union(
_ other: __owned some Sequence<Element>
) -> Self {
_base.union(other).unordered
}
}
@@ -444,9 +442,9 @@ extension OrderedSet.UnorderedView {
/// - Complexity: Expected to be O(*n*) on average where *n* is the number of
/// elements in `other`, if `Element` implements high-quality hashing.
@inlinable
public __consuming func intersection<S: Sequence>(
_ other: S
) -> Self where S.Element == Element {
public __consuming func intersection(
_ other: some Sequence<Element>
) -> Self {
_base.intersection(other).unordered
}
@@ -461,9 +459,9 @@ extension OrderedSet.UnorderedView {
/// - Complexity: Expected to be O(*n*) on average where *n* is the number of
/// elements in `other`, if `Element` implements high-quality hashing.
@inlinable
public mutating func formIntersection<S: Sequence>(
_ other: S
) where S.Element == Element {
public mutating func formIntersection(
_ other: some Sequence<Element>
) {
_base.formIntersection(other)
}
}
@@ -529,9 +527,9 @@ extension OrderedSet.UnorderedView {
/// the number of elements in `other`, if `Element` implements high-quality
/// hashing.
@inlinable
public __consuming func symmetricDifference<S: Sequence>(
_ other: __owned S
) -> Self where S.Element == Element {
public __consuming func symmetricDifference(
_ other: __owned some Sequence<Element>
) -> Self {
_base.symmetricDifference(other).unordered
}
@@ -552,9 +550,9 @@ extension OrderedSet.UnorderedView {
/// the number of elements in `other`, if `Element` implements high-quality
/// hashing.
@inlinable
public mutating func formSymmetricDifference<S: Sequence>(
_ other: __owned S
) where S.Element == Element {
public mutating func formSymmetricDifference(
_ other: __owned some Sequence<Element>
) {
_base.formSymmetricDifference(other)
}
}
@@ -613,9 +611,7 @@ extension OrderedSet.UnorderedView {
/// - Complexity: Expected to be O(`self.count + other.count`) on average, if
/// `Element` implements high-quality hashing.
@inlinable
public __consuming func subtracting<S: Sequence>(
_ other: S
) -> Self where S.Element == Element {
public __consuming func subtracting(_ other: some Sequence<Element>) -> Self {
_base.subtracting(other).unordered
}
@@ -631,9 +627,7 @@ extension OrderedSet.UnorderedView {
/// is the number of elements in `other`, if `Element` implements
/// high-quality hashing.
@inlinable
public mutating func subtract<S: Sequence>(
_ other: S
) where S.Element == Element {
public mutating func subtract(_ other: some Sequence<Element>) {
_base.subtract(other)
}
}
@@ -662,8 +656,7 @@ extension OrderedSet.UnorderedView {
///
/// - Complexity: O(*n*), where *n* is the number of items in
/// `other`, as long as`Element` properly implements hashing.
public func isEqualSet<S: Sequence>(to other: S) -> Bool
where S.Element == Element {
public func isEqualSet(to other: some Sequence<Element>) -> Bool {
self._base.isEqualSet(to: other)
}
}
@@ -731,9 +724,7 @@ extension OrderedSet.UnorderedView {
/// is the number of elements in `other`, if `Element` implements
/// high-quality hashing.
@inlinable
public func isSubset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
public func isSubset(of other: some Sequence<Element>) -> Bool {
_base.isSubset(of: other)
}
}
@@ -800,9 +791,7 @@ extension OrderedSet.UnorderedView {
/// - Complexity: Expected to be O(*n*) on average, where *n* is the number of
/// elements in `other`, if `Element` implements high-quality hashing.
@inlinable
public func isSuperset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
public func isSuperset(of other: some Sequence<Element>) -> Bool {
_base.isSuperset(of: other)
}
}
@@ -876,9 +865,7 @@ extension OrderedSet.UnorderedView {
/// is the number of elements in `other`, if `Element` implements
/// high-quality hashing.
@inlinable
public func isStrictSubset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
public func isStrictSubset(of other: some Sequence<Element>) -> Bool {
_base.isStrictSubset(of: other)
}
}
@@ -952,9 +939,7 @@ extension OrderedSet.UnorderedView {
/// is the number of elements in `other`, if `Element` implements
/// high-quality hashing.
@inlinable
public func isStrictSuperset<S: Sequence>(
of other: S
) -> Bool where S.Element == Element {
public func isStrictSuperset(of other: some Sequence<Element>) -> Bool {
_base.isStrictSuperset(of: other)
}
}
@@ -1015,9 +1000,7 @@ extension OrderedSet.UnorderedView {
/// - Complexity: Expected to be O(*n*) on average, where *n* is the number of
/// elements in `other`, if `Element` implements high-quality hashing.
@inlinable
public func isDisjoint<S: Sequence>(
with other: S
) -> Bool where S.Element == Element {
public func isDisjoint(with other: some Sequence<Element>) -> Bool {
_base.isDisjoint(with: other)
}
}