Files
swift-collections/Sources/SortedCollections/SortedSet/SortedSet.swift
T
Vihan Bhargava 817c97a403 Implement initial SortedDictionary API and implementations for SortedSet.
Key Changes:
 - SortedSet
   - Implement BidirectionalCollection
 - SortedDictionary
   - Implement Codable
   - Implement Partial RangeReplaceableCollection
     - Includes remove*() operations
   - init(grouping:by:)
   - var keys: Keys (aka SortedSet<Key>)
   - func (compact)mapValues(_:)

Minor Changes:
 - Correct time documented complexities of various methods
 - Implement more variations of removal methods.
2021-08-09 19:13:50 -07:00

35 lines
926 B
Swift

//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
/// An sorted collection of unique elements.
public struct SortedSet<Element: Comparable> {
@usableFromInline
internal typealias _Tree = _BTree<Element, ()>
@usableFromInline
internal var _root: _Tree
/// Creates an empty set.
///
/// - 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
}
}