mirror of
https://github.com/apple/swift-collections
synced 2026-11-29 05:14:20 +00:00
Merge pull request #606 from lorentey/container-upgrades
1.4.1 release preparations
This commit is contained in:
7 files changed
+36
-4
No files matched your search
@@ -150,9 +150,16 @@ This trait enables the following types in the [`ContainersPreview`][ContainersPr
|
||||
- [`struct InputSpan<Element>`][InputSpan] is a reference to a contiguous region of consumable items.
|
||||
- [`struct Borrow<Target>`][Borrow] represents a borrowing reference to an item.
|
||||
- [`struct Inout<Target>`][Inout] represents a mutating reference to an item.
|
||||
|
||||
- [`protocol BorrowingSequence<Element>`][BorrowingSequence] models borrowing sequences with ephemeral lifetimes.
|
||||
- [`protocol BorrowingIteratorProtocol<Element>`][BorrowingIteratorProtocol] models borrowing iterators with ephemeral elements.
|
||||
- [`protocol Container<Element>`][Container] models containers, or constructs that physically store their contents.
|
||||
- [`protocol BidirectionalContainer<Element>`][BidirectionalContainer] is the container analogue of `BidirectionalCollection`.
|
||||
- [`protocol RandomAccessContainer<Element>`][RandomAccessContainer] is the container analogue of `RandomAccessCollection`.
|
||||
- [`protocol PermutableContainer<Element>`][PermutableContainer] models a container that allows items to be arbitrarily reordered (sorted, reversed, etc).
|
||||
- [`protocol MutableContainer<Element>`][MutableContainer] refines `PermutableContainer` to also support arbitrary element replacements/mutations, like `MutableCollection`.
|
||||
- [`protocol RangeReplaceableContainer<Element>`][RangeReplaceableContainer] models a (potentially fixed capacity) container with insert/append/replace operations.
|
||||
- [`protocol DynamicContainer<Element>`][DynamicContainer] refines `RangeReplaceableContainer` to add operations that require dynamic storage sizing.
|
||||
- [`protocol Producer<Element, ProducerError>`][Producer] models a generative iterator -- an abstraction for producing items on demand.
|
||||
- [`protocol Drain<Element>`][Drain] refines `Producer` to model an in-place consumable elements -- primarily for use around container types.
|
||||
|
||||
@@ -161,14 +168,19 @@ This trait enables the following types in the [`ContainersPreview`][ContainersPr
|
||||
[Inout]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Types/Inout.swift
|
||||
[BorrowingSequence]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/BorrowingSequence.swift
|
||||
[BorrowingIteratorProtocol]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/BorrowingIteratorProtocol.swift
|
||||
[Container]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Container.swift
|
||||
[Container]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Container/Container.swift
|
||||
[BidirectionalContainer]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Container/Container.swift
|
||||
[RandomAccessContainer]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Container/RandomAccessContainer.swift
|
||||
[PermutableContainer]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Container/PermutableContainer.swift
|
||||
[MutableContainer]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Container/MutableContainer.swift
|
||||
[RangeReplaceableContainer]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Container/RangeReplaceableContainer.swift
|
||||
[DynamicContainer]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Container/DynamicContainer.swift
|
||||
[Producer]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Producer.swift
|
||||
[Drain]: https://github.com/apple/swift-collections/blob/main/Sources/ContainersPreview/Protocols/Drain.swift
|
||||
|
||||
The trait also enables a large list of new APIs throughout the package that make use of these constructs -- such as generic methods for transferring items between container types, and implementations of the classic `map`/`reduce`/`filter`/etc algorithms.
|
||||
|
||||
The trait also enables a large list of new APIs throughout the package that make use of these constructs -- such as generic methods for transferring items between container types.
|
||||
|
||||
These constructs are previews of potential stdlib additions. As of March 2026, some of these are already making their way through the Swift Evolution process; others are still highly experimental. These need to remain unstable, as we expect that (as usual) these construct will see some API breaking changes on their way to the stdlib; additionally, they will likely need to be removed from the package entirely once they are fully adopted into the Standard Library. (It would not be feasible to maintain two distinct versions of universal library primitives, or basic protocols / generic algorithms.)
|
||||
These constructs are previews of potential stdlib additions. As of March 2026, some of these are already making their way through the Swift Evolution process; others are still unfinished and highly experimental. These need to remain unstable, as we expect that (as usual) these construct will see some API breaking changes on their way to the stdlib; additionally, they will likely need to be removed from the package entirely once they are fully adopted into the Standard Library. (It would not be feasible to maintain two distinct versions of universal library primitives, or basic protocols / generic algorithms.)
|
||||
|
||||
### `UnstableHashedContainers` package trait
|
||||
|
||||
|
||||
@@ -401,6 +401,7 @@ extension RigidArray where Element: ~Copyable {
|
||||
return _span(in: Range(uncheckedBounds: (start, index)))
|
||||
}
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
@inlinable
|
||||
@_lifetime(&self)
|
||||
public mutating func nextMutableSpan(after index: inout Int, maximumCount: Int) -> MutableSpan<Element> {
|
||||
@@ -422,6 +423,7 @@ extension RigidArray where Element: ~Copyable {
|
||||
index = start &- Swift.min(maximumCount, start)
|
||||
return _span(in: Range(uncheckedBounds: (index, start)))
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -357,6 +357,7 @@ extension UniqueArray where Element: ~Copyable {
|
||||
_storage.nextSpan(after: &index, maximumCount: maximumCount)
|
||||
}
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
@inlinable
|
||||
@_lifetime(&self)
|
||||
public mutating func nextMutableSpan(
|
||||
@@ -372,6 +373,7 @@ extension UniqueArray where Element: ~Copyable {
|
||||
) -> Span<Element> {
|
||||
_storage.previousSpan(before: &index, maximumCount: maximumCount)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -32,11 +32,13 @@ extension UniqueArray where Element: ~Copyable {
|
||||
_storage = .init(capacity: capacity)
|
||||
}
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
/// Initializes a new unique array with the specified capacity and no elements.
|
||||
@inlinable
|
||||
public init(minimumCapacity: Int) {
|
||||
_storage = .init(capacity: minimumCapacity)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
|
||||
@@ -89,17 +89,21 @@ extension RigidDeque where Element: ~Copyable {
|
||||
@inline(__always)
|
||||
public func index(after index: Int) -> Int { index + 1 }
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public func index(before index: Int) -> Int { index - 1 }
|
||||
#endif
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public func formIndex(after index: inout Int) { index += 1 }
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public func formIndex(before index: inout Int) { index -= 1 }
|
||||
#endif
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
@@ -126,6 +130,7 @@ extension RigidDeque where Element: ~Copyable {
|
||||
return _overrideLifetime(Span(_unsafeElements: segment), borrowing: self)
|
||||
}
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
@_lifetime(&self)
|
||||
public mutating func nextMutableSpan(
|
||||
after index: inout Int, maximumCount: Int
|
||||
@@ -150,6 +155,7 @@ extension RigidDeque where Element: ~Copyable {
|
||||
index &-= segment.count
|
||||
return _overrideLifetime(Span(_unsafeElements: segment), borrowing: self)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -60,17 +60,21 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
@inline(__always)
|
||||
public func index(after index: Int) -> Int { index + 1 }
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public func index(before index: Int) -> Int { index - 1 }
|
||||
#endif
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public func formIndex(after index: inout Int) { index += 1 }
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
public func formIndex(before index: inout Int) { index -= 1 }
|
||||
#endif
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@inline(__always)
|
||||
@@ -91,6 +95,7 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
_storage.nextSpan(after: &index, maximumCount: maximumCount)
|
||||
}
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
@_lifetime(&self)
|
||||
public mutating func nextMutableSpan(
|
||||
after index: inout Int, maximumCount: Int
|
||||
@@ -103,6 +108,7 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
public func previousSpan(before index: inout Int, maximumCount: Int) -> Span<Element> {
|
||||
_storage.previousSpan(before: &index, maximumCount: maximumCount)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -36,12 +36,14 @@ extension UniqueDeque where Element: ~Copyable {
|
||||
_storage = .init(capacity: capacity)
|
||||
}
|
||||
|
||||
#if COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW // FIXME: Enable unconditionally in 1.5.0
|
||||
/// Creates an empty unique deque with the specified capacity.
|
||||
@_alwaysEmitIntoClient
|
||||
@_transparent
|
||||
public init(minimumCapacity: Int) {
|
||||
_storage = .init(capacity: minimumCapacity)
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Creates a unique deque with the specified capacity, then calls the given
|
||||
/// closure with an output span covering the deque's uninitialized memory.
|
||||
|
||||
Reference in new issue
Block a user