diff --git a/Package.swift b/Package.swift index 116633a1..8a1903e5 100644 --- a/Package.swift +++ b/Package.swift @@ -25,6 +25,15 @@ let _traits: Set = [ swift-collections. This allows experimental use of the Container protocols and associated algorithms. """), + .trait( + name: "UnstableSortedCollections", + description: """ + Enables source-unstable prototypes of `SortedSet` and `SortedDictionary`, + two potential new collection types implementing in-memory B-trees. + These are early developer drafts, and they not ready for use in + production. We will make significant, source breaking API changes to these + types before they ship. + """), ] #endif @@ -37,6 +46,9 @@ var defines: [SwiftSetting] = [ // .define( // "COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW", // .when(traits: ["UnstableContainersPreview"])), + .define( + "COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS", + .when(traits: ["UnstableSortedCollections"])), // Enables internal consistency checks at the end of initializers and // mutating operations. This can have very significant overhead, so enabling @@ -314,15 +326,15 @@ let targets: [CustomTarget] = [ dependencies: ["TrailingElementsModule"]), // These aren't ready for production use yet. -// .target( -// kind: .exported, -// name: "SortedCollections", -// dependencies: ["InternalCollectionsUtilities"], -// directory: "SortedCollections"), -// .target( -// kind: .test, -// name: "SortedCollectionsTests", -// dependencies: ["SortedCollections", "_CollectionsTestSupport"]), + .target( + kind: .exported, + name: "SortedCollections", + dependencies: ["InternalCollectionsUtilities"], + directory: "SortedCollections"), + .target( + kind: .test, + name: "SortedCollectionsTests", + dependencies: ["SortedCollections", "_CollectionsTestSupport"]), .target( kind: .exported, diff --git a/Sources/SortedCollections/BTree/_BTree+BidirectionalCollection.swift b/Sources/SortedCollections/BTree/_BTree+BidirectionalCollection.swift index d6e45bea..127fca3e 100644 --- a/Sources/SortedCollections/BTree/_BTree+BidirectionalCollection.swift +++ b/Sources/SortedCollections/BTree/_BTree+BidirectionalCollection.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + // This contains `_BTree`'s general implementation of BidirectionalCollection. // These operations are bounds in contrast to most other methods on _BTree as // they are designed to be easily propagated to a higher-level data type. @@ -203,3 +205,5 @@ extension _BTree: BidirectionalCollection { return SubSequence(base: self, bounds: bounds) } } + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree+CustomDebugStringConvertible.swift b/Sources/SortedCollections/BTree/_BTree+CustomDebugStringConvertible.swift index a0b0489f..a6fbc452 100644 --- a/Sources/SortedCollections/BTree/_BTree+CustomDebugStringConvertible.swift +++ b/Sources/SortedCollections/BTree/_BTree+CustomDebugStringConvertible.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _BTree: CustomDebugStringConvertible { #if DEBUG /// A textual representation of this instance, suitable for debugging. @@ -23,3 +25,5 @@ extension _BTree: CustomDebugStringConvertible { } #endif // DEBUG } + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree+CustomReflectable.swift b/Sources/SortedCollections/BTree/_BTree+CustomReflectable.swift index c90eb23b..dc5368c4 100644 --- a/Sources/SortedCollections/BTree/_BTree+CustomReflectable.swift +++ b/Sources/SortedCollections/BTree/_BTree+CustomReflectable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if !$Embedded extension _BTree: CustomReflectable { /// The custom mirror for this instance. @@ -18,3 +20,5 @@ extension _BTree: CustomReflectable { } } #endif + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree+Invariants.swift b/Sources/SortedCollections/BTree/_BTree+Invariants.swift index b2684a0c..e47569f5 100644 --- a/Sources/SortedCollections/BTree/_BTree+Invariants.swift +++ b/Sources/SortedCollections/BTree/_BTree+Invariants.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _BTree { #if COLLECTIONS_INTERNAL_CHECKS @inline(never) @@ -100,3 +102,5 @@ extension _BTree { internal func checkInvariants() {} #endif // COLLECTIONS_INTERNAL_CHECKS } + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree+Partial RangeReplaceableCollection.swift b/Sources/SortedCollections/BTree/_BTree+Partial RangeReplaceableCollection.swift index 03c6640d..dafba967 100644 --- a/Sources/SortedCollections/BTree/_BTree+Partial RangeReplaceableCollection.swift +++ b/Sources/SortedCollections/BTree/_BTree+Partial RangeReplaceableCollection.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _BTree { /// Filters a B-Tree on a predicate, returning a new tree. /// @@ -139,3 +141,5 @@ extension _BTree { } } + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree+Sequence.swift b/Sources/SortedCollections/BTree/_BTree+Sequence.swift index 7539e788..48dcf6b7 100644 --- a/Sources/SortedCollections/BTree/_BTree+Sequence.swift +++ b/Sources/SortedCollections/BTree/_BTree+Sequence.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _BTree: Sequence { @inlinable internal func forEach(_ body: (Element) throws -> Void) rethrows { @@ -187,3 +189,5 @@ extension _BTree: Sequence { return Iterator(forTree: self) } } + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree+SubSequence.swift b/Sources/SortedCollections/BTree/_BTree+SubSequence.swift index 52a2ce1e..e541a3e7 100644 --- a/Sources/SortedCollections/BTree/_BTree+SubSequence.swift +++ b/Sources/SortedCollections/BTree/_BTree+SubSequence.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _BTree { @usableFromInline internal struct SubSequence { @@ -185,3 +187,5 @@ extension _BTree.SubSequence: BidirectionalCollection { } // TODO: implement partial RangeReplaceableCollection methods + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree+UnsafeCursor.swift b/Sources/SortedCollections/BTree/_BTree+UnsafeCursor.swift index f85b551c..a08a1a0a 100644 --- a/Sources/SortedCollections/BTree/_BTree+UnsafeCursor.swift +++ b/Sources/SortedCollections/BTree/_BTree+UnsafeCursor.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _BTree { /// A mutable cursor to an element of the B-Tree represented as a path. /// @@ -506,3 +508,5 @@ extension _BTree { return (cursor, found) } } + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree.Builder.swift b/Sources/SortedCollections/BTree/_BTree.Builder.swift index 6e9b7298..b05e07e3 100644 --- a/Sources/SortedCollections/BTree/_BTree.Builder.swift +++ b/Sources/SortedCollections/BTree/_BTree.Builder.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _BTree { /// Provides an interface for efficiently constructing a filled B-Tree from sorted data. /// @@ -368,3 +370,5 @@ extension _BTree.Builder where Value == Void { self.append((key, ())) } } + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree.Index.swift b/Sources/SortedCollections/BTree/_BTree.Index.swift index 31b43fc4..cc5651de 100644 --- a/Sources/SortedCollections/BTree/_BTree.Index.swift +++ b/Sources/SortedCollections/BTree/_BTree.Index.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _BTree { /// An index to an element of the BTree represented as a path. @@ -140,3 +142,5 @@ extension _BTree.Index: Comparable { return lhs.offset < rhs.offset } } + +#endif diff --git a/Sources/SortedCollections/BTree/_BTree.swift b/Sources/SortedCollections/BTree/_BTree.swift index e594dbda..b883a39d 100644 --- a/Sources/SortedCollections/BTree/_BTree.swift +++ b/Sources/SortedCollections/BTree/_BTree.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + /// A bidirectional collection representing a BTree which efficiently stores its /// elements in sorted order and maintains roughly `O(log count)` /// performance for most operations. @@ -581,3 +583,5 @@ extension _BTree { return _BTree(rootedAt: root, internalCapacity: internalCapacity) } } + +#endif diff --git a/Sources/SortedCollections/BTree/_FixedSizeArray.swift b/Sources/SortedCollections/BTree/_FixedSizeArray.swift index 0352f762..ef084bc8 100644 --- a/Sources/SortedCollections/BTree/_FixedSizeArray.swift +++ b/Sources/SortedCollections/BTree/_FixedSizeArray.swift @@ -2,14 +2,16 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// - /// A stack-allocated deque of some values. +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + +/// A stack-allocated deque of some values. /// /// The supports efficient removals from and insertions to the beginning and end. /// @@ -133,3 +135,5 @@ extension _FixedSizeArray: CustomDebugStringConvertible { } #endif #endif + +#endif diff --git a/Sources/SortedCollections/BTree/_Node+CustomDebugString.swift b/Sources/SortedCollections/BTree/_Node+CustomDebugString.swift index 370f03db..df7737c9 100644 --- a/Sources/SortedCollections/BTree/_Node+CustomDebugString.swift +++ b/Sources/SortedCollections/BTree/_Node+CustomDebugString.swift @@ -2,16 +2,20 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _Node: CustomDebugStringConvertible { /// A textual representation of this instance, suitable for debugging. public var debugDescription: String { self.read { $0.debugDescription } } } + +#endif diff --git a/Sources/SortedCollections/BTree/_Node+Testing.swift b/Sources/SortedCollections/BTree/_Node+Testing.swift index dfead537..c61a37d4 100644 --- a/Sources/SortedCollections/BTree/_Node+Testing.swift +++ b/Sources/SortedCollections/BTree/_Node+Testing.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _Node { /// Initialize a node from a list of key-value tuples. @_spi(Testing) @@ -62,3 +64,5 @@ extension _Node { } } } + +#endif diff --git a/Sources/SortedCollections/BTree/_Node.Splinter.swift b/Sources/SortedCollections/BTree/_Node.Splinter.swift index b8144a98..cd77bd59 100644 --- a/Sources/SortedCollections/BTree/_Node.Splinter.swift +++ b/Sources/SortedCollections/BTree/_Node.Splinter.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _Node { /// Represents the result of a overfilled node's split. @usableFromInline @@ -49,3 +51,5 @@ extension _Node { } } } + +#endif diff --git a/Sources/SortedCollections/BTree/_Node.Storage.swift b/Sources/SortedCollections/BTree/_Node.Storage.swift index 89e4d729..a6c6edc5 100644 --- a/Sources/SortedCollections/BTree/_Node.Storage.swift +++ b/Sources/SortedCollections/BTree/_Node.Storage.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _Node { @usableFromInline internal struct Header { @@ -242,3 +244,5 @@ extension _Node { } } } + +#endif diff --git a/Sources/SortedCollections/BTree/_Node.UnsafeHandle+CustomDebugStringConvertible.swift b/Sources/SortedCollections/BTree/_Node.UnsafeHandle+CustomDebugStringConvertible.swift index 3c37f202..fef4b9a1 100644 --- a/Sources/SortedCollections/BTree/_Node.UnsafeHandle+CustomDebugStringConvertible.swift +++ b/Sources/SortedCollections/BTree/_Node.UnsafeHandle+CustomDebugStringConvertible.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if !$Embedded // MARK: CustomDebugStringConvertible extension _Node.UnsafeHandle: CustomDebugStringConvertible { @@ -149,3 +151,5 @@ extension _Node.UnsafeHandle: CustomDebugStringConvertible { #endif // DEBUG } #endif + +#endif diff --git a/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Deletion.swift b/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Deletion.swift index 0fee49b2..185521cb 100644 --- a/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Deletion.swift +++ b/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Deletion.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _Node.UnsafeHandle { /// Removes the key-value pair corresponding to the first found instance of the key. /// @@ -489,3 +491,5 @@ extension _Node.UnsafeHandle { } } } + +#endif diff --git a/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Insertion.swift b/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Insertion.swift index cd4ed328..15d3b51f 100644 --- a/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Insertion.swift +++ b/Sources/SortedCollections/BTree/_Node.UnsafeHandle+Insertion.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + // MARK: Tree Insertions extension _Node.UnsafeHandle { @usableFromInline @@ -520,3 +522,5 @@ extension _Node.UnsafeHandle { } } } + +#endif diff --git a/Sources/SortedCollections/BTree/_Node.UnsafeHandle.swift b/Sources/SortedCollections/BTree/_Node.UnsafeHandle.swift index eb46d3a4..0b5fd6de 100644 --- a/Sources/SortedCollections/BTree/_Node.UnsafeHandle.swift +++ b/Sources/SortedCollections/BTree/_Node.UnsafeHandle.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension _Node { /// A handle allowing potentially mutable operations to be performed. /// @@ -783,3 +785,5 @@ extension _Node.UnsafeHandle { return key } } + +#endif diff --git a/Sources/SortedCollections/BTree/_Node.swift b/Sources/SortedCollections/BTree/_Node.swift index c6038a9c..16a65229 100644 --- a/Sources/SortedCollections/BTree/_Node.swift +++ b/Sources/SortedCollections/BTree/_Node.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + /// A single node within a B-Tree, containing keys, values, and children. /// /// A node is merely struct wrapper of the ``_Node.Storage`` class. This does not and should not @@ -360,3 +362,4 @@ extension _Node: Equatable { } } +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+BidirectionalCollection.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+BidirectionalCollection.swift index a9027a3f..a3562fd9 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+BidirectionalCollection.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+BidirectionalCollection.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary: BidirectionalCollection { /// The number of elements in the sorted dictionary. /// @@ -173,3 +175,5 @@ extension SortedDictionary: BidirectionalCollection { return self._root.formIndex(&i._index, offsetBy: distance, limitedBy: limit._index) } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Codable.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Codable.swift index 11df1b44..9cf9001d 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Codable.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Codable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if !$Embedded extension SortedDictionary: Encodable where Key: Codable, Value: Codable { /// Encodes the contents of this dictionary into the given encoder. @@ -75,3 +77,5 @@ extension SortedDictionary: Decodable where Key: Decodable, Value: Decodable { } } #endif + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+CustomReflectable.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+CustomReflectable.swift index ef62ac18..0494f855 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+CustomReflectable.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+CustomReflectable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if !$Embedded extension SortedDictionary: CustomReflectable { /// The custom mirror for this instance. @@ -17,3 +19,5 @@ extension SortedDictionary: CustomReflectable { } } #endif + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+CustomStringConvertible.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+CustomStringConvertible.swift index c0d3d9a9..fea710f4 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+CustomStringConvertible.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+CustomStringConvertible.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if !$Embedded extension SortedDictionary: CustomStringConvertible, CustomDebugStringConvertible { @inlinable @@ -52,3 +54,5 @@ extension SortedDictionary: CustomStringConvertible, CustomDebugStringConvertibl } } #endif + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Equatable.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Equatable.swift index cec7ae10..3728fb82 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Equatable.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Equatable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary: Equatable where Value: Equatable { /// Returns a Boolean value indicating whether two values are equal. /// @@ -31,3 +33,5 @@ extension SortedDictionary: Equatable where Value: Equatable { return true } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+ExpressibleByDictionaryLiteral.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+ExpressibleByDictionaryLiteral.swift index 289b1761..3deb0d33 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+ExpressibleByDictionaryLiteral.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+ExpressibleByDictionaryLiteral.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary: ExpressibleByDictionaryLiteral { /// Creates a new sorted dictionary from the contents of a dictionary /// literal. @@ -31,3 +33,5 @@ extension SortedDictionary: ExpressibleByDictionaryLiteral { self.init(keysWithValues: elements) } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Hashable.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Hashable.swift index 7a666091..96a526c0 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Hashable.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Hashable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary: Hashable where Key: Hashable, Value: Hashable { /// Hashes the essential components of this value by feeding them /// into the given hasher. @@ -24,3 +26,5 @@ extension SortedDictionary: Hashable where Key: Hashable, Value: Hashable { } } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Initializers.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Initializers.swift index 6916a6b4..68fe70fb 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Initializers.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Initializers.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary { /// Creates a dictionary from a sequence of key-value pairs. /// @@ -142,3 +144,5 @@ extension SortedDictionary { } } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Keys.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Keys.swift index a1270da8..e42ac650 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Keys.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Keys.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary { /// A view of an sorted dictionary's Keys as a standalone collection. public struct Keys { @@ -257,3 +259,5 @@ extension SortedDictionary.Keys: Hashable where Key: Hashable { } } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Partial RangeReplaceableCollection.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Partial RangeReplaceableCollection.swift index e4a3e5f1..5e2d1b69 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Partial RangeReplaceableCollection.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Partial RangeReplaceableCollection.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary { /// Returns a new sorted dictionary containing the key-value pairs of the /// dictionary that satisfy the given predicate. @@ -172,3 +174,4 @@ extension SortedDictionary { } +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Sendable.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Sendable.swift index 4eeedc16..e8e378c4 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Sendable.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Sendable.swift @@ -2,12 +2,16 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2022 Apple Inc. and the Swift project authors +// Copyright (c) 2022 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary: @unchecked Sendable where Key: Sendable, Value: Sendable {} + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Sequence.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Sequence.swift index 41c8ad83..57bdbd93 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Sequence.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Sequence.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary: Sequence { @inlinable public func forEach(_ body: (Element) throws -> Void) rethrows { @@ -48,3 +50,5 @@ extension SortedDictionary: Sequence { extension SortedDictionary.Iterator: @unchecked Sendable where Key: Sendable, Value: Sendable {} + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+SubSequence.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+SubSequence.swift index 4b23f2dd..9f5fe826 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+SubSequence.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+SubSequence.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary { public struct SubSequence { @usableFromInline @@ -319,3 +321,5 @@ extension SortedDictionary.SubSequence: Hashable where Key: Hashable, Value: Has } } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Subscripts.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Subscripts.swift index e23de48b..bff3c26d 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Subscripts.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Subscripts.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary { /// Accesses the value associated with the key for both read and write operations /// @@ -174,3 +176,5 @@ extension SortedDictionary { return SubSequence(_root[bound]) } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Values.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Values.swift index 356a9df6..5b8be021 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary+Values.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary+Values.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary { /// A view of an sorted dictionary's values as a standalone collection. public struct Values { @@ -276,3 +278,5 @@ extension SortedDictionary.Values: Hashable where Value: Hashable { } } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary.Index.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary.Index.swift index 95cc9d48..aee0c0df 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary.Index.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary.Index.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedDictionary { /// Returns the index for a given key, if it exists /// - Complexity: O(`log n`) @@ -54,3 +56,5 @@ extension SortedDictionary.Index: Comparable { return lhs._index < rhs._index } } + +#endif diff --git a/Sources/SortedCollections/SortedDictionary/SortedDictionary.swift b/Sources/SortedCollections/SortedDictionary/SortedDictionary.swift index 5c72e9d6..1439ded9 100644 --- a/Sources/SortedCollections/SortedDictionary/SortedDictionary.swift +++ b/Sources/SortedCollections/SortedDictionary/SortedDictionary.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + /// A collection which maintains key-value pairs in ascending sorted order. /// /// A sorted dictionary is a type of tree, providing efficient read and write operations @@ -219,3 +221,5 @@ extension SortedDictionary { return SortedDictionary(_rootedAt: builder.finish()) } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+BidirectionalCollection.swift b/Sources/SortedCollections/SortedSet/SortedSet+BidirectionalCollection.swift index a108ff24..49b91534 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+BidirectionalCollection.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+BidirectionalCollection.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet: BidirectionalCollection { /// The number of elements in the sorted set. /// @@ -173,3 +175,5 @@ extension SortedSet: BidirectionalCollection { return self._root.formIndex(&i._index, offsetBy: distance, limitedBy: limit._index) } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Codable.swift b/Sources/SortedCollections/SortedSet/SortedSet+Codable.swift index c2e6998d..3e3b6dca 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Codable.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Codable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if !$Embedded extension SortedSet: Encodable where Element: Encodable { /// Encodes the elements of this ordered set into the given encoder. @@ -52,3 +54,5 @@ extension SortedSet: Decodable where Element: Decodable { } } #endif + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+CustomReflectable.swift b/Sources/SortedCollections/SortedSet/SortedSet+CustomReflectable.swift index b97d6930..3fa0268e 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+CustomReflectable.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+CustomReflectable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if !$Embedded extension SortedSet: CustomReflectable { /// The custom mirror for this instance. @@ -17,3 +19,5 @@ extension SortedSet: CustomReflectable { } } #endif + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+CustomStringConvertible.swift b/Sources/SortedCollections/SortedSet/SortedSet+CustomStringConvertible.swift index ff518fdb..76d2677a 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+CustomStringConvertible.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+CustomStringConvertible.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if !$Embedded extension SortedSet: CustomStringConvertible, CustomDebugStringConvertible { @inlinable @@ -45,3 +47,5 @@ extension SortedSet: CustomStringConvertible, CustomDebugStringConvertible { } } #endif + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Equatable.swift b/Sources/SortedCollections/SortedSet/SortedSet+Equatable.swift index 1818c1e1..e7e60ac6 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Equatable.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Equatable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet: Equatable { /// Returns a Boolean value indicating whether two values are equal. /// @@ -31,3 +33,5 @@ extension SortedSet: Equatable { return true } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+ExpressibleByArrayLiteral.swift b/Sources/SortedCollections/SortedSet/SortedSet+ExpressibleByArrayLiteral.swift index 01f2b040..ec1a7509 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+ExpressibleByArrayLiteral.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+ExpressibleByArrayLiteral.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet: ExpressibleByArrayLiteral { /// Creates a new sorted set from the contents of an array literal. /// @@ -30,3 +32,5 @@ extension SortedSet: ExpressibleByArrayLiteral { self.init(elements) } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Hashable.swift b/Sources/SortedCollections/SortedSet/SortedSet+Hashable.swift index d5cea514..513b637a 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Hashable.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Hashable.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet: Hashable where Element: Hashable { /// Hashes the essential components of this value by feeding them /// into the given hasher. @@ -23,3 +25,5 @@ extension SortedSet: Hashable where Element: Hashable { } } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Initializers.swift b/Sources/SortedCollections/SortedSet/SortedSet+Initializers.swift index dae3a783..c97c2879 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Initializers.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Initializers.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet { /// Creates a new set from a finite sequence of items. /// @@ -51,3 +53,5 @@ extension SortedSet { self.init(_rootedAt: builder.finish()) } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Partial RangeReplaceableCollection.swift b/Sources/SortedCollections/SortedSet/SortedSet+Partial RangeReplaceableCollection.swift index 569f2faa..22c19c50 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Partial RangeReplaceableCollection.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Partial RangeReplaceableCollection.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet { /// Returns a new sorted set containing the members of the set that satisfy the given /// predicate. @@ -172,3 +174,4 @@ extension SortedSet { } } +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Sendable.swift b/Sources/SortedCollections/SortedSet/SortedSet+Sendable.swift index c080c760..7a2f153e 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Sendable.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Sendable.swift @@ -2,11 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2022 Apple Inc. and the Swift project authors +// Copyright (c) 2022 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet: @unchecked Sendable where Element: Sendable {} + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Sequence.swift b/Sources/SortedCollections/SortedSet/SortedSet+Sequence.swift index 676d00bb..d5053b63 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Sequence.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Sequence.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet: Sequence { @inlinable @inline(__always) @@ -52,3 +54,5 @@ extension SortedSet: Sequence { extension SortedSet.Iterator: @unchecked Sendable where Element: Sendable {} + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+SetAlgebra.swift b/Sources/SortedCollections/SortedSet/SortedSet+SetAlgebra.swift index f05df312..bc3dd35d 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+SetAlgebra.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+SetAlgebra.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet: SetAlgebra { // MARK: Testing for Membership @@ -368,3 +370,5 @@ extension SortedSet: SetAlgebra { return true } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+SubSequence.swift b/Sources/SortedCollections/SortedSet/SortedSet+SubSequence.swift index bd718ae0..2e4ab053 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+SubSequence.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+SubSequence.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet { public struct SubSequence { @usableFromInline @@ -318,3 +320,5 @@ extension SortedSet.SubSequence: Hashable where Element: Hashable { } } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Subscripts.swift b/Sources/SortedCollections/SortedSet/SortedSet+Subscripts.swift index 31750b1d..6d76b9d6 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Subscripts.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Subscripts.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet { @inlinable public subscript(position: Index) -> Element { @@ -43,3 +45,5 @@ extension SortedSet { return SubSequence(range) } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet.Index.swift b/Sources/SortedCollections/SortedSet/SortedSet.Index.swift index 24bceb73..a47e4ccf 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet.Index.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet.Index.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + extension SortedSet { /// Returns the index for a given element, if it exists /// - Complexity: O(`log n`) @@ -54,3 +56,5 @@ extension SortedSet.Index: Comparable { return lhs._index < rhs._index } } + +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet.swift b/Sources/SortedCollections/SortedSet/SortedSet.swift index 15a5bde1..1ec406f8 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + /// A collection which maintains unique members in ascending sorted order. public struct SortedSet { @usableFromInline @@ -35,3 +37,5 @@ public struct SortedSet { self._root = tree } } + +#endif diff --git a/Sources/SortedCollections/Utilities/Assertions.swift b/Sources/SortedCollections/Utilities/Assertions.swift deleted file mode 100644 index fda167d4..00000000 --- a/Sources/SortedCollections/Utilities/Assertions.swift +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift Collections open source project -// -// Copyright (c) 2021 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// -//===----------------------------------------------------------------------===// - - diff --git a/Tests/SortedCollectionsTests/BTree/BTree Tests.swift b/Tests/SortedCollectionsTests/BTree/BTree Tests.swift index 4f4ed26c..3c831ce5 100644 --- a/Tests/SortedCollectionsTests/BTree/BTree Tests.swift +++ b/Tests/SortedCollectionsTests/BTree/BTree Tests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -173,3 +175,5 @@ final class BTreeTests: CollectionTestCase { } } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/BTree/BTree+Deletion Tests.swift b/Tests/SortedCollectionsTests/BTree/BTree+Deletion Tests.swift index 7d21886a..bc751e9d 100644 --- a/Tests/SortedCollectionsTests/BTree/BTree+Deletion Tests.swift +++ b/Tests/SortedCollectionsTests/BTree/BTree+Deletion Tests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -55,3 +57,5 @@ final class NodeDeletionTests: CollectionTestCase { } } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/BTree/BTree.Builder Tests.swift b/Tests/SortedCollectionsTests/BTree/BTree.Builder Tests.swift index de3f219a..8c95fd2f 100644 --- a/Tests/SortedCollectionsTests/BTree/BTree.Builder Tests.swift +++ b/Tests/SortedCollectionsTests/BTree/BTree.Builder Tests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -29,3 +31,5 @@ final class BTreeBuilderTests: CollectionTestCase { } } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/BTree/Node Utils.swift b/Tests/SortedCollectionsTests/BTree/Node Utils.swift index 2fc24c2c..1f1e8ae2 100644 --- a/Tests/SortedCollectionsTests/BTree/Node Utils.swift +++ b/Tests/SortedCollectionsTests/BTree/Node Utils.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -83,3 +85,5 @@ func tree(@NodeTemplateBuilder _ builder: () -> NodeTemplate) -> NodeTemplate { return builder() } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/BTree/Node+Balancing Tests.swift b/Tests/SortedCollectionsTests/BTree/Node+Balancing Tests.swift index b26b3ea8..c984be7b 100644 --- a/Tests/SortedCollectionsTests/BTree/Node+Balancing Tests.swift +++ b/Tests/SortedCollectionsTests/BTree/Node+Balancing Tests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -236,3 +238,5 @@ final class NodeBalancingTests: CollectionTestCase { } } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/BTree/Node+Insertion Tests.swift b/Tests/SortedCollectionsTests/BTree/Node+Insertion Tests.swift index f2201ca6..9584af02 100644 --- a/Tests/SortedCollectionsTests/BTree/Node+Insertion Tests.swift +++ b/Tests/SortedCollectionsTests/BTree/Node+Insertion Tests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -545,3 +547,5 @@ final class NodeInsertionTests: CollectionTestCase { } } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/BTree/Node+Join Tests.swift b/Tests/SortedCollectionsTests/BTree/Node+Join Tests.swift index f6654b01..8554ac82 100644 --- a/Tests/SortedCollectionsTests/BTree/Node+Join Tests.swift +++ b/Tests/SortedCollectionsTests/BTree/Node+Join Tests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -105,3 +107,5 @@ final class NodeJoinTests: CollectionTestCase { } } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/BTree/NodeTests.swift b/Tests/SortedCollectionsTests/BTree/NodeTests.swift index e6b19922..6d6ef0cd 100644 --- a/Tests/SortedCollectionsTests/BTree/NodeTests.swift +++ b/Tests/SortedCollectionsTests/BTree/NodeTests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -143,3 +145,5 @@ final class NodeTests: CollectionTestCase { } } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/SortedDictionary/SortedDictionary Tests.swift b/Tests/SortedCollectionsTests/SortedDictionary/SortedDictionary Tests.swift index 4b398852..b5215282 100644 --- a/Tests/SortedCollectionsTests/SortedDictionary/SortedDictionary Tests.swift +++ b/Tests/SortedCollectionsTests/SortedDictionary/SortedDictionary Tests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + #if DEBUG import _CollectionsTestSupport @_spi(Testing) @testable import SortedCollections @@ -283,3 +285,5 @@ final class SortedDictionaryTests: CollectionTestCase { } #endif + +#endif diff --git a/Tests/SortedCollectionsTests/SortedDictionary/SortedDictionary Utils.swift b/Tests/SortedCollectionsTests/SortedDictionary/SortedDictionary Utils.swift index 63ab3f0b..6c8b5529 100644 --- a/Tests/SortedCollectionsTests/SortedDictionary/SortedDictionary Utils.swift +++ b/Tests/SortedCollectionsTests/SortedDictionary/SortedDictionary Utils.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + import _CollectionsTestSupport import SortedCollections @@ -32,3 +34,5 @@ extension LifetimeTracker { return (dictionary, kvs) } } + +#endif diff --git a/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift b/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift index 75aab32a..04a41bff 100644 --- a/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift +++ b/Tests/SortedCollectionsTests/SortedSet/SortedSet Tests.swift @@ -2,13 +2,15 @@ // // This source file is part of the Swift Collections open source project // -// Copyright (c) 2021 Apple Inc. and the Swift project authors +// Copyright (c) 2021 - 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // //===----------------------------------------------------------------------===// +#if COLLECTIONS_UNSTABLE_SORTED_COLLECTIONS + import XCTest @_spi(Testing) import SortedCollections import _CollectionsTestSupport @@ -476,3 +478,5 @@ class SortedSetTests: CollectionTestCase { } } } + +#endif