Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SetAlgebra types] isEqual(to:) → isEqualSet(to:) #234

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

### Adding Elements

- ``append(_:)``
- ``append(_:)-8dqhn``
- ``append(contentsOf:)-18dwf``
- ``append(contentsOf:)-576q4``
- ``append(contentsOf:)-8xkr8``
- ``insert(_:at:)``
- ``insert(_:at:)-9t4hf``
- ``insert(contentsOf:at:)-7e1xn``
- ``insert(contentsOf:at:)-35dp3``
- ``insert(contentsOf:at:)-1wsgw``
Expand All @@ -46,8 +46,8 @@
- ``removeSubrange(_:)-18qe7``
- ``removeLast()``
- ``removeLast(_:)``
- ``removeFirst()``
- ``removeFirst(_:)``
- ``removeFirst()-dcsp``
- ``removeFirst(_:)-9nqlo``
- ``popLast()``

### Replacing Elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
### Binary Set Predicates

- ``==(_:_:)``
- ``isEqual(to:)-5bw9h``
- ``isEqual(to:)-8jxq5``
- ``isEqual(to:)-7w9qy``
- ``isEqual(to:)-9tnfo``
- ``isEqualSet(to:)-11031``
- ``isEqualSet(to:)-1hvpp``
- ``isEqualSet(to:)-1mvpq``
- ``isEqualSet(to:)-878x1``

- ``isSubset(of:)-8iy8c``
- ``isSubset(of:)-1r41b``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@
### Comparing Sets

- ``==(_:_:)``
- ``isEqual(to:)-5zfpo``
- ``isEqual(to:)-93d52``
- ``isEqual(to:)-542zl``
- ``isEqual(to:)-1d66i``
- ``isEqualSet(to:)-4xfa9``
- ``isEqualSet(to:)-359ao``
- ``isEqualSet(to:)-5ap6y``
- ``isEqualSet(to:)-2dezf``

