mirror of
https://github.com/apple/swift-collections
synced 2026-11-22 04:20:40 +00:00
[doc] Fix most issues reported by docc
DocC keeps changing its link syntax. The latest iteration appears to have trouble dealing with `Self`-taking or `Self`-returning methods, so change our API to replace `Self` with a direct mention of the concrete type. ¯\\\_(ツ)\_/¯ That said, the new compiler also found a large number of mismatching parameter names, and that was really helpful.
This commit is contained in:
67 files changed
+187
-277
No files matched your search
@@ -21,8 +21,8 @@ extension BitArray: Equatable {
|
||||
/// Equality is the inverse of inequality. For any values `a` and `b`,
|
||||
/// `a == b` implies that `a != b` is `false`.
|
||||
///
|
||||
/// - Parameter lhs: A value to compare.
|
||||
/// - Parameter rhs: Another value to compare.
|
||||
/// - Parameter left: A value to compare.
|
||||
/// - Parameter right: Another value to compare.
|
||||
/// - Complexity: O(left.count)
|
||||
public static func ==(left: Self, right: Self) -> Bool {
|
||||
guard left._count == right._count else { return false }
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
### Accessing Elements
|
||||
|
||||
- ``subscript(position:)`
|
||||
- ``subscript(_:)``
|
||||
- ``first``
|
||||
- ``last``
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
- ``remove(at:)``
|
||||
- ``removeAll(keepingCapacity:)``
|
||||
- ``removeAll(where:)``
|
||||
- ``removeAll(where:)-4izxo``
|
||||
- ``removeSubrange(_:)``
|
||||
- ``removeLast()``
|
||||
- ``removeLast(_:)``
|
||||
|
||||
@@ -51,42 +51,42 @@
|
||||
|
||||
### Binary Set Operations
|
||||
|
||||
- ``intersection(_:)-(Self)``
|
||||
- ``intersection(_:)-(BitSet.Counted)``
|
||||
- ``intersection(_:)-(BitSet)``
|
||||
- ``intersection(_:)-(Range<Int>)``
|
||||
- ``intersection(_:)-(Sequence<Int>)
|
||||
- ``intersection(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``union(_:)-(Self)``
|
||||
- ``union(_:)-(BitSet.Counted)``
|
||||
- ``union(_:)-(BitSet)``
|
||||
- ``union(_:)-(Range<Int>)``
|
||||
- ``union(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``subtracting(_:)-(Self)``
|
||||
- ``subtracting(_:)-(BitSet.Counted)``
|
||||
- ``subtracting(_:)-(BitSet)``
|
||||
- ``subtracting(_:)-(Range<Int>)``
|
||||
- ``subtracting(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``symmetricDifference(_:)-(Self)``
|
||||
- ``symmetricDifference(_:)-(BitSet.Counted)``
|
||||
- ``symmetricDifference(_:)-(BitSet)``
|
||||
- ``symmetricDifference(_:)-(Range<Int>)``
|
||||
- ``symmetricDifference(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``formIntersection(_:)-(Self)``
|
||||
- ``formIntersection(_:)-(BitSet.Counted)``
|
||||
- ``formIntersection(_:)-(BitSet)``
|
||||
- ``formIntersection(_:)-(Range<Int>)``
|
||||
- ``formIntersection(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``formUnion(_:)-(Self)``
|
||||
- ``formUnion(_:)-(BitSet.Counted)``
|
||||
- ``formUnion(_:)-(BitSet)``
|
||||
- ``formUnion(_:)-(Range<Int>)``
|
||||
- ``formUnion(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``subtract(_:)-(Self)``
|
||||
- ``subtract(_:)-(BitSet.Counted)``
|
||||
- ``subtract(_:)-(BitSet)``
|
||||
- ``subtract(_:)-(Range<Int>)``
|
||||
- ``subtract(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``formSymmetricDifference(_:)-(Self)``
|
||||
- ``formSymmetricDifference(_:)-(BitSet.Counted)``
|
||||
- ``formSymmetricDifference(_:)-(BitSet)``
|
||||
- ``formSymmetricDifference(_:)-(Range<Int>)``
|
||||
- ``formSymmetricDifference(_:)-(Sequence<Int>)``
|
||||
@@ -94,32 +94,32 @@
|
||||
### Binary Set Predicates
|
||||
|
||||
- ``==(_:_:)``
|
||||
- ``isEqualSet(to:)-(Self)``
|
||||
- ``isEqualSet(to:)-(BitSet.Counted)``
|
||||
- ``isEqualSet(to:)-(BitSet)``
|
||||
- ``isEqualSet(to:)-(Range<Int>)``
|
||||
- ``isEqualSet(to:)-(Sequence<Int>)``
|
||||
|
||||
- ``isSubset(of:)-(Self)``
|
||||
- ``isSubset(of:)-(BitSet.Counted)``
|
||||
- ``isSubset(of:)-(BitSet)``
|
||||
- ``isSubset(of:)-(Range<Int>)``
|
||||
- ``isSubset(of:)-(Sequence<Int>)``
|
||||
|
||||
- ``isSuperset(of:)-(Self)``
|
||||
- ``isSuperset(of:)-(BitSet.Counted)``
|
||||
- ``isSuperset(of:)-(BitSet)``
|
||||
- ``isSuperset(of:)-(Range<Int>)``
|
||||
- ``isSuperset(of:)-(Sequence<Int>)``
|
||||
|
||||
- ``isStrictSubset(of:)-(Self)``
|
||||
- ``isStrictSubset(of:)-(BitSet.Counted)``
|
||||
- ``isStrictSubset(of:)-(BitSet)``
|
||||
- ``isStrictSubset(of:)-(Range<Int>)``
|
||||
- ``isStrictSubset(of:)-(Sequence<Int>)``
|
||||
|
||||
- ``isStrictSuperset(of:)-(Self)``
|
||||
- ``isStrictSuperset(of:)-(BitSet.Counted)``
|
||||
- ``isStrictSuperset(of:)-(BitSet)``
|
||||
- ``isStrictSuperset(of:)-(Range<Int>)``
|
||||
- ``isStrictSuperset(of:)-(Sequence<Int>)``
|
||||
|
||||
- ``isDisjoint(with:)-(Self)``
|
||||
- ``isDisjoint(with:)-(BitSet.Counted)``
|
||||
- ``isDisjoint(with:)-(BitSet)``
|
||||
- ``isDisjoint(with:)-(Range<Int>)``
|
||||
- ``isDisjoint(with:)-(Sequence<Int>)``
|
||||
@@ -38,7 +38,6 @@
|
||||
|
||||
### Sorted Set Operations
|
||||
|
||||
- ``subscript(position:)``
|
||||
- ``subscript(member:)``
|
||||
- ``subscript(members:)-(RangeExpression<Int>)``
|
||||
- ``subscript(members:)-(Range<Int>)``
|
||||
@@ -48,27 +47,27 @@
|
||||
|
||||
### Combining Sets
|
||||
|
||||
- ``intersection(_:)-(Self)``
|
||||
- ``intersection(_:)-(BitSet)``
|
||||
- ``intersection(_:)-(Range<Int>)``
|
||||
- ``intersection(_:)-(BitSet.Counted)``
|
||||
- ``intersection(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``union(_:)-(Self)``
|
||||
- ``union(_:)-(BitSet)``
|
||||
- ``union(_:)-(Range<Int>)``
|
||||
- ``union(_:)-(BitSet.Counted)``
|
||||
- ``union(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``subtracting(_:)-(Self)``
|
||||
- ``subtracting(_:)-(BitSet)``
|
||||
- ``subtracting(_:)-(Range<Int>)``
|
||||
- ``subtracting(_:)-(BitSet.Counted)``
|
||||
- ``subtracting(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``symmetricDifference(_:)-(Self)``
|
||||
- ``symmetricDifference(_:)-(BitSet)``
|
||||
- ``symmetricDifference(_:)-(Range<Int>)``
|
||||
- ``symmetricDifference(_:)-(Counted)``
|
||||
- ``symmetricDifference(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``formIntersection(_:)-(Self)``
|
||||
- ``formIntersection(_:)-(BitSet)``
|
||||
- ``formIntersection(_:)-(Range<Int>)``
|
||||
- ``formIntersection(_:)-(BitSet.Counted)``
|
||||
- ``formIntersection(_:)-(Sequence<Int>)``
|
||||
@@ -83,7 +82,7 @@
|
||||
- ``subtract(_:)-(BitSet.Counted)``
|
||||
- ``subtract(_:)-(Sequence<Int>)``
|
||||
|
||||
- ``formSymmetricDifference(_:)-(Self)``
|
||||
- ``formSymmetricDifference(_:)-(BitSet)``
|
||||
- ``formSymmetricDifference(_:)-(Range<Int>)``
|
||||
- ``formSymmetricDifference(_:)-(BitSet.Counted)``
|
||||
- ``formSymmetricDifference(_:)-(Sequence<Int>)``
|
||||
@@ -91,17 +90,17 @@
|
||||
### Comparing Sets
|
||||
|
||||
- ``==(_:_:)``
|
||||
- ``isEqualSet(to:)-(Self)``
|
||||
- ``isEqualSet(to:)-(BitSet)``
|
||||
- ``isEqualSet(to:)-(Range<Int>)``
|
||||
- ``isEqualSet(to:)-(BitSet.Counted)``
|
||||
- ``isEqualSet(to:)-(Sequence<Int>)``
|
||||
|
||||
- ``isSubset(of:)-(Self)``
|
||||
- ``isSubset(of:)-(BitSet)``
|
||||
- ``isSubset(of:)-(Range<Int>)``
|
||||
- ``isSubset(of:)-(BitSet.Counted)``
|
||||
- ``isSubset(of:)-(Sequence<Int>)``
|
||||
|
||||
- ``isSuperset(of:)-(Self)
|
||||
- ``isSuperset(of:)-(Self)``
|
||||
- ``isSuperset(of:)-(Range<Int>)``
|
||||
- ``isSuperset(of:)-(BitSet.Counted)``
|
||||
- ``isSuperset(of:)-(Sequence<Int>)``
|
||||
@@ -116,7 +115,7 @@
|
||||
- ``isStrictSuperset(of:)-(BitSet.Counted)``
|
||||
- ``isStrictSuperset(of:)-(Sequence<Int>)``
|
||||
|
||||
- ``isDisjoint(with:)-(Self)
|
||||
- ``isDisjoint(with:)-(Self)``
|
||||
- ``isDisjoint(with:)-(Range<Int>)``
|
||||
- ``isDisjoint(with:)-(BitSet.Counted)``
|
||||
- ``isDisjoint(with:)-(Sequence<Int>)``
|
||||
|
||||
@@ -212,9 +212,9 @@ extension BitSet: Collection, BidirectionalCollection {
|
||||
/// the collection.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - i: A valid index of the collection.
|
||||
/// - distance: The distance to offset `i`.
|
||||
/// - Returns: An index offset by `distance` from the index `i`. If
|
||||
/// - index: A valid index of the collection.
|
||||
/// - distance: The distance to offset `index`.
|
||||
/// - Returns: An index offset by `distance` from `index`. If
|
||||
/// `distance` is positive, this is the same value as the result of
|
||||
/// `distance` calls to `index(after:)`. If `distance` is negative, this
|
||||
/// is the same value as the result of `abs(distance)` calls to
|
||||
|
||||
@@ -151,7 +151,7 @@ extension BitSet {
|
||||
extension BitSet {
|
||||
/// Removes and returns the element at the specified position.
|
||||
///
|
||||
/// - Parameter i: The position of the element to remove. `index` must be
|
||||
/// - Parameter index: The position of the element to remove. `index` must be
|
||||
/// a valid index of the collection that is not equal to the collection's
|
||||
/// end index.
|
||||
///
|
||||
|
||||
@@ -32,7 +32,7 @@ extension BitSet {
|
||||
/// Returns a Boolean value that indicates whether the given element exists
|
||||
/// in the set.
|
||||
///
|
||||
/// - Parameter element: An element to look for in the set.
|
||||
/// - Parameter member: An element to look for in the set.
|
||||
///
|
||||
/// - Returns: `true` if `member` exists in the set; otherwise, `false`.
|
||||
///
|
||||
|
||||
@@ -26,7 +26,7 @@ extension BitSet {
|
||||
/// - Parameter other: A bit set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either set.
|
||||
public mutating func formIntersection(_ other: Self) {
|
||||
public mutating func formIntersection(_ other: BitSet) {
|
||||
other._read { source in
|
||||
if source.wordCount < _storage.count {
|
||||
self._storage.removeLast(_storage.count - source.wordCount)
|
||||
|
||||
@@ -27,7 +27,7 @@ extension BitSet {
|
||||
/// - Parameter other: Another set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either set.
|
||||
public mutating func formSymmetricDifference(_ other: Self) {
|
||||
public mutating func formSymmetricDifference(_ other: BitSet) {
|
||||
_ensureCapacity(limit: other._capacity)
|
||||
_updateThenShrink { target, shrink in
|
||||
other._read { source in
|
||||
|
||||
@@ -26,7 +26,7 @@ extension BitSet {
|
||||
/// - Parameter other: The set of elements to insert.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public mutating func formUnion(_ other: Self) {
|
||||
public mutating func formUnion(_ other: BitSet) {
|
||||
_ensureCapacity(limit: other._capacity)
|
||||
_update { target in
|
||||
other._read { source in
|
||||
|
||||
@@ -27,7 +27,7 @@ extension BitSet {
|
||||
/// - Parameter other: A bit set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either set.
|
||||
public func intersection(_ other: Self) -> Self {
|
||||
public func intersection(_ other: BitSet) -> BitSet {
|
||||
self._read { first in
|
||||
other._read { second in
|
||||
Self(
|
||||
@@ -49,7 +49,7 @@ extension BitSet {
|
||||
/// - Parameter other: A bit set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either set.
|
||||
public func intersection(_ other: BitSet.Counted) -> Self {
|
||||
public func intersection(_ other: BitSet.Counted) -> BitSet {
|
||||
self.intersection(other._bits)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ extension BitSet {
|
||||
///
|
||||
/// - Complexity: O(*max*) + *k*, where *max* is the largest item in `self`,
|
||||
/// and *k* is the complexity of iterating over all elements in `other`.
|
||||
public func intersection(_ other: Range<Int>) -> Self {
|
||||
public func intersection(_ other: Range<Int>) -> BitSet {
|
||||
var result = self
|
||||
result.formIntersection(other)
|
||||
return result
|
||||
@@ -83,7 +83,7 @@ extension BitSet {
|
||||
/// - Complexity: O(*max*) + *k*, where *max* is the largest item in `self`,
|
||||
/// and *k* is the complexity of iterating over all elements in `other`.
|
||||
@inlinable
|
||||
public func intersection(_ other: __owned some Sequence<Int>) -> Self {
|
||||
public func intersection(_ other: __owned some Sequence<Int>) -> BitSet {
|
||||
if let other = _specialize(other, for: Range<Int>.self) {
|
||||
return intersection(other)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ extension BitSet {
|
||||
/// otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public func isDisjoint(with other: Self) -> Bool {
|
||||
public func isDisjoint(with other: BitSet) -> Bool {
|
||||
self._read { first in
|
||||
other._read { second in
|
||||
let w1 = first._words
|
||||
|
||||
@@ -22,7 +22,7 @@ extension BitSet {
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is value of the largest member of
|
||||
/// either set.
|
||||
public func isEqualSet(to other: Self) -> Bool {
|
||||
public func isEqualSet(to other: BitSet) -> Bool {
|
||||
self._storage == other._storage
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ extension BitSet {
|
||||
/// otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in `self`.
|
||||
public func isStrictSubset(of other: Self) -> Bool {
|
||||
public func isStrictSubset(of other: BitSet) -> Bool {
|
||||
self._read { first in
|
||||
other._read { second in
|
||||
let w1 = first._words
|
||||
|
||||
@@ -35,7 +35,7 @@ extension BitSet {
|
||||
/// - Returns: `true` if the set is a superset of `other`; otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in `other`.
|
||||
public func isStrictSuperset(of other: Self) -> Bool {
|
||||
public func isStrictSuperset(of other: BitSet) -> Bool {
|
||||
other.isStrictSubset(of: self)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ extension BitSet {
|
||||
/// - Returns: `true` if the set is a subset of `other`; otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in `self`.
|
||||
public func isSubset(of other: Self) -> Bool {
|
||||
public func isSubset(of other: BitSet) -> Bool {
|
||||
self._read { first in
|
||||
other._read { second in
|
||||
let w1 = first._words
|
||||
|
||||
@@ -34,7 +34,7 @@ extension BitSet {
|
||||
/// - Returns: `true` if the set is a superset of `other`; otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in `other`.
|
||||
public func isSuperset(of other: Self) -> Bool {
|
||||
public func isSuperset(of other: BitSet) -> Bool {
|
||||
other.isSubset(of: self)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ extension BitSet {
|
||||
/// - Parameter other: Another bit set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public mutating func subtract(_ other: Self) {
|
||||
public mutating func subtract(_ other: BitSet) {
|
||||
_updateThenShrink { target, shrink in
|
||||
other._read { source in
|
||||
target.combineSharedPrefix(
|
||||
@@ -59,8 +59,6 @@ extension BitSet {
|
||||
///
|
||||
/// - Parameter other: A range of arbitrary integers.
|
||||
///
|
||||
/// - Returns: A new set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in self.
|
||||
public mutating func subtract(_ other: Range<Int>) {
|
||||
_subtract(other._clampedToUInt())
|
||||
|
||||
@@ -28,7 +28,7 @@ extension BitSet {
|
||||
/// - Returns: A new set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public func subtracting(_ other: Self) -> Self {
|
||||
public func subtracting(_ other: BitSet) -> BitSet {
|
||||
self._read { first in
|
||||
other._read { second in
|
||||
Self(
|
||||
@@ -51,7 +51,7 @@ extension BitSet {
|
||||
/// - Returns: A new set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public func subtracting(_ other: BitSet.Counted) -> Self {
|
||||
public func subtracting(_ other: BitSet.Counted) -> BitSet {
|
||||
subtracting(other._bits)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ extension BitSet {
|
||||
/// - Returns: A new set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in self.
|
||||
public func subtracting(_ other: Range<Int>) -> Self {
|
||||
public func subtracting(_ other: Range<Int>) -> BitSet {
|
||||
var result = self
|
||||
result.subtract(other)
|
||||
return result
|
||||
@@ -86,7 +86,7 @@ extension BitSet {
|
||||
/// - Complexity: O(*max*) + *k*, where *max* is the largest item in `self`,
|
||||
/// and *k* is the complexity of iterating over all elements in `other`.
|
||||
@inlinable
|
||||
public func subtracting(_ other: __owned some Sequence<Int>) -> Self {
|
||||
public func subtracting(_ other: __owned some Sequence<Int>) -> BitSet {
|
||||
var result = self
|
||||
result.subtract(other)
|
||||
return result
|
||||
|
||||
@@ -28,7 +28,7 @@ extension BitSet {
|
||||
/// - Returns: A new set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either set.
|
||||
public func symmetricDifference(_ other: Self) -> Self {
|
||||
public func symmetricDifference(_ other: BitSet) -> BitSet {
|
||||
self._read { first in
|
||||
other._read { second in
|
||||
Self(
|
||||
@@ -51,7 +51,7 @@ extension BitSet {
|
||||
/// - Returns: A new set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either set.
|
||||
public func symmetricDifference(_ other: Counted) -> Self {
|
||||
public func symmetricDifference(_ other: Counted) -> BitSet {
|
||||
symmetricDifference(other._bits)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ extension BitSet {
|
||||
/// - Returns: A new set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public func symmetricDifference(_ other: Range<Int>) -> Self {
|
||||
public func symmetricDifference(_ other: Range<Int>) -> BitSet {
|
||||
var result = self
|
||||
result.formSymmetricDifference(other)
|
||||
return result
|
||||
@@ -87,7 +87,7 @@ extension BitSet {
|
||||
@inlinable
|
||||
public func symmetricDifference(
|
||||
_ other: __owned some Sequence<Int>
|
||||
) -> Self {
|
||||
) -> BitSet {
|
||||
if let other = _specialize(other, for: Range<Int>.self) {
|
||||
return symmetricDifference(other)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ extension BitSet {
|
||||
/// - Parameter other: The set of elements to insert.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public func union(_ other: Self) -> Self {
|
||||
public func union(_ other: BitSet) -> BitSet {
|
||||
self._read { first in
|
||||
other._read { second in
|
||||
Self(
|
||||
@@ -45,7 +45,7 @@ extension BitSet {
|
||||
/// - Parameter other: The set of elements to insert.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public func union(_ other: BitSet.Counted) -> Self {
|
||||
public func union(_ other: BitSet.Counted) -> BitSet {
|
||||
union(other._bits)
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ extension BitSet {
|
||||
/// - Parameter other: A range of nonnegative integers.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public func union(_ other: Range<Int>) -> Self {
|
||||
public func union(_ other: Range<Int>) -> BitSet {
|
||||
var result = self
|
||||
result.formUnion(other)
|
||||
return result
|
||||
@@ -77,7 +77,7 @@ extension BitSet {
|
||||
/// input, and *k* is the complexity of iterating over all elements in
|
||||
/// `other`.
|
||||
@inlinable
|
||||
public func union(_ other: __owned some Sequence<Int>) -> Self {
|
||||
public func union(_ other: __owned some Sequence<Int>) -> BitSet {
|
||||
if let other = _specialize(other, for: BitSet.self) {
|
||||
return union(other)
|
||||
}
|
||||
|
||||
@@ -866,8 +866,6 @@ extension BitSet.Counted {
|
||||
///
|
||||
/// - Parameter other: A range of arbitrary integers.
|
||||
///
|
||||
/// - Returns: A new set.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in self.
|
||||
public mutating func subtract(_ other: Range<Int>) {
|
||||
_bits.subtract(other)
|
||||
@@ -902,7 +900,7 @@ extension BitSet.Counted {
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is value of the largest member of
|
||||
/// either set.
|
||||
public func isEqualSet(to other: Self) -> Bool {
|
||||
public func isEqualSet(to other: BitSet.Counted) -> Bool {
|
||||
guard self.count == other.count else { return false }
|
||||
return self._bits.isEqualSet(to: other._bits)
|
||||
}
|
||||
@@ -964,7 +962,7 @@ extension BitSet.Counted {
|
||||
/// - Returns: `true` if the set is a subset of `other`; otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in `self`.
|
||||
public func isSubset(of other: Self) -> Bool {
|
||||
public func isSubset(of other: BitSet.Counted) -> Bool {
|
||||
if self.count > other.count { return false }
|
||||
return self._bits.isSubset(of: other._bits)
|
||||
}
|
||||
@@ -1047,7 +1045,7 @@ extension BitSet.Counted {
|
||||
/// - Returns: `true` if the set is a superset of `other`; otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in `other`.
|
||||
public func isSuperset(of other: Self) -> Bool {
|
||||
public func isSuperset(of other: BitSet.Counted) -> Bool {
|
||||
other.isSubset(of: self)
|
||||
}
|
||||
|
||||
@@ -1131,7 +1129,7 @@ extension BitSet.Counted {
|
||||
/// otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in `self`.
|
||||
public func isStrictSubset(of other: Self) -> Bool {
|
||||
public func isStrictSubset(of other: BitSet.Counted) -> Bool {
|
||||
guard self.count < other.count else { return false }
|
||||
return _bits.isStrictSubset(of: other._bits)
|
||||
}
|
||||
@@ -1222,7 +1220,7 @@ extension BitSet.Counted {
|
||||
/// - Returns: `true` if the set is a superset of `other`; otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in `other`.
|
||||
public func isStrictSuperset(of other: Self) -> Bool {
|
||||
public func isStrictSuperset(of other: BitSet.Counted) -> Bool {
|
||||
other.isStrictSubset(of: self)
|
||||
}
|
||||
|
||||
@@ -1300,7 +1298,7 @@ extension BitSet.Counted {
|
||||
/// otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: O(*max*), where *max* is the largest item in either input.
|
||||
public func isDisjoint(with other: Self) -> Bool {
|
||||
public func isDisjoint(with other: BitSet.Counted) -> Bool {
|
||||
_bits.isDisjoint(with: other._bits)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,96 +1,9 @@
|
||||
# ``BasicContainers/RigidArray``
|
||||
# ``ContainersPreview/Box``
|
||||
|
||||
## Topics
|
||||
|
||||
### Creating a rigid array
|
||||
|
||||
- ``init()``
|
||||
- ``init(capacity:)``
|
||||
- ``init(capacity:initializingWith:)``
|
||||
- ``init(repeating:count:)``
|
||||
- ``init(capacity:copying:)-(_,Sequence<Element>)``
|
||||
- ``init(capacity:copying:)-(_,Collection<Element>)``
|
||||
|
||||
### Inspecting a rigid array
|
||||
|
||||
- ``isEmpty``
|
||||
- ``isFull``
|
||||
- ``count``
|
||||
- ``capacity``
|
||||
- ``freeCapacity``
|
||||
|
||||
### Indices
|
||||
|
||||
- ``startIndex``
|
||||
- ``endIndex``
|
||||
- ``indices``
|
||||
|
||||
### Accessing elements
|
||||
|
||||
- ``subscript(position:)``
|
||||
- ``swapAt(_:_:)``
|
||||
- ``edit(_:)``
|
||||
|
||||
### Memory management
|
||||
|
||||
- ``reallocate(capacity:)``
|
||||
- ``reserveCapacity(_:)``
|
||||
- ``copy()``
|
||||
- ``copy(capacity:)``
|
||||
|
||||
### Spans
|
||||
|
||||
- ``init(_:)``
|
||||
- ``subscript()``
|
||||
- ``consume()``
|
||||
- ``span``
|
||||
- ``span(after:)``
|
||||
- ``span(before:)``
|
||||
- ``mutableSpan``
|
||||
- ``mutableSpan(after:)``
|
||||
- ``mutableSpan(before:)``
|
||||
|
||||
### Appending items
|
||||
|
||||
- ``append(_:)``
|
||||
- ``pushLast(_:)``
|
||||
- ``append(count:initializingWith:)``
|
||||
- ``append(moving:)-(UnsafeMutableBufferPointer<Element>)``
|
||||
- ``append(moving:)-(OutputSpan<Element>)``
|
||||
- ``append(moving:)-(RigidArray<Element>)``
|
||||
- ``append(copying:)-(Sequence<Element>)``
|
||||
- ``append(copying:)-(Span<Element>)``
|
||||
- ``append(copying:)-(UnsafeBufferPointer<Element>)``
|
||||
- ``append(copying:)-(UnsafeMutableBufferPointer<Element>)``
|
||||
|
||||
### Inserting items
|
||||
|
||||
- ``insert(_:at:)``
|
||||
- ``insert(count:at:initializingWith:)``
|
||||
- ``insert(moving:at:)-(OutputSpan<Element>,_)``
|
||||
- ``insert(moving:at:)-(RigidArray<Element>,_)``
|
||||
- ``insert(moving:at:)-(UnsafeMutableBufferPointer<Element>,_)``
|
||||
- ``insert(consuming:at:)``
|
||||
- ``insert(copying:at:)-(Collection<Element>,_)``
|
||||
- ``insert(copying:at:)-(Span<Element>,_)``
|
||||
- ``insert(copying:at:)-(UnsafeBufferPointer<Element>,_)``
|
||||
- ``insert(copying:at:)-(UnsafeMutableBufferPointer<Element>,_)``
|
||||
|
||||
### Replacing items
|
||||
|
||||
- ``replaceSubrange(_:newCount:initializingWith:)``
|
||||
- ``replaceSubrange(_:moving:)-(_,OutputSpan<Element>)``
|
||||
- ``replaceSubrange(_:moving:)-(_,RigidArray<Element>))``
|
||||
- ``replaceSubrange(_:moving:)-(_,UnsafeMutableBufferPointer<Element>)``
|
||||
- ``replaceSubrange(_:consuming:)``
|
||||
- ``replaceSubrange(_:copying:)-(_,Collection<Element>)``
|
||||
- ``replaceSubrange(_:copying:)-(_,Span<Element>)``
|
||||
- ``replaceSubrange(_:copying:)-(_,UnsafeBufferPointer<Element>)``
|
||||
- ``replaceSubrange(_:copying:)-(_,UnsafeMutableBufferPointer<Element>)``
|
||||
|
||||
### Removing items
|
||||
|
||||
- ``removeAll()``
|
||||
- ``removeLast()``
|
||||
- ``popLast()``
|
||||
- ``removeLast(_:)``
|
||||
- ``remove(at:)``
|
||||
- ``removeSubrange(_:)-(Range<Int>)``
|
||||
- ``removeSubrange(_:)-(RangeExpression<Int>)``
|
||||
@@ -274,8 +274,8 @@ extension Deque: RandomAccessCollection {
|
||||
/// the collection.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - i: A valid index of the deque.
|
||||
/// - `distance`: The distance by which to offset `i`.
|
||||
/// - i: A valid index of the deque.
|
||||
/// - distance: The distance by which to offset `i`.
|
||||
///
|
||||
/// - Returns: An index offset by `distance` from the index `i`. If `distance`
|
||||
/// is positive, this is the same value as the result of `distance` calls
|
||||
|
||||
@@ -31,8 +31,8 @@ extension Deque {
|
||||
/// the requested number of elements.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - unsafeUninitializedCapacity: The number of elements to allocate
|
||||
/// space for in the new deque.
|
||||
/// - capacity: The number of elements to allocate space for in the new
|
||||
/// deque.
|
||||
/// - initializer: A closure that initializes elements and sets the count
|
||||
/// of the new deque.
|
||||
/// - Parameters:
|
||||
|
||||
@@ -30,9 +30,9 @@ extension RigidDeque where Element: ~Copyable {
|
||||
/// - Complexity: O(1)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func append(_ newElement: consuming Element) {
|
||||
public mutating func append(_ item: consuming Element) {
|
||||
precondition(!isFull, "RigidDeque capacity overflow")
|
||||
_handle.uncheckedAppend(newElement)
|
||||
_handle.uncheckedAppend(item)
|
||||
}
|
||||
|
||||
/// Adds an element to the end of the deque, if possible.
|
||||
|
||||
@@ -161,7 +161,9 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// derived from the collection's count.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - contents: The contents whose contents to copy into the new deque.
|
||||
/// - capacity: The desired capacity of the new deque, or nil to allocate
|
||||
/// just enough storage to fit the contents.
|
||||
/// - contents: The collection whose contents to copy into the new deque.
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init(
|
||||
|
||||
@@ -30,9 +30,9 @@ extension RigidDeque where Element: ~Copyable {
|
||||
/// - Complexity: O(1)
|
||||
@_alwaysEmitIntoClient
|
||||
@_transparent
|
||||
public mutating func prepend(_ newElement: consuming Element) {
|
||||
public mutating func prepend(_ item: consuming Element) {
|
||||
precondition(!isFull, "RigidDeque capacity overflow")
|
||||
_handle.uncheckedPrepend(newElement)
|
||||
_handle.uncheckedPrepend(item)
|
||||
}
|
||||
|
||||
/// Adds an element to the front of the deque, if possible.
|
||||
|
||||
@@ -26,7 +26,7 @@ extension RigidDeque where Element: ~Copyable {
|
||||
/// gap left by the removed item. (The direction of the move depends on the
|
||||
/// location of the removal, minimizing the cost.)
|
||||
///
|
||||
/// - Parameter i: The position of the element to remove. `index` must be
|
||||
/// - Parameter index: The position of the element to remove. `index` must be
|
||||
/// a valid index of the deque that is not equal to the end index.
|
||||
/// - Returns: The removed element.
|
||||
///
|
||||
@@ -98,11 +98,11 @@ extension RigidDeque where Element: ~Copyable {
|
||||
/// Attempting to remove more elements than exist in the deque
|
||||
/// triggers a runtime error.
|
||||
///
|
||||
/// - Parameter k: The number of elements to remove from the deque.
|
||||
/// `k` must be greater than or equal to zero and must not exceed
|
||||
/// - Parameter n: The number of elements to remove from the deque.
|
||||
/// `n` must be greater than or equal to zero and must not exceed
|
||||
/// the count of the deque.
|
||||
///
|
||||
/// - Complexity: O(`k`)
|
||||
/// - Complexity: O(`n`)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func removeLast(_ n: Int) {
|
||||
precondition(n >= 0, "Cannot remove a negative number of elements")
|
||||
|
||||
@@ -92,7 +92,7 @@ public struct RigidDeque<Element: ~Copyable>: ~Copyable {
|
||||
///
|
||||
/// It is possible to extend or shrink the capacity of a rigid deque instance,
|
||||
/// but this needs to be done explicitly, with operations dedicated to this
|
||||
/// purpose (such as ``reserveCapacity`` and ``reallocate(capacity:)``).
|
||||
/// purpose (such as ``reserveCapacity(_:)`` and ``reallocate(capacity:)``).
|
||||
/// The deque never resizes itself automatically.
|
||||
///
|
||||
/// Therefore, it is necessary to perform careful manual analysis (or up front
|
||||
|
||||
@@ -31,9 +31,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
/// - Complexity: O(1) as amortized over many invocations on the same deque.
|
||||
@_alwaysEmitIntoClient
|
||||
@_transparent
|
||||
public mutating func append(_ newElement: consuming Element) {
|
||||
public mutating func append(_ item: consuming Element) {
|
||||
_ensureFreeCapacity(1)
|
||||
_storage._handle.uncheckedAppend(newElement)
|
||||
_storage._handle.uncheckedAppend(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
/// - Complexity: O(1) when amortized over many invocations on the same deque.
|
||||
@_alwaysEmitIntoClient
|
||||
@_transparent
|
||||
public mutating func prepend(_ newElement: consuming Element) {
|
||||
public mutating func prepend(_ item: consuming Element) {
|
||||
_ensureFreeCapacity(1)
|
||||
_storage._handle.uncheckedPrepend(newElement)
|
||||
_storage._handle.uncheckedPrepend(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
/// gap left by the removed item. (The direction of the move depends on the
|
||||
/// location of the removal, minimizing the cost.)
|
||||
///
|
||||
/// - Parameter i: The position of the element to remove. `index` must be
|
||||
/// - Parameter index: The position of the element to remove. `index` must be
|
||||
/// a valid index of the deque that is not equal to the end index.
|
||||
/// - Returns: The removed element.
|
||||
///
|
||||
|
||||
@@ -250,7 +250,7 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
/// buffer of the specified capacity, moving all existing elements
|
||||
/// to its new storage. The old storage is then deallocated.
|
||||
///
|
||||
/// - Parameter newCapacity: The desired new capacity. `newCapacity` must be
|
||||
/// - Parameter capacity: The desired new capacity. `capacity` must be
|
||||
/// greater than or equal to the current count.
|
||||
///
|
||||
/// - Complexity: O(`count`)
|
||||
|
||||
@@ -26,7 +26,7 @@ mutation, its `Values` view is not a `MutableCollection`.
|
||||
|
||||
- ``init()``
|
||||
- ``init(_:)-(TreeDictionary<Key,Value>)``
|
||||
- ``init(_:)-(Dictionary<Key,Value>)``
|
||||
- ``init(_:)-([Key:Value])``
|
||||
- ``init(uniqueKeysWithValues:)-(Sequence<Element>)``
|
||||
- ``init(uniqueKeysWithValues:)-(Sequence<(Key,Value)>)``
|
||||
- ``init(_:uniquingKeysWith:)-(Sequence<Element>,_)``
|
||||
@@ -43,9 +43,9 @@ mutation, its `Values` view is not a `MutableCollection`.
|
||||
|
||||
### Accessing Keys and Values
|
||||
|
||||
- ``subscript(i:)``
|
||||
- ``subscript(key:default:)``
|
||||
- ``subscript(key:)``
|
||||
- ``subscript(_:)->TreeDictionary<Key,Value>.Element``
|
||||
- ``subscript(_:default:)``
|
||||
- ``subscript(_:)->Value?``
|
||||
- ``index(forKey:)``
|
||||
|
||||
### Adding or Updating Keys and Values
|
||||
@@ -60,10 +60,10 @@ operation.) `TreeDictionary` also provides the standard `merge` and
|
||||
- ``updateValue(_:forKey:)``
|
||||
- ``updateValue(forKey:with:)``
|
||||
- ``updateValue(forKey:default:with:)``
|
||||
- ``merge(_:uniquingKeysWith:)-(Self,_)``
|
||||
- ``merge(_:uniquingKeysWith:)-(TreeDictionary,_)``
|
||||
- ``merge(_:uniquingKeysWith:)-(Sequence<Element>,_)``
|
||||
- ``merge(_:uniquingKeysWith:)-(Sequence<(Key,Value)>,_)``
|
||||
- ``merging(_:uniquingKeysWith:)-(Self,_)``
|
||||
- ``merging(_:uniquingKeysWith:)-(TreeDictionary,_)``
|
||||
- ``merging(_:uniquingKeysWith:)-(Sequence<Element>,_)``
|
||||
- ``merging(_:uniquingKeysWith:)-(Sequence<(Key,Value)>,_)``
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ average -- typically they will need to compare against just one member.
|
||||
### Creating a Set
|
||||
|
||||
- ``init()``
|
||||
- ``init(_:)-(Self)``
|
||||
- ``init(_:)-(TreeSet)``
|
||||
- ``init(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``init(_:)-(Sequence<Element>)``
|
||||
|
||||
@@ -103,35 +103,35 @@ but `TreeSet` follows the tradition established by `Set` in providing
|
||||
additional overloads to each operation that allow combining a set with
|
||||
additional types, including arbitrary sequences.
|
||||
|
||||
- ``intersection(_:)-(Self)`
|
||||
- ``intersection(_:)-(TreeSet)``
|
||||
- ``intersection(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``intersection(_:)-(Sequence<Element>)``
|
||||
|
||||
- ``union(_:)-(Self)``
|
||||
- ``union(_:)-(TreeSet)``
|
||||
- ``union(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``union(_:)-(Sequence<Element>)``
|
||||
|
||||
- ``subtracting(_:)-(Self)``
|
||||
- ``subtracting(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``subtracting(_:)-(TreeSet)``
|
||||
- ``subtracting(_:)-(TreeDictionary<Element,V>.Keys)``
|
||||
- ``subtracting(_:)-(Sequence<Element>)``
|
||||
|
||||
- ``symmetricDifference(_:)-(Self)``
|
||||
- ``symmetricDifference(_:)-(TreeSet)``
|
||||
- ``symmetricDifference(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``symmetricDifference(_:)-(Sequence<Element>)``
|
||||
|
||||
- ``formIntersection(_:)-(Self)``
|
||||
- ``formIntersection(_:)-(TreeSet)``
|
||||
- ``formIntersection(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``formIntersection(_:)-(Sequence<Element>)``
|
||||
|
||||
- ``formUnion(_:)-(Self)``
|
||||
- ``formUnion(_:)-(TreeSet)``
|
||||
- ``formUnion(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``formUnion(_:)-(Sequence<Element>)``
|
||||
|
||||
- ``subtract(_:)-(Self)``
|
||||
- ``subtract(_:)-(TreeSet)``
|
||||
- ``subtract(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``subtract(_:)-(Sequence<Element>)``
|
||||
|
||||
- ``formSymmetricDifference(_:)-(Self)``
|
||||
- ``formSymmetricDifference(_:)-(TreeSet)``
|
||||
- ``formSymmetricDifference(_:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``formSymmetricDifference(_:)-(Sequence<Element>)``
|
||||
|
||||
@@ -146,26 +146,26 @@ Like `==`, the `isEqualSet` functions ignore element ordering and duplicates (if
|
||||
any).
|
||||
|
||||
- ``==(_:_:)``
|
||||
- ``isEqualSet(to:)-(Self)``
|
||||
- ``isEqualSet(to:)-(TreeSet)``
|
||||
- ``isEqualSet(to:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``isEqualSet(to:)-(Sequence<Element>)``
|
||||
|
||||
- ``isSubset(of:)-(Self)``
|
||||
- ``isSubset(of:)-(TreeSet)``
|
||||
- ``isSubset(of:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``isSubset(of:)-(Sequence<Element>)``
|
||||
|
||||
- ``isSuperset(of:)-(Self)``
|
||||
- ``isSuperset(of:)-(TreeSet)``
|
||||
- ``isSuperset(of:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``isSuperset(of:)-(Sequence<Element>)``
|
||||
|
||||
- ``isStrictSubset(of:)-(Self)``
|
||||
- ``isStrictSubset(of:)-(TreeSet)``
|
||||
- ``isStrictSubset(of:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``isStrictSubset(of:)-(Sequence<Element>)``
|
||||
|
||||
- ``isStrictSuperset(of:)-(Self)``
|
||||
- ``isStrictSuperset(of:)-(TreeSet)``
|
||||
- ``isStrictSuperset(of:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``isStrictSuperset(of:)-(Sequence<Element>)``
|
||||
|
||||
- ``isDisjoint(with:)-(Self)``
|
||||
- ``isDisjoint(with:)-(TreeSet)``
|
||||
- ``isDisjoint(with:)-(TreeDictionary<Element,Value>.Keys)``
|
||||
- ``isDisjoint(with:)-(Sequence<Element>)``
|
||||
@@ -159,11 +159,11 @@ extension TreeDictionary: Collection {
|
||||
///
|
||||
/// - Complexity: O(1)
|
||||
@inlinable
|
||||
public subscript(i: Index) -> Element {
|
||||
precondition(_isValid(i), "Invalid index")
|
||||
precondition(i._path.isOnItem, "Cannot get element at endIndex")
|
||||
return _UnsafeHandle.read(i._path.node) {
|
||||
$0[item: i._path.currentItemSlot]
|
||||
public subscript(position: Index) -> Element {
|
||||
precondition(_isValid(position), "Invalid index")
|
||||
precondition(position._path.isOnItem, "Cannot get element at endIndex")
|
||||
return _UnsafeHandle.read(position._path.node) {
|
||||
$0[item: position._path.currentItemSlot]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ extension TreeDictionary.Keys {
|
||||
/// However, the implementation is careful to make the best use of
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
public func intersection(_ other: TreeSet<Key>) -> Self {
|
||||
public func intersection(_ other: TreeSet<Key>) -> TreeDictionary.Keys {
|
||||
guard let r = _base._root.intersection(.top, other._root) else {
|
||||
return self
|
||||
}
|
||||
@@ -259,7 +259,7 @@ extension TreeDictionary.Keys {
|
||||
/// parts of the input trees directly into the result.
|
||||
public func subtracting<Value2>(
|
||||
_ other: TreeDictionary<Key, Value2>.Keys
|
||||
) -> Self {
|
||||
) -> TreeDictionary.Keys {
|
||||
guard let r = _base._root.subtracting(.top, other._base._root) else {
|
||||
return self
|
||||
}
|
||||
@@ -283,7 +283,7 @@ extension TreeDictionary.Keys {
|
||||
/// However, the implementation is careful to make the best use of
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
public func subtracting(_ other: TreeSet<Key>) -> Self {
|
||||
public func subtracting(_ other: TreeSet<Key>) -> TreeDictionary.Keys {
|
||||
guard let r = _base._root.subtracting(.top, other._root) else {
|
||||
return self
|
||||
}
|
||||
@@ -299,8 +299,8 @@ extension TreeDictionary.Keys: Equatable {
|
||||
/// Equality is the inverse of inequality. For any values `a` and `b`,
|
||||
/// `a == b` implies that `a != b` is `false`.
|
||||
///
|
||||
/// - Parameter lhs: A value to compare.
|
||||
/// - Parameter rhs: Another value to compare.
|
||||
/// - Parameter left: A value to compare.
|
||||
/// - Parameter right: Another value to compare.
|
||||
///
|
||||
/// - Complexity: Generally O(`count`), as long as`Element` properly
|
||||
/// implements hashing. That said, the implementation is careful to take
|
||||
|
||||
@@ -41,7 +41,7 @@ extension TreeDictionary {
|
||||
/// dictionary.
|
||||
@inlinable
|
||||
public mutating func merge(
|
||||
_ keysAndValues: Self,
|
||||
_ keysAndValues: TreeDictionary,
|
||||
uniquingKeysWith combine: (Value, Value) throws -> Value
|
||||
) rethrows {
|
||||
_invalidateIndices()
|
||||
@@ -168,7 +168,7 @@ extension TreeDictionary {
|
||||
/// hashing.
|
||||
@inlinable
|
||||
public func merging(
|
||||
_ other: Self,
|
||||
_ other: TreeDictionary,
|
||||
uniquingKeysWith combine: (Value, Value) throws -> Value
|
||||
) rethrows -> Self {
|
||||
var copy = self
|
||||
|
||||
@@ -46,10 +46,10 @@ extension TreeSet {
|
||||
///
|
||||
/// Calling this method invalidates all existing indices of the collection.
|
||||
///
|
||||
/// - Parameter item: The new value that should replace the original element.
|
||||
/// - Parameters:
|
||||
/// - member: The new value that should replace the original element.
|
||||
/// `item` must compare equal to the original value.
|
||||
///
|
||||
/// - Parameter index: The index of the element to be replaced.
|
||||
/// - index: The index of the element to be replaced.
|
||||
///
|
||||
/// - Returns: The original element that was replaced.
|
||||
///
|
||||
|
||||
@@ -56,7 +56,7 @@ extension TreeSet {
|
||||
///
|
||||
/// - Complexity: O(1)
|
||||
@inlinable
|
||||
public init(_ items: __owned Self) {
|
||||
public init(_ items: __owned TreeSet) {
|
||||
self = items
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ extension TreeSet {
|
||||
/// - Complexity: O(*items.count*)
|
||||
@inlinable
|
||||
public init<Value>(
|
||||
_ item: __owned TreeDictionary<Element, Value>.Keys
|
||||
_ items: __owned TreeDictionary<Element, Value>.Keys
|
||||
) {
|
||||
self.init(_new: item._base._root.mapValues { _ in () })
|
||||
self.init(_new: items._base._root.mapValues { _ in () })
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,9 @@ extension TreeSet: SetAlgebra {
|
||||
/// Returns a Boolean value that indicates whether the given element exists
|
||||
/// in the set.
|
||||
///
|
||||
/// - Parameter element: An element to look for in the set.
|
||||
/// - Parameter item: An element to look for in the set.
|
||||
///
|
||||
/// - Returns: `true` if `element` exists in the set; otherwise, `false`.
|
||||
/// - Returns: `true` if `item` exists in the set; otherwise, `false`.
|
||||
///
|
||||
/// - Complexity: This operation is expected to perform O(1) hashing and
|
||||
/// comparison operations on average, provided that `Element` implements
|
||||
|
||||
@@ -31,7 +31,7 @@ extension TreeSet {
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
@inlinable
|
||||
public mutating func formIntersection(_ other: Self) {
|
||||
public mutating func formIntersection(_ other: TreeSet) {
|
||||
// FIXME: Implement in-place reductions
|
||||
self = intersection(other)
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ extension TreeSet {
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
@inlinable
|
||||
public mutating func formSymmetricDifference(_ other: __owned Self) {
|
||||
public mutating func formSymmetricDifference(_ other: __owned TreeSet) {
|
||||
self = symmetricDifference(other)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ extension TreeSet {
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
@inlinable
|
||||
public mutating func formUnion(_ other: __owned Self) {
|
||||
public mutating func formUnion(_ other: __owned TreeSet) {
|
||||
self = union(other)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ extension TreeSet {
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
@inlinable @inline(__always)
|
||||
public func intersection(_ other: Self) -> Self {
|
||||
public func intersection(_ other: TreeSet) -> TreeSet {
|
||||
_intersection(other._root)
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ extension TreeSet {
|
||||
@inlinable @inline(__always)
|
||||
public func intersection<Value>(
|
||||
_ other: TreeDictionary<Element, Value>.Keys
|
||||
) -> Self {
|
||||
) -> TreeSet {
|
||||
_intersection(other._base._root)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
internal func _intersection<V>(_ other: _HashNode<Element, V>) -> Self {
|
||||
internal func _intersection<V>(_ other: _HashNode<Element, V>) -> TreeSet {
|
||||
guard let r = _root.intersection(.top, other) else { return self }
|
||||
return Self(_new: r)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ extension TreeSet {
|
||||
@inlinable
|
||||
public func intersection(
|
||||
_ other: some Sequence<Element>
|
||||
) -> Self {
|
||||
) -> TreeSet {
|
||||
if let other = _specialize(other, for: Self.self) {
|
||||
return intersection(other)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ extension TreeSet {
|
||||
/// - Complexity: Expected to be O(min(`self.count`, `other.count`)) on
|
||||
/// average, if `Element` implements high-quality hashing.
|
||||
@inlinable
|
||||
public func isDisjoint(with other: Self) -> Bool {
|
||||
public func isDisjoint(with other: TreeSet) -> Bool {
|
||||
self._root.isDisjoint(.top, with: other._root)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ extension TreeSet {
|
||||
/// every available shortcut to reduce complexity, e.g. by skipping
|
||||
/// comparing elements in shared subtrees.
|
||||
@inlinable
|
||||
public func isEqualSet(to other: Self) -> Bool {
|
||||
public func isEqualSet(to other: TreeSet) -> Bool {
|
||||
_root.isEqualSet(to: other._root, by: { _, _ in true })
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ extension TreeSet {
|
||||
/// the best use of hash tree structure to minimize work when possible,
|
||||
/// e.g. by skipping over parts of the input trees.
|
||||
@inlinable
|
||||
public func isStrictSubset(of other: Self) -> Bool {
|
||||
public func isStrictSubset(of other: TreeSet) -> Bool {
|
||||
guard self.count < other.count else { return false }
|
||||
return isSubset(of: other)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ extension TreeSet {
|
||||
/// the best use of hash tree structure to minimize work when possible,
|
||||
/// e.g. by skipping over parts of the input trees.
|
||||
@inlinable
|
||||
public func isStrictSuperset(of other: Self) -> Bool {
|
||||
public func isStrictSuperset(of other: TreeSet) -> Bool {
|
||||
guard self.count > other.count else { return false }
|
||||
return other._root.isSubset(.top, of: self._root)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ extension TreeSet {
|
||||
/// the best use of hash tree structure to minimize work when possible,
|
||||
/// e.g. by skipping over parts of the input trees.
|
||||
@inlinable
|
||||
public func isSubset(of other: Self) -> Bool {
|
||||
public func isSubset(of other: TreeSet) -> Bool {
|
||||
self._root.isSubset(.top, of: other._root)
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ extension TreeSet {
|
||||
/// the best use of hash tree structure to minimize work when possible,
|
||||
/// e.g. by skipping over parts of the input trees.
|
||||
@inlinable
|
||||
public func isSuperset(of other: Self) -> Bool {
|
||||
public func isSuperset(of other: TreeSet) -> Bool {
|
||||
other._root.isSubset(.top, of: self._root)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ extension TreeSet {
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
@inlinable
|
||||
public mutating func subtract(_ other: Self) {
|
||||
public mutating func subtract(_ other: TreeSet) {
|
||||
// FIXME: Implement in-place reductions
|
||||
self = subtracting(other)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ extension TreeSet {
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
@inlinable
|
||||
public __consuming func subtracting(_ other: Self) -> Self {
|
||||
public __consuming func subtracting(_ other: TreeSet) -> TreeSet {
|
||||
_subtracting(other._root)
|
||||
}
|
||||
|
||||
@@ -54,14 +54,14 @@ extension TreeSet {
|
||||
@inlinable
|
||||
public __consuming func subtracting<V>(
|
||||
_ other: TreeDictionary<Element, V>.Keys
|
||||
) -> Self {
|
||||
) -> TreeSet {
|
||||
_subtracting(other._base._root)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
internal __consuming func _subtracting<V>(
|
||||
_ other: _HashNode<Element, V>
|
||||
) -> Self {
|
||||
) -> TreeSet {
|
||||
guard let r = _root.subtracting(.top, other) else { return self }
|
||||
return Self(_new: r)
|
||||
}
|
||||
@@ -79,7 +79,9 @@ extension TreeSet {
|
||||
/// - Complexity: O(*n*) where *n* is the number of elements in `other`,
|
||||
/// as long as `Element` properly implements hashing.
|
||||
@inlinable
|
||||
public __consuming func subtracting(_ other: some Sequence<Element>) -> Self {
|
||||
public __consuming func subtracting(
|
||||
_ other: some Sequence<Element>
|
||||
) -> TreeSet {
|
||||
if let other = _specialize(other, for: Self.self) {
|
||||
return subtracting(other)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ extension TreeSet {
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
@inlinable
|
||||
public func symmetricDifference(_ other: __owned Self) -> Self {
|
||||
public func symmetricDifference(_ other: __owned TreeSet) -> TreeSet {
|
||||
let branch = _root.symmetricDifference(.top, other._root)
|
||||
guard let branch = branch else { return self }
|
||||
let root = branch.finalize(.top)
|
||||
@@ -58,7 +58,7 @@ extension TreeSet {
|
||||
@inlinable
|
||||
public func symmetricDifference<Value>(
|
||||
_ other: __owned TreeDictionary<Element, Value>.Keys
|
||||
) -> Self {
|
||||
) -> TreeSet {
|
||||
let branch = _root.symmetricDifference(.top, other._base._root)
|
||||
guard let branch = branch else { return self }
|
||||
let root = branch.finalize(.top)
|
||||
@@ -88,7 +88,7 @@ extension TreeSet {
|
||||
@inlinable
|
||||
public func symmetricDifference(
|
||||
_ other: __owned some Sequence<Element>
|
||||
) -> Self {
|
||||
) -> TreeSet {
|
||||
if let other = _specialize(other, for: Self.self) {
|
||||
return symmetricDifference(other)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ extension TreeSet {
|
||||
/// hash tree structure to minimize work when possible, e.g. by linking
|
||||
/// parts of the input trees directly into the result.
|
||||
@inlinable
|
||||
public func union(_ other: __owned Self) -> Self {
|
||||
public func union(_ other: __owned TreeSet) -> TreeSet {
|
||||
let r = _root.union(.top, other._root)
|
||||
guard r.copied else { return self }
|
||||
r.node._fullInvariantCheck()
|
||||
@@ -66,7 +66,7 @@ extension TreeSet {
|
||||
@inlinable
|
||||
public func union<Value>(
|
||||
_ other: __owned TreeDictionary<Element, Value>.Keys
|
||||
) -> Self {
|
||||
) -> TreeSet {
|
||||
let r = _root.union(.top, other._base._root)
|
||||
guard r.copied else { return self }
|
||||
r.node._fullInvariantCheck()
|
||||
@@ -97,7 +97,7 @@ extension TreeSet {
|
||||
/// the worst case, where *n* is the number of items in `other`,
|
||||
/// as long as `Element` properly implements hashing.
|
||||
@inlinable
|
||||
public func union(_ other: __owned some Sequence<Element>) -> Self {
|
||||
public func union(_ other: __owned some Sequence<Element>) -> TreeSet {
|
||||
if let other = _specialize(other, for: Self.self) {
|
||||
return union(other)
|
||||
}
|
||||
|
||||
+3
-2
@@ -312,8 +312,9 @@ extension OrderedDictionary.Elements.SubSequence: RandomAccessCollection {
|
||||
|
||||
/// Accesses the element at the specified position.
|
||||
///
|
||||
/// - Parameter index: The position of the element to access. `index` must be
|
||||
/// greater than or equal to `startIndex` and less than `endIndex`.
|
||||
/// - Parameter position: The position of the element to access.
|
||||
/// `position` must be greater than or equal to `startIndex` and less than
|
||||
/// `endIndex`.
|
||||
///
|
||||
/// - Complexity: O(1)
|
||||
@inlinable
|
||||
|
||||
@@ -275,8 +275,8 @@ extension OrderedDictionary.Elements: RandomAccessCollection {
|
||||
|
||||
/// Accesses the element at the specified position.
|
||||
///
|
||||
/// - Parameter index: The position of the element to access. `index` must be
|
||||
/// greater than or equal to `startIndex` and less than `endIndex`.
|
||||
/// - Parameter position: The position of the element to access. `position`
|
||||
/// must be greater than or equal to `startIndex` and less than `endIndex`.
|
||||
///
|
||||
/// - Complexity: O(1)
|
||||
@inlinable
|
||||
@@ -539,7 +539,7 @@ extension OrderedDictionary.Elements {
|
||||
extension OrderedDictionary.Elements {
|
||||
/// Removes all members from the dictionary.
|
||||
///
|
||||
/// - Parameter keepingCapacity: If `true`, the dictionary's storage capacity
|
||||
/// - Parameter keepCapacity: If `true`, the dictionary's storage capacity
|
||||
/// is preserved; if `false`, the underlying storage is released. The
|
||||
/// default is `false`.
|
||||
///
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ extension OrderedDictionary {
|
||||
|
||||
/// Removes all members from the dictionary.
|
||||
///
|
||||
/// - Parameter keepingCapacity: If `true`, the dictionary's storage capacity
|
||||
/// - Parameter keepCapacity: If `true`, the dictionary's storage capacity
|
||||
/// is preserved; if `false`, the underlying storage is released. The
|
||||
/// default is `false`.
|
||||
///
|
||||
|
||||
@@ -298,8 +298,9 @@ extension OrderedDictionary.Values: MutableCollection {
|
||||
/// Accesses the element at the specified position. This can be used to
|
||||
/// perform in-place mutations on dictionary values.
|
||||
///
|
||||
/// - Parameter index: The position of the element to access. `index` must be
|
||||
/// greater than or equal to `startIndex` and less than `endIndex`.
|
||||
/// - Parameter position: The position of the element to access.
|
||||
/// `position` must be greater than or equal to `startIndex` and less than
|
||||
/// `endIndex`.
|
||||
///
|
||||
/// - Complexity: O(1)
|
||||
@inlinable
|
||||
|
||||
@@ -718,8 +718,10 @@ extension OrderedDictionary {
|
||||
/// - Parameters:
|
||||
/// - key: The key to look up (or append). If `key` does not already exist
|
||||
/// in the dictionary, it is appended with the supplied default value.
|
||||
/// - defaultValue: The default value to append if `key` doesn't exist in
|
||||
/// - defaultValue: The default value to insert if `key` doesn't exist in
|
||||
/// the dictionary.
|
||||
/// - index: The index at which to insert the new element, if it doesn't
|
||||
/// already exist.
|
||||
/// - body: A function that performs an in-place mutation on the dictionary
|
||||
/// value.
|
||||
///
|
||||
|
||||
@@ -146,7 +146,11 @@ extension OrderedSet {
|
||||
/// Insert a new member to this set at the specified index, if the set doesn't
|
||||
/// already contain it.
|
||||
///
|
||||
/// - Parameter item: The element to insert.
|
||||
/// - Parameters:
|
||||
/// - item: The element to insert.
|
||||
/// - index: The index at which to insert the new element, if the set
|
||||
/// doesn't already contain it. `index` must be a valid index in the
|
||||
/// original set.
|
||||
///
|
||||
/// - Returns: A pair `(inserted, index)`, where `inserted` is a Boolean value
|
||||
/// indicating whether the operation added a new element, and `index` is
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
extension OrderedSet {
|
||||
/// Removes all members from the set.
|
||||
///
|
||||
/// - Parameter keepingCapacity: If `true`, the set's storage capacity is
|
||||
/// - Parameter keepCapacity: If `true`, the set's storage capacity is
|
||||
/// preserved; if `false`, the underlying storage is released. The default
|
||||
/// is `false`.
|
||||
///
|
||||
|
||||
@@ -225,8 +225,9 @@ extension OrderedSet: RandomAccessCollection {
|
||||
|
||||
/// Accesses the element at the specified position.
|
||||
///
|
||||
/// - Parameter index: The position of the element to access. `index` must be
|
||||
/// greater than or equal to `startIndex` and less than `endIndex`.
|
||||
/// - Parameter position: The position of the element to access.
|
||||
/// `position` must be greater than or equal to `startIndex` and less than
|
||||
/// `endIndex`.
|
||||
///
|
||||
/// - Complexity: O(1)
|
||||
@inlinable
|
||||
|
||||
@@ -289,8 +289,9 @@ extension OrderedSet.SubSequence: RandomAccessCollection {
|
||||
|
||||
/// Accesses the element at the specified position.
|
||||
///
|
||||
/// - Parameter index: The position of the element to access. `index` must be
|
||||
/// greater than or equal to `startIndex` and less than `endIndex`.
|
||||
/// - Parameter position: The position of the element to access.
|
||||
/// `position` must be greater than or equal to `startIndex` and less than
|
||||
/// `endIndex`.
|
||||
///
|
||||
/// - Complexity: O(1)
|
||||
@inlinable
|
||||
|
||||
+1
-1
@@ -112,4 +112,4 @@ var padded = TrailingPadding(header: SomeType(), totalSize: getSizeOfSomeTypeWit
|
||||
- ``TrailingPadding``
|
||||
|
||||
### Protocols
|
||||
- ``TrailingElements`
|
||||
- ``TrailingElements``
|
||||
+1
-13
@@ -30,7 +30,7 @@ output_dir_base=/tmp/foo
|
||||
rm -rf "$output_dir_base"
|
||||
|
||||
components="\
|
||||
BitCollections DequeModule HeapModule OrderedCollections \
|
||||
BitCollections ContainersPreview DequeModule HeapModule OrderedCollections \
|
||||
HashTreeCollections"
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
@@ -40,18 +40,6 @@ else
|
||||
fi
|
||||
|
||||
for target in $targets; do
|
||||
if [ "$target" = "Collections" ]; then
|
||||
# Update extensions under Collections.docc
|
||||
rm -rf Sources/Collections/Collections.docc/Extensions/*.md
|
||||
for component in $components; do
|
||||
for file in Sources/"$component"/"$component".docc/Extensions/*.md; do
|
||||
output="Sources/Collections/Collections.docc/Extensions/$(basename $file)"
|
||||
blurb="<!-- DO NOT EDIT THIS FILE; IT'S AUTOMATICALLY GENERATED -->"
|
||||
sed 's?^# ``[^/]*/\(.*\)``?# ``Collections/\1``\n\n'"$blurb"'\n?' "$file" > "$output"
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
mkdir -p "$build_dir/$target/build"
|
||||
mkdir -p "$build_dir/$target/symbol-graphs"
|
||||
mkdir -p "$build_dir/$target/docc"
|
||||
|
||||
Reference in new issue
Block a user