mirror of
https://github.com/apple/swift-collections
synced 2026-11-28 05:04:21 +00:00
Use Iterable from the Standard Library, replacing the local definition
This commit is contained in:
68 files changed
+565
-921
No files matched your search
@@ -19,15 +19,14 @@ import ContainersPreview
|
||||
#if compiler(>=6.4) && UnstableHashedContainers && UnstableContainersPreview
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension UniqueSet: Iterable_ where Element: ~Copyable {
|
||||
public typealias Element_ = Element
|
||||
public typealias BorrowingIterator_ = RigidSet<Element>.BorrowingIterator_
|
||||
extension UniqueSet: Iterable where Element: ~Copyable {
|
||||
public typealias BorrowingIterator = RigidSet<Element>.BorrowingIterator
|
||||
|
||||
@inlinable
|
||||
public var underestimatedCount_: Int { count }
|
||||
public var underestimatedCount: Int { count }
|
||||
|
||||
@inlinable
|
||||
public func _customContainsEquatableElement_(
|
||||
public func _customContainsEquatableElement(
|
||||
_ element: borrowing Element
|
||||
) -> Bool? {
|
||||
self.contains(element)
|
||||
@@ -35,8 +34,8 @@ extension UniqueSet: Iterable_ where Element: ~Copyable {
|
||||
|
||||
@inlinable
|
||||
@_lifetime(borrow self)
|
||||
public borrowing func makeBorrowingIterator_() -> BorrowingIterator_ {
|
||||
BorrowingIterator_(_set: _storage)
|
||||
public borrowing func makeBorrowingIterator() -> BorrowingIterator {
|
||||
BorrowingIterator(_set: _storage)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -77,12 +77,10 @@ extension UniqueSet where Element: Copyable {
|
||||
#if UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public init<
|
||||
S: Iterable_ & ~Copyable & ~Escapable
|
||||
>(
|
||||
public init<S: Iterable & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
) throws(S.Failure)
|
||||
where S.Element == Element {
|
||||
self.init()
|
||||
try self.insert(copying: items)
|
||||
}
|
||||
@@ -97,12 +95,10 @@ extension UniqueSet where Element: Copyable {
|
||||
#if UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public init<
|
||||
S: Iterable_ & Sequence<Element>
|
||||
>(
|
||||
public init<S: Iterable & Sequence<Element>>(
|
||||
copying items: borrowing S
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
) throws(S.Failure)
|
||||
where S.Element == Element {
|
||||
self.init()
|
||||
try self._insert(copying: items)
|
||||
}
|
||||
|
||||
@@ -134,15 +134,15 @@ extension UniqueSet /* where Element: Copyable */ {
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
package mutating func _insert<
|
||||
S: Iterable_ & ~Copyable & ~Escapable
|
||||
S: Iterable & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
_ensureFreeCapacity(items.underestimatedCount_)
|
||||
var it = items.makeBorrowingIterator_()
|
||||
) throws(S.Failure)
|
||||
where S.Element == Element {
|
||||
_ensureFreeCapacity(items.underestimatedCount)
|
||||
var it = items.makeBorrowingIterator()
|
||||
while true {
|
||||
let span = try it.nextSpan_()
|
||||
let span = try it.nextSpan()
|
||||
guard !span.isEmpty else { break }
|
||||
self.insert(copying: span)
|
||||
}
|
||||
@@ -154,10 +154,10 @@ extension UniqueSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
S: Iterable_ & ~Copyable & ~Escapable
|
||||
S: Iterable & ~Copyable & ~Escapable
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) throws(S.Failure_) where S.Element_ == Element {
|
||||
) throws(S.Failure) where S.Element == Element {
|
||||
try _insert(copying: items)
|
||||
}
|
||||
#endif
|
||||
@@ -177,11 +177,11 @@ extension UniqueSet /* where Element: Copyable */ {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
S: Iterable_ & Sequence<Element>
|
||||
S: Iterable & Sequence<Element>
|
||||
>(
|
||||
copying items: borrowing S
|
||||
) throws(S.Failure_)
|
||||
where S.Element_ == Element {
|
||||
) throws(S.Failure)
|
||||
where S.Element == Element {
|
||||
try _insert(copying: items)
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user