- ``isSubset(of:)-73apg``
- ``isSubset(of:)-14xt1``
Expand Down
4 changes: 2 additions & 2 deletions Sources/BitCollections/BitSet/BitSet+Equatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ extension BitSet: Equatable {
/// Returns a Boolean value indicating whether two values are equal. Two
/// bit sets are considered equal if they contain the same elements.
///
/// - Note: This simply forwards to the ``isEqual(to:)-5zfpo`` method.
/// - Note: This simply forwards to the ``isEqualSet(to:)-4xfa9`` method.
/// That method has additional overloads that can be used to compare
/// bit sets with additional types.
///
/// - Complexity: O(*max*), where *max* is value of the largest member of
/// either set.
public static func ==(left: Self, right: Self) -> Bool {
left.isEqual(to: right)
left.isEqualSet(to: right)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension BitSet {
///
/// - Complexity: O(*max*), where *max* is value of the largest member of
/// either set.
public func isEqual(to other: Self) -> Bool {
public func isEqualSet(to other: Self) -> Bool {
self._storage == other._storage
}

Expand All @@ -27,18 +27,18 @@ extension BitSet {
///
/// - Complexity: O(*max*), where *max* is value of the largest member of
/// either set.
public func isEqual(to other: BitSet.Counted) -> Bool {
self.isEqual(to: other._bits)
public func isEqualSet(to other: BitSet.Counted) -> Bool {
self.isEqualSet(to: other._bits)
}

/// Returns a Boolean value indicating whether a bit set is equal to a range
/// of integers, i.e., whether they contain the same values.
///
/// - Complexity: O(min(*max*, `other.upperBound`), where *max* is the largest
/// member of `self`.
public func isEqual(to other: Range<Int>) -> Bool {
public func isEqualSet(to other: Range<Int>) -> Bool {
guard let other = other._toUInt() else { return false }
return _read { $0.isEqual(to: other) }
return _read { $0.isEqualSet(to: other) }
}

/// Returns a Boolean value indicating whether this bit set contains the same
Expand All @@ -50,18 +50,18 @@ extension BitSet {
/// let bits: BitSet = [0, 1, 5, 6]
/// let other = [5, 5, 0, 1, 1, 6, 5, 0, 1, 6, 6, 5]
///
/// bits.isEqual(to: other) // true
/// bits.isEqualSet(to: other) // true
///
/// - Complexity: O(*n*), where *n* is the number of items in `other`.
public func isEqual<S: Sequence>(to other: S) -> Bool where S.Element == Int {
public func isEqualSet<S: Sequence>(to other: S) -> Bool where S.Element == Int {
if S.self == Self.self {
return isEqual(to: other as! Self)
return isEqualSet(to: other as! Self)
}
if S.self == BitSet.Counted.self {
return isEqual(to: other as! BitSet.Counted)
return isEqualSet(to: other as! BitSet.Counted)
}
if S.self == Range<Int>.self {
return isEqual(to: other as! Range<Int>)
return isEqualSet(to: other as! Range<Int>)
}

if self.isEmpty {
Expand Down
18 changes: 9 additions & 9 deletions Sources/BitCollections/BitSet/BitSet.Counted.swift
Original file line number Diff line number Diff line change
Expand Up @@ -902,28 +902,28 @@ extension BitSet.Counted {
///
/// - Complexity: O(*max*), where *max* is value of the largest member of
/// either set.
public func isEqual(to other: Self) -> Bool {
public func isEqualSet(to other: Self) -> Bool {
guard self.count == other.count else { return false }
return self._bits.isEqual(to: other._bits)
return self._bits.isEqualSet(to: other._bits)
}

/// Returns a Boolean value indicating whether a bit set is equal to a counted
/// bit set, i.e., whether they contain the same values.
///
/// - Complexity: O(*max*), where *max* is value of the largest member of
/// either set.
public func isEqual(to other: BitSet) -> Bool {
self._bits.isEqual(to: other)
public func isEqualSet(to other: BitSet) -> Bool {
self._bits.isEqualSet(to: other)
}

/// Returns a Boolean value indicating whether a bit set is equal to a range
/// of integers, i.e., whether they contain the same values.
///
/// - Complexity: O(min(*max*, `other.upperBound`), where *max* is the largest
/// member of `self`.
public func isEqual(to other: Range<Int>) -> Bool {
public func isEqualSet(to other: Range<Int>) -> Bool {
guard self.count == other.count else { return false }
return _bits.isEqual(to: other)
return _bits.isEqualSet(to: other)
}

/// Returns a Boolean value indicating whether this bit set contains the same
Expand All @@ -935,15 +935,15 @@ extension BitSet.Counted {
/// let bits: BitSet = [0, 1, 5, 6]
/// let other = [5, 5, 0, 1, 1, 6, 5, 0, 1, 6, 6, 5]
///
/// bits.isEqual(to: other) // true
/// bits.isEqualSet(to: other) // true
///
/// - Complexity: O(*n*), where *n* is the number of items in `other`.
@inlinable
public func isEqual<S: Sequence>(to other: S) -> Bool
public func isEqualSet<S: Sequence>(to other: S) -> Bool
where S.Element == Int
{
guard self.count >= other.underestimatedCount else { return false }
return _bits.isEqual(to: other)
return _bits.isEqualSet(to: other)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/BitCollections/BitSet/BitSet._UnsafeHandle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ extension BitSet._UnsafeHandle {
return _words[upper.word].intersection(uw) == uw
}

internal func isEqual(to range: Range<UInt>) -> Bool {
internal func isEqualSet(to range: Range<UInt>) -> Bool {
if range.isEmpty { return self.isEmpty }
let r = range.clamped(to: 0 ..< UInt(capacity))
guard r == range else { return false }
Expand Down
2 changes: 1 addition & 1 deletion Sources/BitCollections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ add_library(BitCollections
"BitSet/BitSet+SetAlgebra formUnion.swift"
"BitSet/BitSet+SetAlgebra intersection.swift"
"BitSet/BitSet+SetAlgebra isDisjoint.swift"
"BitSet/BitSet+SetAlgebra isEqual.swift"
"BitSet/BitSet+SetAlgebra isEqualSet.swift"
"BitSet/BitSet+SetAlgebra isStrictSubset.swift"
"BitSet/BitSet+SetAlgebra isStrictSuperset.swift"
"BitSet/BitSet+SetAlgebra isSubset.swift"
Expand Down
8 changes: 4 additions & 4 deletions Sources/Collections/Collections.docc/Extensions/BitArray.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

### Adding Elements

- ``append(_:)``
- ``append(_:)-8dqhn``
- ``append(contentsOf:)-18dwf``
- ``append(contentsOf:)-576q4``
- ``append(contentsOf:)-8xkr8``
- ``insert(_:at:)``
- ``insert(_:at:)-9t4hf``
- ``insert(contentsOf:at:)-7e1xn``
- ``insert(contentsOf:at:)-35dp3``
- ``insert(contentsOf:at:)-1wsgw``
Expand All @@ -49,8 +49,8 @@
- ``removeSubrange(_:)-18qe7``
- ``removeLast()``
- ``removeLast(_:)``
- ``removeFirst()``
- ``removeFirst(_:)``
- ``removeFirst()-dcsp``
- ``removeFirst(_:)-9nqlo``
- ``popLast()``

### Replacing Elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@
### Binary Set Predicates

- ``==(_:_:)``
- ``isEqual(to:)-5bw9h``
- ``isEqual(to:)-8jxq5``
- ``isEqual(to:)-7w9qy``
- ``isEqual(to:)-9tnfo``
- ``isEqualSet(to:)-11031``
- ``isEqualSet(to:)-1hvpp``
- ``isEqualSet(to:)-1mvpq``
- ``isEqualSet(to:)-878x1``

- ``isSubset(of:)-8iy8c``
- ``isSubset(of:)-1r41b``
Expand Down
8 changes: 4 additions & 4 deletions Sources/Collections/Collections.docc/Extensions/BitSet.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@
### Comparing Sets

- ``==(_:_:)``
- ``isEqual(to:)-5zfpo``
- ``isEqual(to:)-93d52``
- ``isEqual(to:)-542zl``
- ``isEqual(to:)-1d66i``
- ``isEqualSet(to:)-4xfa9``
- ``isEqualSet(to:)-359ao``
- ``isEqualSet(to:)-5ap6y``
- ``isEqualSet(to:)-2dezf``

- ``isSubset(of:)-73apg``
- ``isSubset(of:)-14xt1``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,25 @@
### Binary Set Predicates

- ``==(_:_:)``
- ``isEqualSet(to:)-1szq``
- ``isEqualSet(to:)-9djqq``

- ``isSubset(of:)-n4t7``
- ``isSubset(of:)-2dx31``
- ``isSubset(of:)-801lo``
- ``isSubset(of:)-952h5``

- ``isSuperset(of:)-4ea6h``
- ``isSuperset(of:)-9t33p``
- ``isSuperset(of:)-2vtig``
- ``isSuperset(of:)-9krpz``

- ``isStrictSubset(of:)-33z0l``
- ``isStrictSubset(of:)-9o6mg``
- ``isStrictSubset(of:)-91par``
- ``isStrictSubset(of:)-7n66e``

- ``isStrictSuperset(of:)-8pbce``
- ``isStrictSuperset(of:)-89ig3``
- ``isStrictSuperset(of:)-1e0xt``
- ``isStrictSuperset(of:)-5dsfd``

- ``isDisjoint(with:)-7sbsg``
- ``isDisjoint(with:)-3wuso``
- ``isDisjoint(with:)-25vmx``
- ``isDisjoint(with:)-8nfqs``
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@
### Comparing Sets

- ``==(_:_:)``
- ``isEqual(to:)-69p52``
- ``isEqual(to:)-1xzfo``
- ``isEqual(to:)-3ab2q``
- ``isEqualSet(to:)-6zqj7``
- ``isEqualSet(to:)-34yz0``
- ``isEqualSet(to:)-2bhxr``

- ``isSubset(of:)-ptij``
- ``isSubset(of:)-3mw6r``
Expand Down Expand Up @@ -135,7 +135,7 @@

### Creating and Applying Differences

- ``difference(from:)``
- ``difference(from:)-30bkk``
- ``applying(_:)``

### Memory Management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ average -- typically they will need to compare against just one member.
### Comparing Sets

- ``==(_:_:)``
- ``isEqual(to:)-3m3in``
- ``isEqual(to:)-7mkn1``
- ``isEqual(to:)-5px5r``
- ``isEqualSet(to:)-7egih``
- ``isEqualSet(to:)-4t0k5``
- ``isEqualSet(to:)-7s0cu``

- ``isSubset(of:)-9mp7l``
- ``isSubset(of:)-2jlh``
Expand Down
2 changes: 1 addition & 1 deletion Sources/OrderedCollections/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ add_library(OrderedCollections
"OrderedSet/OrderedSet+Partial SetAlgebra formUnion.swift"
"OrderedSet/OrderedSet+Partial SetAlgebra intersection.swift"
"OrderedSet/OrderedSet+Partial SetAlgebra isDisjoint.swift"
"OrderedSet/OrderedSet+Partial SetAlgebra isEqual.swift"
"OrderedSet/OrderedSet+Partial SetAlgebra isEqualSet.swift"
"OrderedSet/OrderedSet+Partial SetAlgebra isStrictSubset.swift"
"OrderedSet/OrderedSet+Partial SetAlgebra isStrictSuperset.swift"
"OrderedSet/OrderedSet+Partial SetAlgebra isSubset.swift"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,25 @@
### Binary Set Predicates

- ``==(_:_:)``
- ``isEqualSet(to:)-1szq``
- ``isEqualSet(to:)-9djqq``

- ``isSubset(of:)-n4t7``
- ``isSubset(of:)-2dx31``
- ``isSubset(of:)-801lo``
- ``isSubset(of:)-952h5``

- ``isSuperset(of:)-4ea6h``
- ``isSuperset(of:)-9t33p``
- ``isSuperset(of:)-2vtig``
- ``isSuperset(of:)-9krpz``

- ``isStrictSubset(of:)-33z0l``
- ``isStrictSubset(of:)-9o6mg``
- ``isStrictSubset(of:)-91par``
- ``isStrictSubset(of:)-7n66e``

- ``isStrictSuperset(of:)-8pbce``
- ``isStrictSuperset(of:)-89ig3``
- ``isStrictSuperset(of:)-1e0xt``
- ``isStrictSuperset(of:)-5dsfd``

- ``isDisjoint(with:)-7sbsg``
- ``isDisjoint(with:)-3wuso``
- ``isDisjoint(with:)-25vmx``
- ``isDisjoint(with:)-8nfqs``
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
### Comparing Sets

- ``==(_:_:)``
- ``isEqual(to:)-69p52``
- ``isEqual(to:)-1xzfo``
- ``isEqual(to:)-3ab2q``
- ``isEqualSet(to:)-6zqj7``
- ``isEqualSet(to:)-34yz0``
- ``isEqualSet(to:)-2bhxr``

- ``isSubset(of:)-ptij``
- ``isSubset(of:)-3mw6r``
Expand Down Expand Up @@ -132,7 +132,7 @@

### Creating and Applying Differences

- ``difference(from:)``
- ``difference(from:)-30bkk``
- ``applying(_:)``

### Memory Management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension OrderedSet: Equatable {
/// elements in the same order.
///
/// - Note: This operator implements different behavior than the
/// `isEqual(to:)` method -- the latter implements an unordered
/// `isEqualSet(to:)` method -- the latter implements an unordered
/// comparison, to match the behavior of members like `isSubset(of:)`,
/// `isStrictSuperset(of:)` etc.
///
Expand Down
Loading