mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
[ContainersPreview] Exhibit A in the case against prototyping things in the stdlib 😞
This commit is contained in:
56 files changed
+200
-98
No files matched your search
@@ -307,6 +307,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
internal mutating func _append<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
@@ -329,6 +330,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: BorrowingSequence<Element> & ~Copyable & ~Escapable>(
|
||||
copying newElements: borrowing S
|
||||
@@ -369,6 +371,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 append<
|
||||
S: BorrowingSequence<Element> & Sequence<Element>
|
||||
|
||||
@@ -36,13 +36,14 @@ extension RigidDeque /*: Equatable */ where Element: Equatable /* & ~Copyable */
|
||||
guard !left.isTriviallyIdentical(to: right) else { return true }
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
return left._elementsEqual(right)
|
||||
#else
|
||||
if #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, visionOS 9999, *) { // FIXME: SwiftStdlib 6.4
|
||||
return left._elementsEqual(right)
|
||||
}
|
||||
#endif
|
||||
for i in 0 ..< left.count {
|
||||
guard left[i] == right[i] else { return false }
|
||||
}
|
||||
return true
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,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<
|
||||
@@ -182,6 +183,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<
|
||||
@@ -203,6 +205,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<
|
||||
|
||||
@@ -353,6 +353,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _insertContainer<
|
||||
C: Container<Element> & ~Copyable & ~Escapable
|
||||
@@ -364,7 +365,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
let expectedCount = self.count + newCount
|
||||
var it = items.makeBorrowingIterator()
|
||||
insert(addingCount: newCount, at: index) { target in
|
||||
it.copyContents(into: &target)
|
||||
it._copyContents(into: &target)
|
||||
}
|
||||
precondition(
|
||||
it.nextSpan().isEmpty && self.count == expectedCount,
|
||||
@@ -415,6 +416,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<
|
||||
@@ -477,6 +479,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<
|
||||
|
||||
@@ -286,6 +286,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
@@ -302,6 +303,7 @@ extension RigidDeque /*where Element: Copyable*/ {
|
||||
_handle.rotate(toStartAtOffset: oldCount)
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
@@ -330,6 +332,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: BorrowingSequence<Element> & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
@@ -347,6 +350,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
|
||||
@@ -434,6 +438,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: BorrowingSequence<Element> & Sequence<Element>>(
|
||||
copying items: borrowing S
|
||||
@@ -450,6 +455,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: BorrowingSequence<Element> & Collection<Element>>(
|
||||
copying items: borrowing S
|
||||
@@ -466,6 +472,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
|
||||
@@ -482,6 +489,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
|
||||
|
||||
@@ -454,6 +454,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _replace<
|
||||
C: Container<Element> & ~Copyable & ~Escapable
|
||||
@@ -466,7 +467,7 @@ extension RigidDeque /* where Element: Copyable */ {
|
||||
let expectedCount = self.count - subrange.count + newCount
|
||||
var it = items.makeBorrowingIterator()
|
||||
self.replace(removing: subrange, addingCount: newCount) { target in
|
||||
it.copyContents(into: &target)
|
||||
it._copyContents(into: &target)
|
||||
}
|
||||
precondition(
|
||||
it.nextSpan().isEmpty && count == expectedCount,
|
||||
@@ -524,6 +525,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<
|
||||
@@ -601,6 +603,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<
|
||||
|
||||
@@ -294,6 +294,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@_alwaysEmitIntoClient
|
||||
internal mutating func _append<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
@@ -318,6 +319,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: BorrowingSequence<Element> & ~Copyable & ~Escapable>(
|
||||
copying items: borrowing S
|
||||
@@ -368,6 +370,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: BorrowingSequence<Element> & Sequence<Element>
|
||||
|
||||
@@ -147,6 +147,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<
|
||||
@@ -186,6 +187,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<
|
||||
@@ -205,6 +207,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<
|
||||
|
||||
@@ -371,6 +371,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _insertContainer<
|
||||
C: Container<Element> & ~Copyable & ~Escapable
|
||||
@@ -382,7 +383,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
let expectedCount = self.count + newCount
|
||||
var it = items.makeBorrowingIterator()
|
||||
insert(addingCount: newCount, at: index) { target in
|
||||
it.copyContents(into: &target)
|
||||
it._copyContents(into: &target)
|
||||
}
|
||||
precondition(
|
||||
it.nextSpan().isEmpty && count == expectedCount,
|
||||
@@ -436,6 +437,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<
|
||||
@@ -502,6 +504,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<
|
||||
|
||||
@@ -316,6 +316,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
@@ -332,6 +333,7 @@ extension UniqueDeque /*where Element: Copyable*/ {
|
||||
_storage._handle.rotate(toStartAtOffset: oldCount)
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _prepend<
|
||||
S: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
@@ -361,6 +363,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: BorrowingSequence<Element> & ~Copyable & ~Escapable
|
||||
@@ -381,6 +384,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
|
||||
@@ -471,6 +475,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: BorrowingSequence<Element> & Sequence<Element>
|
||||
@@ -490,6 +495,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: BorrowingSequence<Element> & Collection<Element>
|
||||
@@ -509,6 +515,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
|
||||
@@ -526,6 +533,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
|
||||
|
||||
@@ -463,6 +463,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
}
|
||||
|
||||
#if compiler(>=6.4) && COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@inlinable
|
||||
internal mutating func _replace<
|
||||
C: Container<Element> & ~Copyable & ~Escapable
|
||||
@@ -475,7 +476,7 @@ extension UniqueDeque /* where Element: Copyable */ {
|
||||
let expectedCount = self.count - subrange.count + newCount
|
||||
var it = items.makeBorrowingIterator()
|
||||
self.replace(removing: subrange, addingCount: newCount) { target in
|
||||
it.copyContents(into: &target)
|
||||
it._copyContents(into: &target)
|
||||
}
|
||||
precondition(
|
||||
it.nextSpan().isEmpty && count == expectedCount,
|
||||
@@ -534,6 +535,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<
|
||||
@@ -613,6 +615,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