Skip to content

[SE-0270] Reset availability of RangeSet APIs #34567

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

Merged
merged 1 commit into from
Nov 4, 2020
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
4 changes: 2 additions & 2 deletions stdlib/public/core/CollectionAlgorithms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ extension Collection {
/// returns `true`.
///
/// - Complexity: O(*n*), where *n* is the length of the collection.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public func subranges(where predicate: (Element) throws -> Bool) rethrows
-> RangeSet<Index>
{
Expand Down Expand Up @@ -267,7 +267,7 @@ extension Collection where Element: Equatable {
/// `element`.
///
/// - Complexity: O(*n*), where *n* is the length of the collection.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public func subranges(of element: Element) -> RangeSet<Index> {
subranges(where: { $0 == element })
}
Expand Down
20 changes: 10 additions & 10 deletions stdlib/public/core/DiscontiguousSlice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/// A collection wrapper that provides access to the elements of a collection,
/// indexed by a set of indices.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@frozen
public struct DiscontiguousSlice<Base: Collection> {
/// The collection that the indexed collection wraps.
Expand All @@ -22,7 +22,7 @@ public struct DiscontiguousSlice<Base: Collection> {
public var subranges: RangeSet<Base.Index>
}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension DiscontiguousSlice {
/// A position in an `DiscontiguousSlice`.
@frozen
Expand All @@ -39,10 +39,10 @@ extension DiscontiguousSlice {
}
}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension DiscontiguousSlice.Index: Hashable where Base.Index: Hashable {}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension DiscontiguousSlice: Collection {
public typealias SubSequence = Self

Expand Down Expand Up @@ -83,7 +83,7 @@ extension DiscontiguousSlice: Collection {
}
}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension DiscontiguousSlice {
public var count: Int {
var c = 0
Expand All @@ -102,7 +102,7 @@ extension DiscontiguousSlice {
}
}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension DiscontiguousSlice: BidirectionalCollection
where Base: BidirectionalCollection
{
Expand All @@ -122,7 +122,7 @@ extension DiscontiguousSlice: BidirectionalCollection
}
}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension DiscontiguousSlice: MutableCollection where Base: MutableCollection {
public subscript(i: Index) -> Base.Element {
get {
Expand All @@ -145,7 +145,7 @@ extension Collection {
/// - Returns: A collection of the elements at the positions in `subranges`.
///
/// - Complexity: O(1)
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public subscript(subranges: RangeSet<Index>) -> DiscontiguousSlice<Self> {
DiscontiguousSlice(base: self, subranges: subranges)
}
Expand All @@ -162,7 +162,7 @@ extension MutableCollection {
/// - Complexity: O(1) to access the elements, O(*m*) to mutate the
/// elements at the positions in `subranges`, where *m* is the number of
/// elements indicated by `subranges`.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public subscript(subranges: RangeSet<Index>) -> DiscontiguousSlice<Self> {
get {
DiscontiguousSlice(base: self, subranges: subranges)
Expand Down Expand Up @@ -196,7 +196,7 @@ extension Collection {
/// - Returns: A collection of the elements that are not in `subranges`.
///
/// - Complexity: O(*n*), where *n* is the length of the collection.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public func removingSubranges(
_ subranges: RangeSet<Index>
) -> DiscontiguousSlice<Self> {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/MutableCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ extension MutableCollection {
/// - Returns: The new bounds of the moved elements.
///
/// - Complexity: O(*n* log *n*) where *n* is the length of the collection.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@discardableResult
public mutating func moveSubranges(
_ subranges: RangeSet<Index>, to insertionPoint: Index
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/RangeReplaceableCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ extension RangeReplaceableCollection {
/// - Parameter subranges: The indices of the elements to remove.
///
/// - Complexity: O(*n*), where *n* is the length of the collection.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public mutating func removeSubranges(_ subranges: RangeSet<Index>) {
guard !subranges.isEmpty else {
return
Expand Down Expand Up @@ -1208,7 +1208,7 @@ extension MutableCollection where Self: RangeReplaceableCollection {
/// - Parameter subranges: The indices of the elements to remove.
///
/// - Complexity: O(*n*), where *n* is the length of the collection.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public mutating func removeSubranges(_ subranges: RangeSet<Index>) {
guard let firstRange = subranges.ranges.first else {
return
Expand Down
14 changes: 7 additions & 7 deletions stdlib/public/core/RangeSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
///
/// numbers.moveSubranges(negativeSubranges, to: 0)
/// // numbers == [-5, -3, -9, 10, 12, 14, 15]
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
public struct RangeSet<Bound: Comparable> {
internal var _ranges = _RangeSetStorage<Bound>()

Expand Down Expand Up @@ -238,15 +238,15 @@ public struct RangeSet<Bound: Comparable> {
}
}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension RangeSet: Equatable {}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension RangeSet: Hashable where Bound: Hashable {}

// MARK: - Range Collection

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension RangeSet {
/// A collection of the ranges that make up a range set.
public struct Ranges: RandomAccessCollection {
Expand All @@ -271,7 +271,7 @@ extension RangeSet {

// MARK: - Collection APIs

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension RangeSet {
/// Creates a new range set containing ranges that contain only the
/// specified indices in the given collection.
Expand Down Expand Up @@ -365,7 +365,7 @@ extension RangeSet {

// These methods only depend on the ranges that comprise the range set, so
// we can provide them even when we can't provide `SetAlgebra` conformance.
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension RangeSet {
/// Adds the contents of the given range set to this range set.
///
Expand Down Expand Up @@ -549,7 +549,7 @@ extension RangeSet {
}
}

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension RangeSet: CustomStringConvertible {
public var description: String {
let rangesDescription = _ranges
Expand Down
4 changes: 2 additions & 2 deletions validation-test/StdlibUnittest/RangeSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import StdlibUnittest
import StdlibCollectionUnittest

@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
extension RangeSet: ExpressibleByArrayLiteral {
public init(arrayLiteral elements: Range<Bound>...) {
self.init(elements)
Expand All @@ -21,7 +21,7 @@ extension Collection {

let RangeSetTests = TestSuite("RangeSet")

if #available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
let parent = -200..<200
let source: RangeSet = [1..<5, 8..<10, 20..<22, 27..<29]

Expand Down