mirror of
https://github.com/apple/swift-collections
synced 2026-11-30 05:18:44 +00:00
Merge pull request #533 from lorentey/unstable-sorted-collections-trait
Add new package trait UnstableSortedCollections
This commit is contained in:
67 files changed
+344
-87
No files matched your search
+21
-9
@@ -25,6 +25,15 @@ let _traits: Set<Trait> = [
|
||||
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,
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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<Key, T>(rootedAt: root, internalCapacity: internalCapacity)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
+5
-1
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
+5
-1
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
+5
-1
@@ -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
|
||||
@@ -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
|
||||
+5
-1
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
+4
-1
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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<Key, T>(_rootedAt: builder.finish())
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
+4
-1
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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<Element: Comparable> {
|
||||
@usableFromInline
|
||||
@@ -35,3 +37,5 @@ public struct SortedSet<Element: Comparable> {
|
||||
self._root = tree
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user