mirror of
https://github.com/apple/swift-collections
synced 2026-11-24 04:27:53 +00:00
This re-enables the SortedCollections for easi(er) experimentation. The module remains source unstable — it may go away entirely or it may receive arbitrary source-breaking changes in any new swift-collections release, with no special pre-announcement.
42 lines
1.1 KiB
Swift
42 lines
1.1 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift Collections open source project
|
|
//
|
|
// 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
|
|
internal typealias _Tree = _BTree<Element, ()>
|
|
|
|
@usableFromInline
|
|
internal var _root: _Tree
|
|
|
|
//// Creates an empty set.
|
|
///
|
|
/// This initializer is equivalent to initializing with an empty array
|
|
/// literal.
|
|
///
|
|
/// - Complexity: O(1)
|
|
@inlinable
|
|
@inline(__always)
|
|
public init() {
|
|
self._root = _Tree()
|
|
}
|
|
|
|
/// Creates a set rooted at a given B-Tree.
|
|
@inlinable
|
|
internal init(_rootedAt tree: _Tree) {
|
|
self._root = tree
|
|
}
|
|
}
|
|
|
|
#endif
|