mirror of
https://github.com/apple/swift-collections
synced 2026-11-26 04:47:48 +00:00
Bump availability of Iterable_ and Container protocols to SwiftStdlib 6.4
This is preparing for switching over to the stdlib’s definition of `protocol Iterable`, assuming it will land with macOS 27/iOS 27 etc availability; `Container` is refining `Iterable`, so it needs matching availability. If `Iterable` won’t ship in Swift 6.4, then we’ll need to bump this again.
This commit is contained in:
66 files changed
+645
-418
No files matched your search
@@ -311,6 +311,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
internal mutating func _append<
|
||||
S: Iterable_ & ~Copyable & ~Escapable
|
||||
@@ -334,6 +335,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - newElements: The new elements to copy into the deque.
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `newElements`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
copying newElements: borrowing S
|
||||
@@ -375,6 +377,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - items: The new elements to copy into the deque.
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`. @available(SwiftStdlib 5.0, *)
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<
|
||||
S: Iterable_ & Sequence<Element>
|
||||
|
||||
@@ -40,13 +40,14 @@ extension RigidDeque where Element: Equatable & ~Copyable {
|
||||
guard !left.isTriviallyIdentical(to: right) else { return true }
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
return left._elementsEqual(right)
|
||||
#else
|
||||
if #available(anyAppleOS 27, *) {
|
||||
return left._elementsEqual(right)
|
||||
}
|
||||
#endif
|
||||
for i in 0 ..< left.count {
|
||||
guard left[i] == right[i] else { return false }
|
||||
}
|
||||
return true
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - capacity: The storage capacity of the new deque.
|
||||
/// - contents: A sequence whose contents to copy into the new deque.
|
||||
/// The sequence must not contain more than `capacity` elements.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
@@ -183,6 +184,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - capacity: The storage capacity of the new deque.
|
||||
/// - contents: A sequence whose contents to copy into the new deque.
|
||||
/// The sequence must not contain more than `capacity` elements.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<S: Iterable_ & Sequence<Element>>(
|
||||
@@ -193,7 +195,9 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
self.init(capacity: capacity)
|
||||
try self._append(copying: contents)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
/// Creates a new deque with the specified capacity, holding a copy
|
||||
/// of the contents of a given collection.
|
||||
///
|
||||
@@ -203,6 +207,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// than or equal to the count of the collection.
|
||||
/// - contents: A collection whose contents to copy into the new deque.
|
||||
/// The sequence must not contain more than `capacity` elements.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<S: Iterable_ & Collection<Element>>(
|
||||
|
||||
@@ -356,6 +356,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _insertContainer<
|
||||
C: Container<Element> & ~Copyable & ~Escapable
|
||||
@@ -418,6 +419,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
/// a valid index of the deque.
|
||||
///
|
||||
/// - Complexity: O(`self.count` + `items.count`).
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
@@ -480,6 +482,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
/// a valid index of the deque.
|
||||
///
|
||||
/// - Complexity: O(`self.count` + `items.count`)
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
|
||||
@@ -288,6 +288,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: Iterable_ & ~Copyable & ~Escapable
|
||||
@@ -307,6 +308,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
_handle.rotate(toStartAtOffset: oldCount)
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: Iterable_ & ~Copyable & ~Escapable
|
||||
@@ -336,6 +338,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - items: The new elements to copy into the deque.
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
@@ -354,6 +357,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - items: The new elements to copy into the deque.
|
||||
///
|
||||
/// - Complexity: O(`items.count`)
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<C: Container<Element> & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing C
|
||||
@@ -441,6 +445,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - items: The new elements to copy into the deque.
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: Iterable_ & Sequence<Element>>(
|
||||
copying items: borrowing S
|
||||
@@ -458,6 +463,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - items: The new elements to copy into the deque.
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: Iterable_ & Collection<Element>>(
|
||||
copying items: borrowing S
|
||||
@@ -475,6 +481,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - items: The new elements to copy into the deque.
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<C: Container<Element> & Sequence<Element>>(
|
||||
copying items: borrowing C
|
||||
@@ -491,6 +498,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
/// - items: The new elements to copy into the deque.
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<C: Container<Element> & Collection<Element>>(
|
||||
copying items: borrowing C
|
||||
|
||||
@@ -153,7 +153,6 @@ extension RigidDeque where Element: ~Copyable {
|
||||
return _handle.uncheckedRemoveFirst()
|
||||
}
|
||||
|
||||
#if !UnstableContainersPreview
|
||||
/// Removes and returns the last element of the deque, if there is one.
|
||||
///
|
||||
/// - Returns: The last element of the original deque if it was not empty;
|
||||
@@ -162,10 +161,11 @@ extension RigidDeque where Element: ~Copyable {
|
||||
/// - Complexity: O(1)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func popLast() -> Element? {
|
||||
// FIXME: Remove this algorithm; it is already provided by
|
||||
// RangeReplaceableContainer, albeit with stricter availability.
|
||||
guard !isEmpty else { return nil }
|
||||
return _handle.uncheckedRemoveLast()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -456,6 +456,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _replace<
|
||||
C: Container<Element> & ~Copyable & ~Escapable
|
||||
@@ -529,6 +530,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
/// - items: The new elements to copy into the collection.
|
||||
///
|
||||
/// - Complexity: O(`self.count` + `items.count`)
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public mutating func replace<
|
||||
@@ -606,6 +608,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
///
|
||||
/// - Complexity: O(*n* + *m*), where *n* is count of this deque and
|
||||
/// *m* is the count of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public mutating func replace<
|
||||
|
||||
@@ -298,6 +298,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
internal mutating func _append<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
@@ -323,6 +324,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`, when amortized
|
||||
/// over many similar invocations on the same deque
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
@@ -374,6 +376,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`, when
|
||||
/// amortized over many similar invocations over the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func append<S: Iterable_ & Sequence<Element>>(
|
||||
copying items: S
|
||||
|
||||
@@ -142,6 +142,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// - capacity: The storage capacity of the new deque, or nil to let the
|
||||
/// deque grow itself as needed to accomodate all items in `contents`.
|
||||
/// - contents: A sequence whose contents to copy into the new deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
@@ -180,6 +181,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// deque grow itself as needed to accomodate all items in `contents`.
|
||||
/// - contents: A sequence whose contents to copy into the new deque.
|
||||
/// The sequence must not contain more than `capacity` elements.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<S: Iterable_ & Sequence<Element>>(
|
||||
@@ -198,6 +200,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
/// - capacity: The storage capacity of the new deque.
|
||||
/// - contents: A sequence whose contents to copy into the new deque.
|
||||
/// The sequence must not contain more than `capacity` elements.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public init<S: Iterable_ & Collection<Element>>(
|
||||
|
||||
@@ -374,6 +374,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _insertContainer<
|
||||
C: Container<Element> & ~Copyable & ~Escapable
|
||||
@@ -439,6 +440,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
///
|
||||
/// - Complexity: O(`self.count` + `items.count`) when amortized over many
|
||||
/// similar invocations on the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
@@ -505,6 +507,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
///
|
||||
/// - Complexity: O(`self.count` + `items.count`) when amortized over many
|
||||
/// similar invocations on the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func insert<
|
||||
|
||||
@@ -320,6 +320,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
@@ -338,6 +339,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
_storage._handle.rotate(toStartAtOffset: oldCount)
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S,
|
||||
@@ -366,6 +368,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`, as amortized
|
||||
/// over many similar invocations on the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: Iterable_ & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
@@ -385,6 +388,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(`items.count`) when amortized over many similar
|
||||
/// invocations on the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<C: Container<Element> & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing C
|
||||
@@ -477,6 +481,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items`, as amortized
|
||||
/// over many similar invocations on the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: Iterable_ & Sequence<Element>>(
|
||||
copying items: borrowing S
|
||||
@@ -495,6 +500,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items` when amortized
|
||||
/// over many similar invocations on the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<S: Iterable_ & Collection<Element>>(
|
||||
copying items: borrowing S
|
||||
@@ -513,6 +519,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items` when amortized
|
||||
/// over many similar invocations on the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<C: Container<Element> & Sequence<Element>>(
|
||||
copying items: borrowing C
|
||||
@@ -530,6 +537,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
///
|
||||
/// - Complexity: O(*m*), where *m* is the length of `items` when amortized
|
||||
/// over many similar invocations on the same deque.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public mutating func prepend<C: Container<Element> & Collection<Element>>(
|
||||
copying items: C
|
||||
|
||||
@@ -136,7 +136,6 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
_storage.popFirst()
|
||||
}
|
||||
|
||||
#if !UnstableContainersPreview
|
||||
/// Removes and returns the last element of the deque, if there is one.
|
||||
///
|
||||
/// - Returns: The last element of the original deque if it was not empty;
|
||||
@@ -146,9 +145,10 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public mutating func popLast() -> Element? {
|
||||
// FIXME: Remove this algorithm; it is already provided by
|
||||
// RangeReplaceableContainer, albeit with stricter availability.
|
||||
_storage.popLast()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -465,6 +465,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && UnstableContainersPreview
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _replace<
|
||||
C: Container<Element> & ~Copyable & ~Escapable
|
||||
@@ -539,6 +540,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
/// - items: The new elements to copy into the collection.
|
||||
///
|
||||
/// - Complexity: O(`self.count` + `items.count`)
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public mutating func replace<
|
||||
@@ -618,6 +620,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
///
|
||||
/// - Complexity: O(*n* + *m*), where *n* is count of this deque and
|
||||
/// *m* is the count of `items`.
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
@inline(__always)
|
||||
public mutating func replace<
|
||||
|
||||
Reference in new issue
Block a user