Files
swift-collections/Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra Initializers.swift
T
Karoy Lorentey c73a8caad1 [PersistentCollections] Clean up _Node.Builder & removals
This sanitizes the semantics of _Node.Builder, removing
the (unneccessary) need to pass around hash paths.

It also slightly refactors removal operations, but stops short of
implementing node shrinking.

# Conflicts:
#	Sources/PersistentCollections/Node/_Node+Builder.swift
#	Sources/PersistentCollections/Node/_Node+Initializers.swift
#	Sources/PersistentCollections/Node/_Node+Structural intersection.swift
#	Sources/PersistentCollections/Node/_Node+Structural subtracting.swift
#	Sources/PersistentCollections/Node/_Node+Subtree Modify.swift
#	Sources/PersistentCollections/Node/_Node+Subtree Removals.swift
#	Sources/PersistentCollections/PersistentDictionary/PersistentDictionary+Initializers.swift
#	Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra Initializers.swift
#	Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra intersection.swift
#	Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra subtracting.swift
2022-10-12 13:05:58 -07:00

42 lines
1022 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2022 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
//
//===----------------------------------------------------------------------===//
extension PersistentSet {
@inlinable
public init() {
self.init(_new: ._emptyNode())
}
@inlinable
public init<S: Sequence>(_ items: __owned S) where S.Element == Element {
if S.self == Self.self {
self = items as! Self
return
}
self.init()
for item in items {
self._insert(item)
}
}
@inlinable
public init(_ items: __owned Self) {
self = items
}
@inlinable
public init<Value>(
_ item: __owned PersistentDictionary<Element, Value>.Keys
) {
self.init(_new: item._base._root.mapValues { _ in () })
}
}