Review and update container protocols and conformances

- @inlinable → @_alwaysEmitIntoClient for now, to avoid temporary ABI issues
- Review RangeReplaceableContainer algorithms; add missing ones:
    - New requirements: `removeFirst()`, `removeFirst(_:)`, `_customRemoveLast()`, `_customRemoveLast(_:) (with default implementations)
    - `func removeAll()`
    - `func removeLast()`, `func removeLast(_:)`, `func popLast()` when self is also bidirectional
- Review RigidArray, UniqueArray algorithms; remove ones needlessly duplicating functionality already provided by RRC. Try not to break source compatibility.
This commit is contained in:
Karoy Lorentey committed 2026-07-07 14:18:09 -07:00
1 parent 204e94cb63
commit 3ba8d70ec3
36 files changed
+415 -644

No files matched your search

-1
View File
@@ -116,7 +116,6 @@ let extraSettings: [SwiftSetting] = [
.enableExperimentalFeature("AddressableParameters"),
.enableExperimentalFeature("AddressableTypes"),
.enableExperimentalFeature("SuppressedAssociatedTypesWithDefaults"), // Requires Swift 6.4
.enableExperimentalFeature("BorrowAndMutateAccessors"),
// Note: if you touch these, please make sure to also update the similar lists in
// CMakeLists.txt and Xcode/Shared.xcconfig.
]
@@ -130,6 +130,7 @@ extension RigidArray where Element: ~Copyable {
public mutating func append(
moving items: inout InputSpan<Element>
) {
// FIXME: Remove this when `InputSpan` starts conforming to RangeReplaceableContainer
items.withUnsafeMutableBufferPointer { buffer, count in
let source = buffer._extracting(last: count)
unsafe self.append(moving: source)
@@ -152,6 +153,7 @@ extension RigidArray where Element: ~Copyable {
public mutating func append(
moving items: inout OutputSpan<Element>
) {
// FIXME: Remove this when `OutputSpan` starts conforming to RangeReplaceableContainer
items.withUnsafeMutableBufferPointer { buffer, count in
let source = buffer._extracting(first: count)
unsafe self.append(moving: source)
@@ -159,6 +161,7 @@ extension RigidArray where Element: ~Copyable {
}
}
#if !UnstableContainersPreview
/// Appends the elements of a given array to the end of this array by moving
/// them between the containers. On return, the input array becomes empty, but
/// it is not destroyed, and it preserves its original storage capacity.
@@ -174,107 +177,10 @@ extension RigidArray where Element: ~Copyable {
public mutating func append(
moving items: inout RigidArray<Element>
) {
// FIXME: Remove this in favor of a generic algorithm over range-replaceable containers
items.edit { span in
self.append(moving: &span)
}
}
}
@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
#if UnstableContainersPreview
/// Appends the elements of a given container to the end of this array by
/// consuming the source container.
///
/// If the target array does not have sufficient capacity to hold all items
/// in the source array, then this triggers a runtime error.
///
/// - Parameters:
/// - items: A container whose contents to move into this array.
///
/// - Complexity: O(`items.count`)
@_alwaysEmitIntoClient
public mutating func append(
consuming items: consuming RigidArray<Element>
) {
// FIXME: Remove this in favor of a generic algorithm over consumable containers
var items = items
self.append(moving: &items)
}
#endif
}
@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
#if compiler(>=6.4) && UnstableContainersPreview
/// Appends at most `newItemCount` items generated by a producer to the end of
/// this array.
///
/// If the array doesn't have sufficient capacity to accommodate the specified
/// number of new elements, then this method reallocates the array's storage
/// to grow it, using a geometric growth rate.
///
/// This operation appends as many items as the producer can generate before
/// either reaching its end (or throwing an error), or filling the specified
/// capacity. This operation only consumes the first `newItemCount` items in the
/// producer; if the producer has more, then they remain available after this
/// method returns.
///
/// - Parameters:
/// - newItemCount: The maximum number of items to append to the array.
/// - producer: A producer that generates the items to append.
///
/// - Complexity: O(*n*) where *n* is the number of new items, when
/// amortized over many similar invocations on the same array.
@_alwaysEmitIntoClient
public mutating func append<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
>(
addingCount newItemCount: Int,
from producer: inout P
) throws(E)
where P.Element: ~Copyable
{
try self.append(addingCount: newItemCount) { target throws(E) in
while !target.isFull {
guard try producer.generate(into: &target) else { break }
}
}
}
#endif
#if compiler(>=6.4) && UnstableContainersPreview
/// Appends all the items generated by a producer to the end of this deque.
///
/// If the deque doesn't have sufficient capacity to accommodate all the
/// elements, then this method reallocates the deque's storage
/// to grow it, using a geometric growth rate.
///
/// - Parameters:
/// - producer: A producer that generates the items to append.
///
/// - Complexity: O(*n*) where *n* is the number of new items, when
/// amortized over many similarly-sized invocations on the same deque.
@_alwaysEmitIntoClient
public mutating func append<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
>(
from producer: inout P
) throws(E)
where P.Element: ~Copyable
{
var done = false
while !done {
try self.append(addingCount: freeCapacity) { target throws(E) in
while !target.isFull, !done {
done = try !producer.generate(into: &target)
}
}
}
}
#endif
}
@@ -138,7 +138,7 @@ extension RigidArray where Element: ~Copyable {
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
@_alwaysEmitIntoClient
@inline(__always)
@@ -148,9 +148,9 @@ extension RigidArray where Element: ~Copyable {
}
}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
@frozen
public struct SubrangeConsumer: ~Copyable, ~Escapable {
// FIXME: We have to use our own MutableRef because the standard one
@@ -191,11 +191,11 @@ extension RigidArray where Element: ~Copyable {
}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidArray.SubrangeConsumer: Drain where Element: ~Copyable {
}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidArray.SubrangeConsumer where Element: ~Copyable {
@inlinable
public var count: Int {
@@ -44,7 +44,7 @@ extension RigidArray: RandomAccessContainer where Element: ~Copyable {}
@available(SwiftStdlib 5.0, *)
extension RigidArray: MutableContainer where Element: ~Copyable {}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidArray: RangeReplaceableContainer where Element: ~Copyable {}
#endif
#endif
@@ -170,6 +170,7 @@ extension RigidArray where Element: ~Copyable {
moving items: inout InputSpan<Element>,
at index: Int
) {
// FIXME: Remove when InputSpan starts conforming to RangeReplaceableContainer
items.withUnsafeMutableBufferPointer { buffer, count in
let source = buffer._extracting(last: count)
unsafe self.insert(moving: source, at: index)
@@ -199,6 +200,7 @@ extension RigidArray where Element: ~Copyable {
moving items: inout OutputSpan<Element>,
at index: Int
) {
// FIXME: Remove when OutputSpan starts conforming to RangeReplaceableContainer
items.withUnsafeMutableBufferPointer { buffer, count in
let source = buffer._extracting(first: count)
unsafe self.insert(moving: source, at: index)
@@ -206,6 +208,7 @@ extension RigidArray where Element: ~Copyable {
}
}
#if !UnstableContainersPreview
/// Inserts the elements of a given array into the given position in this
/// array by moving them between the containers. On return, the input array
/// becomes empty, but it is not destroyed, and it preserves its original
@@ -234,88 +237,9 @@ extension RigidArray where Element: ~Copyable {
self.insert(moving: &source, at: index)
}
}
}
@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
#if UnstableContainersPreview
/// Inserts the elements of a given array into the given position in this
/// array by consuming the source container.
///
/// All existing elements at or following the specified position are moved to
/// make room for the new items.
///
/// If the capacity of the array isn't sufficient to accommodate the new
/// elements, then this method triggers a runtime error.
///
/// - Parameters:
/// - items: The array whose contents to move into `self`.
/// - index: The position at which to insert the new items.
/// `index` must be a valid index in the array.
///
/// - Complexity: O(`count` + `items.count`)
@_alwaysEmitIntoClient
public mutating func insert(
consuming items: consuming RigidArray<Element>,
at index: Int
) {
// FIXME: Remove this in favor of a generic algorithm over consumable containers
var items = items
self.insert(moving: &items, at: index)
}
#endif
}
@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
#if compiler(>=6.4) && UnstableContainersPreview
/// Inserts at most `newItemCount` items generated by a producer into this
/// array, starting at the given index.
///
/// Existing elements in the array's storage are moved as needed to make room
/// for the new items.
///
/// If the target array does not have sufficient capacity to hold the
/// specified number of new items, then this triggers a runtime error.
///
/// This operation inserts as many items as the producer can generate before
/// either reaching `newItemCount`, or the producer hitting its end, or
/// throwing an error. If the producer has more than `newItemCount` items
/// left in its underlying sequence, then extra items remain available after
/// this method returns.
///
/// If the operation inserts fewer than `newItemCount` items, then it results
/// in a gap in ring buffer storage that needs to be closed by moving some
/// items to their correct positions given the adjusted count. This adds some
/// overhead compared to adding exactly as many items as promised.
///
/// - Parameters:
/// - newItemCount: The maximum number of items to insert into the array.
/// - index: The position at which to insert the new items.
/// `index` must be a valid index in the array.
/// - producer: A producer that generates the items to append.
///
/// - Complexity: O(`self.count` + `newItemCount`)
@_alwaysEmitIntoClient
public mutating func insert<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
>(
addingCount newItemCount: Int,
from producer: inout P,
at index: Int
) throws(E)
where P.Element: ~Copyable
{
try insert(addingCount: newItemCount, at: index) { target throws(E) in
while !target.isFull, try producer.generate(into: &target) {
// Do nothing
}
}
}
#endif
}
@available(SwiftStdlib 5.0, *)
extension RigidArray {
/// Copies the elements of a fully initialized buffer pointer into this
@@ -406,82 +330,28 @@ extension RigidArray {
}
}
#if compiler(>=6.4) && UnstableContainersPreview
#if !UnstableContainersPreview
@_alwaysEmitIntoClient
internal mutating func _insertContainer<
C: Container<Element> & ~Copyable & ~Escapable
>(
at index: Int,
copying items: borrowing C,
newCount: Int
package mutating func _insertCollection(
addingCount newCount: Int,
copying items: some Collection<Element>,
at index: Index
) {
var it = items.makeIterableIterator_()
insert(addingCount: newCount, at: index) { target in
while !target.isFull {
let source = it.nextSpan_(maximumCount: target.freeCapacity)
precondition(!source.isEmpty, "Broken container: mismatching count")
target._append(copying: source)
let done: Void? = items.withContiguousStorageIfAvailable { buffer in
precondition(buffer.count == newCount, "Broken Collection: mismatching count")
self.insert(addingCount: buffer.count, at: index) { target in
target._append(copying: buffer)
}
}
precondition(it.nextSpan_().isEmpty, "Broken container: mismatching count")
}
#endif
@inlinable
internal mutating func _insertCollection(
at index: Int,
copying items: some Collection<Element>,
newCount: Int
) {
_checkValidIndex(index)
precondition(newCount <= freeCapacity, "RigidArray capacity overflow")
let gap = unsafe _openGap(at: index, count: newCount)
let done: Void? = items.withContiguousStorageIfAvailable { buffer in
let i = unsafe gap._initializePrefix(copying: buffer)
precondition(
i == newCount,
"Broken Collection: count doesn't match contents")
_count += newCount
}
if done != nil { return }
var (it, copied) = unsafe items._copyContents(initializing: gap)
precondition(
it.next() == nil && copied == newCount,
"Broken Collection: count doesn't match contents")
_count += newCount
}
#if compiler(>=6.4) && UnstableContainersPreview
/// Copies the elements of a container into this array at the specified
/// position.
///
/// The new elements are inserted before the element currently at the
/// specified index. If you pass the array's `endIndex` as the `index`
/// parameter, then the new elements are appended to the end of the array.
///
/// All existing elements at or following the specified position are moved to
/// make room for the new item.
///
/// If the capacity of the array isn't sufficient to accommodate the new
/// elements, then this method triggers a runtime error.
///
/// - Parameters:
/// - newElements: The new elements to insert into the array.
/// - index: The position at which to insert the new elements. It must be
/// a valid index of the array.
///
/// - Complexity: O(`self.count` + `newElements.count`).
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
C: Container<Element> & ~Copyable & ~Escapable
>(
copying newElements: borrowing C, at index: Int
) {
_insertContainer(
at: index, copying: newElements, newCount: newElements.count)
var it = items.makeIterator()
self.insert(addingCount: newCount, at: index) { target in
while !target.isFull {
guard let item = it.next() else { preconditionFailure() }
target.append(item)
}
}
precondition(it.next() == nil, "Broken Collection")
}
#endif
@@ -504,46 +374,16 @@ extension RigidArray {
/// a valid index of the array.
///
/// - Complexity: O(`count` + `newElements.count`)
@inlinable
@inline(__always)
public mutating func insert(
copying newElements: some Collection<Element>, at index: Int
) {
_insertCollection(
at: index, copying: newElements, newCount: newElements.count)
}
#if compiler(>=6.4) && UnstableContainersPreview
/// Copies the elements of a container into this array at the specified
/// position.
///
/// The new elements are inserted before the element currently at the
/// specified index. If you pass the array's `endIndex` as the `index`
/// parameter, then the new elements are appended to the end of the array.
///
/// All existing elements at or following the specified position are moved to
/// make room for the new item.
///
/// If the capacity of the array isn't sufficient to accommodate the new
/// elements, then this method triggers a runtime error.
///
/// - Parameters:
/// - newElements: The new elements to insert into the array.
/// - index: The position at which to insert the new elements. It must be
/// a valid index of the array.
///
/// - Complexity: O(`self.count` + `newElements.count`)
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
C: Container<Element> & Collection<Element>
>(
copying newElements: borrowing C, at index: Int
public mutating func insert(
copying items: some Collection<Element>, at index: Int
) {
_insertContainer(
at: index, copying: newElements, newCount: newElements.count)
// FIXME: Remove this -- RangeReplaceContainer already has this algorithm.
// (Note that this would be source breaking while RRC lives in the separate
// ContainersPreview module.)
_insertCollection(addingCount: items.count, copying: items, at: index)
}
#endif
}
#endif
@@ -114,13 +114,14 @@ extension RigidArray where Element: ~Copyable {
/// - Complexity: O(`count`)
@_alwaysEmitIntoClient
public mutating func removeSubrange(_ bounds: some RangeExpression<Int>) {
// FIXME: Remove this in favor of a standard algorithm.
// FIXME: Remove this in favor of the RangeReplaceableContainer algorithm.
removeSubrange(bounds.relative(to: indices))
}
}
@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
#if !UnstableContainersPreview
/// Removes and returns the last element of the array, if there is one.
///
/// - Returns: The last element of the array if the array is not empty;
@@ -129,10 +130,11 @@ extension RigidArray where Element: ~Copyable {
/// - Complexity: O(1)
@_alwaysEmitIntoClient
public mutating func popLast() -> Element? {
// FIXME: Remove this in favor of a standard algorithm.
// FIXME: Remove this in favor of the RangeReplaceableContainer algorithm.
if isEmpty { return nil }
return removeLast()
}
#endif
}
#endif
@@ -132,6 +132,7 @@ extension UniqueArray where Element: ~Copyable {
_storage.append(moving: &items)
}
#if !UnstableContainersPreview
/// Appends the elements of a given array to the end of this array by moving
/// them between the containers. On return, the input array becomes empty, but
/// it is not destroyed, and it preserves its original storage capacity.
@@ -149,70 +150,19 @@ extension UniqueArray where Element: ~Copyable {
public mutating func append(
moving items: inout RigidArray<Element>
) {
// FIXME: Remove this in favor of a generic algorithm over range-replaceable containers
_ensureFreeCapacity(items.count)
_storage.append(moving: &items)
items.edit { source in
source.withUnsafeMutableBufferPointer { buffer, count in
_storage.append(moving: buffer._extracting(first: count))
count = 0
}
}
}
#endif
}
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
#if UnstableContainersPreview
/// Appends the elements of a given container to the end of this array by
/// consuming the source container.
///
/// If the target array does not have sufficient capacity to hold all items
/// in the source array, then this automatically grows the target array's
/// capacity, using a geometric growth rate.
///
/// - Parameters:
/// - items: An array whose items to move to the end of this array.
///
/// - Complexity: O(`items.count`)
@_alwaysEmitIntoClient
public mutating func append(
consuming items: consuming RigidArray<Element>
) {
// FIXME: Remove this in favor of a generic algorithm over consumable containers
var items = items
self.append(moving: &items)
}
#endif
#if compiler(>=6.4) && UnstableContainersPreview
/// Appends at most `newItemCount` items generated by a producer to the end of
/// this array.
///
/// If the array doesn't have sufficient capacity to accommodate the specified
/// number of new elements, then this method reallocates the array's storage
/// to grow it, using a geometric growth rate.
///
/// This operation appends as many items as the producer can generate before
/// either reaching its end (or throwing an error), or filling the specified
/// capacity. This operation only consumes the first `newItemCount` items in the
/// producer; if the producer has more, then they remain available after this
/// method returns.
///
/// - Parameters:
/// - newItemCount: The maximum number of items to append to the array.
/// - producer: A producer that generates the items to append.
///
/// - Complexity: O(*n*) where *n* is the number of new items, when
/// amortized over many similar invocations on the same array.
@_alwaysEmitIntoClient
public mutating func append<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
>(
addingCount newItemCount: Int,
from producer: inout P
) throws(E)
where P.Element: ~Copyable
{
_ensureFreeCapacity(newItemCount)
try _storage.append(addingCount: newItemCount, from: &producer)
}
#endif
#if compiler(>=6.4) && UnstableContainersPreview
/// Appends all the items generated by a producer to the end of this deque.
@@ -117,7 +117,7 @@ extension UniqueArray where Element: ~Copyable {
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
public typealias SubrangeConsumer = RigidArray<Element>.SubrangeConsumer
@@ -48,10 +48,10 @@ extension UniqueArray: RandomAccessContainer where Element: ~Copyable {}
extension UniqueArray: MutableContainer where Element: ~Copyable {}
#if compiler(>=6.4)
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension UniqueArray: RangeReplaceableContainer where Element: ~Copyable {}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension UniqueArray: DynamicContainer where Element: ~Copyable {}
#endif
#endif
@@ -144,6 +144,7 @@ extension UniqueArray where Element: ~Copyable {
moving items: inout InputSpan<Element>,
at index: Int
) {
// FIXME: Remove when InputSpan starts conforming to RangeReplaceableContainer
_ensureFreeCapacity(items.count)
_storage.insert(moving: &items, at: index)
}
@@ -171,10 +172,12 @@ extension UniqueArray where Element: ~Copyable {
moving items: inout OutputSpan<Element>,
at index: Int
) {
// FIXME: Remove when OutputSpan starts conforming to RangeReplaceableContainer
_ensureFreeCapacity(items.count)
_storage.insert(moving: &items, at: index)
}
#if !UnstableContainersPreview
/// Inserts the elements of a given array into the given position in this
/// array by moving them between the containers. On return, the input array
/// becomes empty, but it is not destroyed, and it preserves its original
@@ -186,6 +189,7 @@ extension UniqueArray where Element: ~Copyable {
///
/// - Parameters:
/// - items: An array whose contents to move into `self`.
/// - index: The position in `self` at which to insert the new items.
///
/// - Complexity: O(`self.count` + `items.count`)
@_alwaysEmitIntoClient
@@ -197,88 +201,9 @@ extension UniqueArray where Element: ~Copyable {
_ensureFreeCapacity(items.count)
_storage.insert(moving: &items, at: index)
}
}
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
#if UnstableContainersPreview
/// Inserts the elements of a given array into the given position in this
/// array by consuming the source container.
///
/// If the array does not have sufficient capacity to hold all elements,
/// then this reallocates storage to extend its capacity, using a geometric
/// growth rate.
///
/// - Parameters:
/// - items: A fully initialized buffer whose contents to move into
/// the array.
///
/// - Complexity: O(`self.count` + `items.count`)
@_alwaysEmitIntoClient
public mutating func insert(
consuming items: consuming RigidArray<Element>,
at index: Int
) {
// FIXME: Remove this in favor of a generic algorithm over consumable containers
// FIXME: Avoid moving the subsequent elements twice.
_ensureFreeCapacity(items.count)
_storage.insert(consuming: items, at: index)
}
#endif
}
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
#if compiler(>=6.4) && UnstableContainersPreview
/// Inserts at most `newItemCount` items generated by a producer into this
/// array, starting at the given index.
///
/// Existing elements in the array's storage are moved as needed to make room
/// for the new items.
///
/// If the array does not have sufficient capacity to hold enough items,
/// then this reallocates the array's storage to grow its capacity, using a
/// geometric growth rate.
///
/// This operation inserts as many items as the producer can generate before
/// either reaching `newItemCount`, or the producer hitting its end, or
/// throwing an error. If the producer has more than `newItemCount` items
/// left in its underlying sequence, then extra items remain available after
/// this method returns.
///
/// If the operation inserts fewer than `newItemCount` items, then it results
/// in a gap in array storage that needs to be closed by moving some
/// items to their correct positions given the adjusted count. This adds some
/// overhead compared to adding exactly as many items as promised.
///
/// - Parameters:
/// - newItemCount: The maximum number of items to insert into the array.
/// - index: The position at which to insert the new items.
/// `index` must be a valid index in the array.
/// - producer: A producer that generates the items to append.
///
/// - Complexity: O(`self.count` + `newItemCount`) when amortized over many
/// similar invocations on the same array.
@_alwaysEmitIntoClient
public mutating func insert<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
>(
addingCount newItemCount: Int,
from producer: inout P,
at index: Int
) throws(E)
where P.Element: ~Copyable
{
try insert(addingCount: newItemCount, at: index) { target throws(E) in
while !target.isFull, try producer.generate(into: &target) {
// Do nothing
}
}
}
#endif
}
@available(SwiftStdlib 5.0, *)
extension UniqueArray {
/// Copies the elements of a fully initialized buffer pointer into this
@@ -368,42 +293,6 @@ extension UniqueArray {
_storage.insert(copying: newElements, at: index)
}
#if compiler(>=6.4) && UnstableContainersPreview
/// Copies the elements of a container into this array at the specified
/// position.
///
/// The new elements are inserted before the element currently at the
/// specified index. If you pass the array's `endIndex` as the `index`
/// parameter, then the new elements are appended to the end of the array.
///
/// All existing elements at or following the specified position are moved to
/// make room for the new item.
///
/// If the array does not have sufficient capacity to hold enough elements,
/// then this reallocates the array's storage to extend its capacity, using a
/// geometric growth rate.
///
/// - Parameters:
/// - newElements: The new elements to insert into the array.
/// - index: The position at which to insert the new elements. It must be
/// a valid index of the array.
///
/// - Complexity: O(*n* + *m*), where *n* is count of this array and
/// *m* is the count of `newElements`.
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
C: Container<Element> & ~Copyable & ~Escapable
>(
copying newElements: borrowing C, at index: Int
) {
// FIXME: Avoid moving the subsequent elements twice.
let c = newElements.count
_ensureFreeCapacity(c)
_storage._insertContainer(at: index, copying: newElements, newCount: c)
}
#endif
/// Copies the elements of a collection into this array at the specified
/// position.
///
@@ -428,48 +317,15 @@ extension UniqueArray {
public mutating func insert(
copying newElements: some Collection<Element>, at index: Int
) {
// FIXME: Remove this -- RangeReplaceContainer already has this algorithm.
// (Note that this would be source breaking while RRC lives in the separate
// ContainersPreview module.)
// FIXME: Avoid moving the subsequent elements twice.
let newCount = newElements.count
_ensureFreeCapacity(newCount)
_storage._insertCollection(
at: index, copying: newElements, newCount: newCount)
addingCount: newCount, copying: newElements, at: index)
}
#if compiler(>=6.4) && UnstableContainersPreview
/// Copies the elements of a container into this array at the specified
/// position.
///
/// The new elements are inserted before the element currently at the
/// specified index. If you pass the array's `endIndex` as the `index`
/// parameter, then the new elements are appended to the end of the array.
///
/// All existing elements at or following the specified position are moved to
/// make room for the new item.
///
/// If the array does not have sufficient capacity to hold enough elements,
/// then this reallocates the array's storage to extend its capacity, using a
/// geometric growth rate.
///
/// - Parameters:
/// - newElements: The new elements to insert into the array.
/// - index: The position at which to insert the new elements. It must be
/// a valid index of the array.
///
/// - Complexity: O(*n* + *m*), where *n* is count of this array and
/// *m* is the count of `newElements`.
@_alwaysEmitIntoClient
@inline(__always)
public mutating func insert<
C: Container<Element> & Collection<Element>
>(
copying newElements: borrowing C, at index: Int
) {
// FIXME: Avoid moving the subsequent elements twice.
let c = newElements.count
_ensureFreeCapacity(c)
_storage._insertContainer(at: index, copying: newElements, newCount: c)
}
#endif
}
#endif
@@ -103,13 +103,14 @@ extension UniqueArray where Element: ~Copyable {
/// - Complexity: O(`self.count`)
@_alwaysEmitIntoClient
public mutating func removeSubrange(_ bounds: some RangeExpression<Int>) {
// FIXME: Remove this in favor of a standard algorithm.
// FIXME: Remove this in favor of the RangeReplaceableContainer algorithm.
removeSubrange(bounds.relative(to: indices))
}
}
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
#if !UnstableContainersPreview
/// Removes and returns the last element of the array, if there is one.
///
/// - Returns: The last element of the array if the array is not empty;
@@ -118,9 +119,11 @@ extension UniqueArray where Element: ~Copyable {
/// - Complexity: O(1)
@_alwaysEmitIntoClient
public mutating func popLast() -> Element? {
// FIXME: Remove this in favor of the RangeReplaceableContainer algorithm.
if isEmpty { return nil }
return removeLast()
}
#endif
}
#endif
+1
View File
@@ -64,6 +64,7 @@ target_sources(${module_name} PRIVATE
"Protocols/Producer+Reduce.swift"
"Types/InputSpan.swift"
"Types/MutableRef.swift"
"Types/OutputSpan+Extras.swift"
"Types/Shared.swift"
"Types/SpanIterator.swift"
"Types/UniqueBox.swift"
@@ -19,6 +19,7 @@ import InternalCollectionsUtilities
@available(SwiftStdlib 6.4, *)
extension Container where Self: ~Copyable /*& ~Escapable*/, Element: ~Copyable {
@_alwaysEmitIntoClient
@_lifetime(borrow self)
public func _filter(
_ isIncluded: @escaping (borrowing Element) -> Bool
@@ -29,6 +30,7 @@ extension Container where Self: ~Copyable /*& ~Escapable*/, Element: ~Copyable {
@available(SwiftStdlib 6.4, *)
extension ContainerIterator where Base.Element: ~Copyable {
@_alwaysEmitIntoClient
@_lifetime(copy self)
public func filter(
_ isIncluded: @escaping (borrowing Element) -> Bool
@@ -57,7 +59,7 @@ where Base.Element: ~Copyable
@_alwaysEmitIntoClient
public var _remainder: Span<Element>
@inlinable
@_alwaysEmitIntoClient
@_lifetime(copy _base)
internal init(
_base: Ref<Base>,
@@ -70,7 +72,7 @@ where Base.Element: ~Copyable
self._remainder = .init()
}
@inlinable
@_alwaysEmitIntoClient
@_lifetime(borrow _base)
internal init(
_base: borrowing Base,
@@ -249,44 +249,31 @@ extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
/// If the input index is the end index, then this returns an empty span.
/// Otherwise the result is non-empty, with its first element matching the
/// element at the input index.
@inlinable
@_alwaysEmitIntoClient
@_lifetime(borrow self)
public func nextSpan(after index: inout Index) -> Span<Element> {
nextSpan(after: &index, maximumCount: Int.max)
}
// @inlinable
// @_lifetime(borrow self)
// public func nextSpan(after index: inout Index, maximumCount: Int) -> Span<Element> {
// let original = index
// var span = nextSpan(after: &index)
// if span.count > maximumCount {
// span = span.extracting(first: maximumCount)
// // Index remains within the same span, so offseting it is expected to be quick
// index = self.index(original, offsetBy: maximumCount)
// }
// return span
// }
}
@available(SwiftStdlib 5.0, *)
extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
@_alwaysEmitIntoClient
public var isEmpty: Bool {
startIndex == endIndex
}
@inlinable
@_alwaysEmitIntoClient
public var count: Int {
distance(from: startIndex, to: endIndex)
}
@inlinable
@_alwaysEmitIntoClient
public func formIndex(after index: inout Index) {
index = self.index(after: index)
}
@inlinable
@_alwaysEmitIntoClient
public func index(_ index: Index, offsetBy n: Int) -> Index {
precondition(
n >= 0,
@@ -328,7 +315,7 @@ extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
#endif
}
@inlinable
@_alwaysEmitIntoClient
public func formIndex(
_ index: inout Index, offsetBy n: inout Int, limitedBy limit: Index
) {
@@ -347,7 +334,18 @@ extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
}
}
@inlinable
@_alwaysEmitIntoClient
public func index(
_ index: Index, offsetBy n: Int, limitedBy limit: Index
) -> Index? {
var index = index
var n = n
self.formIndex(&index, offsetBy: &n, limitedBy: limit)
if n != 0 { return nil }
return index
}
@_alwaysEmitIntoClient
public func distance(from start: Index, to end: Index) -> Int {
#if true
// This variant does not require that `start` precede `end`, but it's
@@ -400,18 +398,18 @@ extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
#endif
}
@inlinable
@_alwaysEmitIntoClient
public func index(alignedDown index: Index) -> Index { index }
@inlinable
@_alwaysEmitIntoClient
public func index(alignedUp index: Index) -> Index { index }
@inlinable
@_alwaysEmitIntoClient
public func _customIndexOfEquatableElement(_: borrowing Element) -> Index?? {
nil
}
@inlinable
@_alwaysEmitIntoClient
public func _customLastIndexOfEquatableElement(
_ element: borrowing Element
) -> Index?? {
@@ -422,6 +420,7 @@ extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension Container where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@_alwaysEmitIntoClient
@_transparent
public var underestimatedCount_: Int { count }
}
@@ -20,6 +20,7 @@ where
Element: ~Copyable,
IterableIterator_ == ContainerIterator<Self>
{
@_alwaysEmitIntoClient
@_lifetime(borrow self)
public func makeIterableIterator_() -> IterableIterator_ {
ContainerIterator(_borrowing: self, from: self.startIndex)
@@ -33,12 +34,16 @@ public struct ContainerIterator<
where Base.Element: ~Copyable
{
public typealias Element = Base.Element
let _base: Ref<Base> // FIXME: This doesn't support nonescapable Bases
var _position: Base.Index
@_alwaysEmitIntoClient
package let _base: Ref<Base> // FIXME: This doesn't support nonescapable Bases
@_alwaysEmitIntoClient
package var _position: Base.Index
@_alwaysEmitIntoClient
@_lifetime(borrow base)
init(_borrowing base: borrowing @_addressable Base, from position: Base.Index) {
package init(_borrowing base: borrowing @_addressable Base, from position: Base.Index) {
self._base = Ref(base)
self._position = position
}
@@ -52,12 +57,14 @@ where
{
public typealias Element_ = Base.Element
@_alwaysEmitIntoClient
@_unsafeNonescapableResult // FIXME: we cannot convert from a borrow to an inout dependence?!
@_lifetime(&self)
public mutating func nextSpan_(maximumCount: Int) -> Span<Base.Element> {
_base.value.nextSpan(after: &self._position, maximumCount: maximumCount)
}
@_alwaysEmitIntoClient
@_lifetime(self: copy self)
public mutating func skip_(by maximumOffset: Int) -> Int {
// FIXME: If we aren't modeling bidirectional iterators, then this should
@@ -22,17 +22,33 @@ where Element: ~Copyable
mutating func reserveCapacity(_ minimumCapacity: Int)
/// The number of items that can be added to the container without forcing
/// it to allocate extra storage. This is primarily intended to serve as a
/// hint for the batch size of appends, to allow bulk operation even if
/// the number of items to be appended is not known in advance.
///
/// If the container does not have simple, predictable allocation behavior,
/// then this should return the size of the container's primitive allocation
/// unit. For example, in a balanced rope that organizes its contents into a
/// tree of fixed-capacity nodes, it may be a good choice to use the maximum
/// node size as the (constant) free capacity, even though it may not
/// correlate exactly with actual allocation behavior.
///
/// If a container always reports a free capacity of 0, then appending a
/// sequence of items of an unknown size may run slower than expected.
///
/// - Complexity: O(1)
var freeCapacity: Int { get }
}
@available(SwiftStdlib 5.0, *)
extension DynamicContainer where Self: ~Copyable, Element: ~Copyable {
@inlinable
@_alwaysEmitIntoClient
public init() {
self.init(minimumCapacity: 0)
}
@inlinable
@_alwaysEmitIntoClient
public init<E: Error>(
minimumCapacity: Int,
initializingWith initializer: (inout OutputSpan<Element>) throws(E) -> Void
@@ -41,7 +57,7 @@ extension DynamicContainer where Self: ~Copyable, Element: ~Copyable {
try self.append(addingCount: minimumCapacity, initializingWith: initializer)
}
@inlinable
@_alwaysEmitIntoClient
public init<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
@@ -55,7 +71,7 @@ extension DynamicContainer where Self: ~Copyable, Element: ~Copyable {
try self.append(from: producer)
}
@inlinable
@_alwaysEmitIntoClient
public mutating func append<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
@@ -66,15 +82,22 @@ extension DynamicContainer where Self: ~Copyable, Element: ~Copyable {
{
while true {
let c = Swift.max(producer.underestimatedCount, self.freeCapacity)
try self.append(addingCount: c) { target throws(E) in
while !target.isFull {
guard try producer.generate(into: &target) else { return }
if c > 0 {
try self.append(addingCount: c) { target throws(E) in
while !target.isFull {
guard try producer.generate(into: &target) else { return }
}
}
}
// Nudge the container to resize itself, providing more `freeCapacity` in
// the next iteration. Doing this separately avoids forcing the container
// to unnecessarily reallocate itself when the producer is already
// complete. (In exchange, we have to move a handful of items twice.)
// Nudge the container to resize itself, hopefully providing more
// `freeCapacity` in the next iteration. Doing this separately avoids
// forcing the container to unnecessarily reallocate itself when the
// producer is already complete.
//
// In exchange, when neither the producer nor the container provides
// a nonzero count/capacity, then every single item will be added
// individually, resulting in appending all items one by one, but with
// additional overhead spent on the repeared property invocations.
guard let next = try producer.next() else { return }
self.append(next)
}
@@ -83,7 +106,7 @@ extension DynamicContainer where Self: ~Copyable, Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension DynamicContainer where Self: ~Copyable, Element: Copyable {
@inlinable
@_alwaysEmitIntoClient
public init(repeating repeatedValue: Element, count: Int) {
var c = count
self.init(minimumCapacity: count) { target in
@@ -95,15 +95,13 @@ where
after index: inout Index,
maximumCount: Int
) -> MutableSpan<Element>
// FIXME: What about previousMutableSpan?
}
@available(SwiftStdlib 5.0, *)
extension MutableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
@_alwaysEmitIntoClient
@_lifetime(&self)
mutating func nextMutableSpan(
after index: inout Index,
@@ -47,6 +47,10 @@ where
mutating func remove(at index: Index) -> Element
mutating func removeSubrange(_ bounds: Range<Index>)
mutating func removeAll()
mutating func removeFirst() -> Element
mutating func removeFirst(_ n: Int)
mutating func _customRemoveLast() -> Element?
mutating func _customRemoveLast(_ n: Int) -> Bool
mutating func insert<E: Error>(
addingCount newItemCount: Int,
@@ -70,7 +74,7 @@ where
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
@_alwaysEmitIntoClient
public mutating func remove(at index: Index) -> Element {
let range = Range(uncheckedBounds: (index, self.index(after: index)))
var result: Element?
@@ -83,7 +87,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
return result
}
@inlinable
@_alwaysEmitIntoClient
public mutating func removeSubrange(_ bounds: Range<Index>) {
replace(
removing: bounds,
@@ -92,12 +96,39 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
initializingWith: { _ in })
}
@inlinable
public mutating func removeAll() {
removeSubrange(startIndex ..< endIndex)
@_alwaysEmitIntoClient
public mutating func removeFirst() -> Element {
precondition(
!isEmpty,
"Can't remove first element from an empty container")
return self.remove(at: self.startIndex)
}
@inlinable
@_alwaysEmitIntoClient
public mutating func removeFirst(_ n: Int) {
if n == 0 { return }
precondition(n >= 0, "Number of elements to remove should be non-negative")
let start = self.startIndex
guard
let end = self.index(start, offsetBy: n, limitedBy: endIndex)
else {
preconditionFailure(
"Can't remove more items from a container than it has")
}
removeSubrange(start ..< end)
}
@_alwaysEmitIntoClient
public mutating func _customRemoveLast() -> Element? {
nil
}
@_alwaysEmitIntoClient
public mutating func _customRemoveLast(_ n: Int) -> Bool {
false
}
@_alwaysEmitIntoClient
public mutating func insert<E: Error>(
addingCount newItemCount: Int,
at index: Index,
@@ -110,7 +141,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
initializingWith: initializer)
}
@inlinable
@_alwaysEmitIntoClient
public mutating func insert(
_ item: consuming Element, at index: Index
) {
@@ -120,7 +151,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
}
}
@inlinable
@_alwaysEmitIntoClient
public mutating func append<E: Error>(
addingCount newItemCount: Int,
initializingWith initializer: (inout OutputSpan<Element>) throws(E) -> Void
@@ -131,7 +162,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
initializingWith: initializer)
}
@inlinable
@_alwaysEmitIntoClient
public mutating func append(_ item: consuming Element) {
insert(item, at: endIndex)
}
@@ -143,7 +174,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
@_alwaysEmitIntoClient
public mutating func replace<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
@@ -164,7 +195,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
})
}
@inlinable
@_alwaysEmitIntoClient
public mutating func replace<
E: Error,
P: CountedProducer<Element, E> & ~Copyable & ~Escapable
@@ -183,7 +214,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
}
}
@inlinable
@_alwaysEmitIntoClient
public mutating func replace<E: Error>(
removing subrange: some RangeExpression2<Index>,
consumingWith consumer: (inout InputSpan<Element>) -> Void,
@@ -211,7 +242,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
fatalError()
}
@inlinable
@_alwaysEmitIntoClient
public mutating func replace<E: Error>(
removing subrange: some RangeExpression2<Index>,
addingCount newItemCount: Int,
@@ -224,7 +255,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
initializingWith: initializer)
}
@inlinable
@_alwaysEmitIntoClient
public mutating func replace<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -234,7 +265,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
replace(removing: targetSubrange, addingFrom: source.consumeAll())
}
@inlinable
@_alwaysEmitIntoClient
public mutating func replace<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -252,7 +283,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
}
}
@inlinable
@_alwaysEmitIntoClient
public mutating func replace<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -267,7 +298,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable {
@inlinable
@_alwaysEmitIntoClient
public mutating func consume(
_ subrange: Range<Index>,
consumingWith consumer: (inout InputSpan<Element>) -> Void
@@ -281,13 +312,13 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
})
}
@inlinable
@_alwaysEmitIntoClient
@_lifetime(&self)
public mutating func consumeAll() -> SubrangeConsumer {
consume(startIndex ..< endIndex)
}
@inlinable
@_alwaysEmitIntoClient
@_lifetime(&self)
public mutating func consume(
_ subrange: some RangeExpression2<Index>
@@ -305,7 +336,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
fatalError()
}
@inlinable
@_alwaysEmitIntoClient
@_lifetime(&self)
public mutating func consume(
_ subrange: UnboundedRange
@@ -313,7 +344,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
consume(startIndex ..< endIndex)
}
@inlinable
@_alwaysEmitIntoClient
@_lifetime(&self)
public mutating func consumeFirst(_ n: Int) -> SubrangeConsumer {
precondition(n >= 0, "Count of elements to consume is out of bounds")
@@ -333,7 +364,7 @@ where
Self: ~Copyable & ~Escapable,
Element: ~Copyable
{
@inlinable
@_alwaysEmitIntoClient
@_lifetime(&self)
public mutating func consumeLast(_ n: Int) -> SubrangeConsumer {
precondition(n >= 0, "Count of elements to consume is out of bounds")
@@ -350,14 +381,19 @@ where
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
{
@inlinable
@_alwaysEmitIntoClient
public mutating func removeAll() {
removeSubrange(startIndex ..< endIndex)
}
@_alwaysEmitIntoClient
public mutating func removeSubrange(
_ bounds: some RangeExpression2<Index>
) {
removeSubrange(bounds.relative(to: self))
}
@inlinable
@_alwaysEmitIntoClient
public mutating func removeSubrange(
_ bounds: UnboundedRange
) {
@@ -365,6 +401,48 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
}
}
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer
where Self: BidirectionalContainer & ~Copyable & ~Escapable, Element: ~Copyable
{
@_alwaysEmitIntoClient
public mutating func removeLast() -> Element {
precondition(
!self.isEmpty,
"Can't remove last element from an empty container")
if let result = self._customRemoveLast() { return result }
return self.remove(at: self.index(before: self.endIndex))
}
@_alwaysEmitIntoClient
public mutating func removeLast(_ n: Int) {
if n == 0 { return }
precondition(n >= 0, "Number of elements to remove should be non-negative")
if self._customRemoveLast(n) {
return
}
let end = self.endIndex
guard let start = self.index(end, offsetBy: -n, limitedBy: self.startIndex)
else {
preconditionFailure(
"Can't remove more items from a collection than it contains")
}
self.removeSubrange(start ..< end)
}
}
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer
where Self: BidirectionalContainer & ~Copyable & ~Escapable, Element: ~Copyable
{
@_alwaysEmitIntoClient
public mutating func popLast() -> Element? {
if self.isEmpty { return nil }
if let result = self._customRemoveLast() { return result }
return self.remove(at: self.index(before: self.endIndex))
}
}
@available(SwiftStdlib 5.0, *)
extension RangeReplaceableContainer
where Self: ~Copyable & ~Escapable, Element: ~Copyable
@@ -390,7 +468,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
/// - index: The position at which to insert the new items.
/// `index` must be a valid index in the container.
/// - producer: A producer that generates the items to append.
@inlinable
@_alwaysEmitIntoClient
public mutating func insert<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
@@ -428,7 +506,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
/// - index: The position at which to insert the new items.
/// `index` must be a valid index in the container.
/// - producer: A producer that generates the items to append.
@inlinable
@_alwaysEmitIntoClient
public mutating func insert<
E: Error,
P: CountedProducer<Element, E> & ~Copyable & ~Escapable
@@ -448,7 +526,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
}
}
@inlinable
@_alwaysEmitIntoClient
public mutating func insert<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -458,7 +536,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
self.insert(from: source.consumeAll(), at: index)
}
@inlinable
@_alwaysEmitIntoClient
public mutating func insert<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -475,7 +553,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable
}
}
@inlinable
@_alwaysEmitIntoClient
public mutating func insert<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -504,7 +582,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
/// - Parameters:
/// - newItemCount: The number of items to append to the container.
/// - producer: A producer that generates the items to append.
@inlinable
@_alwaysEmitIntoClient
public mutating func append<
E: Error,
P: Producer<Element, E> & ~Copyable & ~Escapable
@@ -529,7 +607,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
///
/// - Parameters:
/// - producer: A producer that generates the items to append.
@inlinable
@_alwaysEmitIntoClient
public mutating func append<
E: Error,
P: CountedProducer<Element, E> & ~Copyable & ~Escapable
@@ -552,7 +630,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
///
/// - Parameters:
/// - items: A container whose contents to move into this container.
@inlinable
@_alwaysEmitIntoClient
public mutating func append<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -561,7 +639,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
self.append(from: items.consumeAll())
}
@inlinable
@_alwaysEmitIntoClient
public mutating func append<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -585,7 +663,7 @@ where Self: ~Copyable & ~Escapable, Element: ~Copyable {
///
/// - Parameters:
/// - items: A container whose contents to move into this container.
@inlinable
@_alwaysEmitIntoClient
public mutating func append<
C: RangeReplaceableContainer<Element> & ~Copyable & ~Escapable
>(
@@ -603,7 +681,7 @@ where
Self: ~Copyable & ~Escapable,
Element: Copyable
{
@inlinable
@_alwaysEmitIntoClient
public mutating func replace<C: Container<Element> & ~Copyable & ~Escapable>(
removing subrange: Range<Index>,
copying items: borrowing C
@@ -760,7 +838,7 @@ where
}
}
@inlinable
@_alwaysEmitIntoClient
public mutating func append<
S: Iterable_ & ~Copyable & ~Escapable
>(
@@ -11,6 +11,10 @@
//
//===----------------------------------------------------------------------===//
#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
@@ -11,6 +11,10 @@
//
//===----------------------------------------------------------------------===//
#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
@@ -11,6 +11,10 @@
//
//===----------------------------------------------------------------------===//
#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
@@ -11,6 +11,10 @@
//
//===----------------------------------------------------------------------===//
#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@_alwaysEmitIntoClient
@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2024 - 2026 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
//
// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception
//
//===----------------------------------------------------------------------===//
#if !COLLECTIONS_SINGLE_MODULE
import InternalCollectionsUtilities
#endif
#if compiler(>=6.2) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
extension OutputSpan where Element: ~Copyable {
@_lifetime(source: copy source)
@inlinable
@inline(__always)
@_lifetime(self: copy self)
package mutating func _append(moving source: inout InputSpan<Element>) {
// FIXME: This needs to be in the stdlib.
source.withUnsafeMutableBufferPointer { src, srcCount in
let srcItems = src._extracting(
uncheckedFrom: src.count &- srcCount,
to: src.count)
self._append(moving: srcItems)
srcCount = 0
}
}
@_alwaysEmitIntoClient
@_lifetime(self: copy self)
package mutating func _consumeAll(
consumingWith consumer: (inout InputSpan<Element>) -> Void
) {
self.withUnsafeMutableBufferPointer { buffer, count in
var span = InputSpan(
buffer: buffer._extracting(first: count),
initializedCount: count)
consumer(&span)
_ = consume span
count = 0
}
}
}
#endif
@@ -167,7 +167,7 @@ extension RigidDeque where Element: ~Copyable {
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
@_alwaysEmitIntoClient
@inline(__always)
@_lifetime(&self)
@@ -178,7 +178,7 @@ extension RigidDeque where Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: ~Copyable {
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
@frozen
public struct SubrangeConsumer: ~Copyable, ~Escapable {
// FIXME: We have to use our own MutableRef because the standard one
@@ -221,11 +221,11 @@ extension RigidDeque where Element: ~Copyable {
}
}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidDeque.SubrangeConsumer: Drain where Element: ~Copyable {
}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidDeque.SubrangeConsumer where Element: ~Copyable {
@inlinable
public var count: Int {
@@ -77,10 +77,10 @@ extension RigidDeque: BidirectionalContainer where Element: ~Copyable {}
extension RigidDeque: RandomAccessContainer where Element: ~Copyable {}
#if compiler(>=6.4)
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidDeque: MutableContainer where Element: ~Copyable {}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension RigidDeque: RangeReplaceableContainer where Element: ~Copyable {}
#endif
#endif
@@ -17,6 +17,7 @@
import InternalCollectionsUtilities
#endif
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
extension RigidDeque: Hashable where Element: Hashable & ~Copyable {
}
@@ -33,5 +34,19 @@ extension RigidDeque where Element: Hashable & ~Copyable {
}
}
}
#else
@available(SwiftStdlib 5.0, *)
extension RigidDeque where Element: Hashable {
@inlinable
public func hash(into hasher: inout Hasher) {
hasher.combine(self.count)
let segments = self._handle.segments()
segments.first.span._hashContents(into: &hasher)
if let second = segments.second {
second.span._hashContents(into: &hasher)
}
}
}
#endif
#endif
@@ -59,7 +59,13 @@ extension RigidDeque where Element: ~Copyable {
precondition(!isEmpty, "Cannot remove first element of an empty RigidDeque")
return _handle.uncheckedRemoveFirst()
}
@_alwaysEmitIntoClient
public mutating func _customRemoveLast() -> Element? {
precondition(!isEmpty, "Cannot remove last element of an empty RigidDeque")
return _handle.uncheckedRemoveLast()
}
/// Removes and returns the last element of the deque.
///
/// The deque must not be empty.
@@ -91,7 +97,15 @@ extension RigidDeque where Element: ~Copyable {
precondition(k <= count, "Cannot remove more elements than there are in the container")
_handle.uncheckedRemoveFirst(k)
}
@_alwaysEmitIntoClient
public mutating func _customRemoveLast(_ n: Int) -> Bool {
precondition(n >= 0, "Cannot remove a negative number of elements")
precondition(n <= count, "Cannot remove more elements than there are in the container")
_handle.uncheckedRemoveLast(n)
return true
}
/// Removes and discards the specified number of elements from the end of the
/// deque.
///
@@ -139,6 +153,7 @@ 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;
@@ -150,6 +165,7 @@ extension RigidDeque where Element: ~Copyable {
guard !isEmpty else { return nil }
return _handle.uncheckedRemoveLast()
}
#endif
}
#endif
@@ -148,7 +148,7 @@ extension UniqueDeque where Element: ~Copyable {
}
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: ~Copyable {
public typealias SubrangeConsumer = RigidDeque<Element>.SubrangeConsumer
@@ -46,10 +46,10 @@ extension UniqueDeque: RandomAccessContainer where Element: ~Copyable {}
extension UniqueDeque: MutableContainer where Element: ~Copyable {}
#if compiler(>=6.4)
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque: RangeReplaceableContainer where Element: ~Copyable {}
@available(SwiftStdlib 6.4, *)
@available(SwiftStdlib 5.0, *)
extension UniqueDeque: DynamicContainer where Element: ~Copyable {}
#endif
#endif
@@ -13,6 +13,7 @@
#if compiler(>=6.2)
#if compiler(>=6.4) && UnstableContainersPreview
@available(SwiftStdlib 6.4, *)
extension UniqueDeque: Hashable where Element: Hashable & ~Copyable {
}
@@ -24,5 +25,14 @@ extension UniqueDeque where Element: Hashable & ~Copyable {
self._storage.hash(into: &hasher)
}
}
#else
@available(SwiftStdlib 5.0, *)
extension UniqueDeque where Element: Hashable {
@inlinable
public func hash(into hasher: inout Hasher) {
self._storage.hash(into: &hasher)
}
}
#endif
#endif
@@ -136,6 +136,7 @@ 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;
@@ -147,6 +148,7 @@ extension UniqueDeque where Element: ~Copyable {
public mutating func popLast() -> Element? {
_storage.popLast()
}
#endif
}
#endif
@@ -67,23 +67,6 @@ extension OutputSpan where Element: ~Copyable {
}
}
#if UnstableContainersPreview
@_lifetime(source: copy source)
@inlinable
@inline(__always)
@_lifetime(self: copy self)
package mutating func _append(moving source: inout InputSpan<Element>) {
// FIXME: This needs to be in the stdlib.
source.withUnsafeMutableBufferPointer { src, srcCount in
let srcItems = src._extracting(
uncheckedFrom: src.count &- srcCount,
to: src.count)
self._append(moving: srcItems)
srcCount = 0
}
}
#endif
@_lifetime(source: copy source)
@inlinable
@inline(__always)
@@ -154,26 +137,5 @@ extension OutputSpan where Element: ~Copyable {
}
}
#if UnstableContainersPreview
@available(SwiftStdlib 5.0, *)
extension OutputSpan where Element: ~Copyable {
@_alwaysEmitIntoClient
@_lifetime(self: copy self)
package mutating func _consumeAll(
consumingWith consumer: (inout InputSpan<Element>) -> Void
) {
self.withUnsafeMutableBufferPointer { buffer, count in
var span = InputSpan(
buffer: buffer._extracting(first: count),
initializedCount: count)
consumer(&span)
_ = consume span
count = 0
}
}
}
#endif
#endif
@@ -38,7 +38,7 @@ extension Span where Element: ~Copyable {
}
}
#if compiler(>=6.4) && UnstableContainersPreview
#if compiler(>=6.4)
@available(SwiftStdlib 5.0, *)
extension Span where Element: Equatable & ~Copyable {
@_alwaysEmitIntoClient
@@ -78,7 +78,7 @@ extension Span where Element: Equatable /* & ~Copyable */ {
}
#endif
#if compiler(>=6.4) && UnstableContainersPreview
#if compiler(>=6.4)
@available(SwiftStdlib 5.0, *)
extension Span where Element: Hashable & ~Copyable {
@_alwaysEmitIntoClient
+40 -4
View File
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
7D12E33D2FF5CC2A003050AB /* OutputSpan+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D12E33C2FF5CC2A003050AB /* OutputSpan+Extras.swift */; };
7D24E3ED2FAD4C37005A55EB /* RigidArray+Formatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D24E3EC2FAD4C37005A55EB /* RigidArray+Formatter.swift */; };
7D2A77262F27F1D1005780C7 /* Span+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2A77252F27F1D1005780C7 /* Span+Extras.swift */; };
7D2A77392F27F1E4005780C7 /* UniqueBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2A77332F27F1E4005780C7 /* UniqueBox.swift */; };
@@ -133,6 +134,10 @@
7D59D05C2FE48B89005B5097 /* Optional+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D59D0592FE48B89005B5097 /* Optional+Extras.swift */; };
7D59D05D2FE48B89005B5097 /* OutputSpan+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D59D05A2FE48B89005B5097 /* OutputSpan+Extras.swift */; };
7D59D05E2FE48B89005B5097 /* TemporaryAllocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D59D05B2FE48B89005B5097 /* TemporaryAllocation.swift */; };
7D59D0662FE49C87005B5097 /* Span+Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D59D0642FE49C87005B5097 /* Span+Container.swift */; };
7D59D0672FE49C87005B5097 /* InputSpan+Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D59D0612FE49C87005B5097 /* InputSpan+Container.swift */; };
7D59D0682FE49C87005B5097 /* MutableSpan+Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D59D0622FE49C87005B5097 /* MutableSpan+Container.swift */; };
7D59D0692FE49C87005B5097 /* OutputSpan+Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D59D0632FE49C87005B5097 /* OutputSpan+Container.swift */; };
7D7246872F3D9DDB00112FD0 /* _HTable+Iteration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7246802F3D9DDB00112FD0 /* _HTable+Iteration.swift */; };
7D7246882F3D9DDB00112FD0 /* RigidDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7246832F3D9DDB00112FD0 /* RigidDictionary.swift */; };
7D7246892F3D9DDB00112FD0 /* _HTable+Find.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D72467E2F3D9DDB00112FD0 /* _HTable+Find.swift */; };
@@ -147,6 +152,8 @@
7D7646062FAAA2B9008639E5 /* UniqueBoxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7646052FAAA2B9008639E5 /* UniqueBoxTests.swift */; };
7D7646082FAAABE3008639E5 /* UniqueDeque+Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7646072FAAABDF008639E5 /* UniqueDeque+Deprecated.swift */; };
7D77E6122FCF810E003FA63B /* CountedProducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D77E6112FCF810E003FA63B /* CountedProducer.swift */; };
7D77E6252FD0F880003FA63B /* UnsafePointer+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D77E6242FD0F87B003FA63B /* UnsafePointer+Extras.swift */; };
7D77E6272FD0F94B003FA63B /* UnsafeMutablePointer+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D77E6262FD0F940003FA63B /* UnsafeMutablePointer+Extras.swift */; };
7D9748D42E9748930098631A /* BigString+Chunk+UTF16.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D9748D32E9748930098631A /* BigString+Chunk+UTF16.swift */; };
7D9748D52E9748930098631A /* BigString+Chunk+UnicodeScalar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D9748D12E9748930098631A /* BigString+Chunk+UnicodeScalar.swift */; };
7D9748D62E9748930098631A /* BigString+Chunk+Character.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D9748CF2E9748930098631A /* BigString+Chunk+Character.swift */; };
@@ -609,6 +616,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
7D12E33C2FF5CC2A003050AB /* OutputSpan+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OutputSpan+Extras.swift"; sourceTree = "<group>"; };
7D24E3EC2FAD4C37005A55EB /* RigidArray+Formatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RigidArray+Formatter.swift"; sourceTree = "<group>"; };
7D24E9862FAD53E1005A55EB /* RigidArray_Fixture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RigidArray_Fixture.swift; sourceTree = "<group>"; };
7D24E9882FAD53E1005A55EB /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
@@ -703,7 +711,6 @@
7D479CFA2F4D080500A8CB59 /* UniqueDictionary+Keys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UniqueDictionary+Keys.swift"; sourceTree = "<group>"; };
7D479CFB2F4D080500A8CB59 /* UniqueDictionary+Removals.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UniqueDictionary+Removals.swift"; sourceTree = "<group>"; };
7D479CFE2F4E487700A8CB59 /* RigidSet+Equatable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RigidSet+Equatable.swift"; sourceTree = "<group>"; };
7D48BCC92E51524200D7F6F7 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
7D48BCDB2E51554900D7F6F7 /* ClassBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClassBox.swift; sourceTree = "<group>"; };
7D48BCDD2E51558700D7F6F7 /* TestPrintable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestPrintable.swift; sourceTree = "<group>"; };
7D48BCDE2E51558700D7F6F7 /* LifetimeTrackedStruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LifetimeTrackedStruct.swift; sourceTree = "<group>"; };
@@ -744,6 +751,11 @@
7D59D0592FE48B89005B5097 /* Optional+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Extras.swift"; sourceTree = "<group>"; };
7D59D05A2FE48B89005B5097 /* OutputSpan+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OutputSpan+Extras.swift"; sourceTree = "<group>"; };
7D59D05B2FE48B89005B5097 /* TemporaryAllocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemporaryAllocation.swift; sourceTree = "<group>"; };
7D59D0602FE49BDA005B5097 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
7D59D0612FE49C87005B5097 /* InputSpan+Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InputSpan+Container.swift"; sourceTree = "<group>"; };
7D59D0622FE49C87005B5097 /* MutableSpan+Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MutableSpan+Container.swift"; sourceTree = "<group>"; };
7D59D0632FE49C87005B5097 /* OutputSpan+Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OutputSpan+Container.swift"; sourceTree = "<group>"; };
7D59D0642FE49C87005B5097 /* Span+Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Span+Container.swift"; sourceTree = "<group>"; };
7D5A64D229CCE8CC00CB2595 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
7D5A64D329CCEE9A00CB2595 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
7D5A64D829CCF0FE00CB2595 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
@@ -763,6 +775,8 @@
7D7646052FAAA2B9008639E5 /* UniqueBoxTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniqueBoxTests.swift; sourceTree = "<group>"; };
7D7646072FAAABDF008639E5 /* UniqueDeque+Deprecated.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UniqueDeque+Deprecated.swift"; sourceTree = "<group>"; };
7D77E6112FCF810E003FA63B /* CountedProducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountedProducer.swift; sourceTree = "<group>"; };
7D77E6242FD0F87B003FA63B /* UnsafePointer+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UnsafePointer+Extras.swift"; sourceTree = "<group>"; };
7D77E6262FD0F940003FA63B /* UnsafeMutablePointer+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UnsafeMutablePointer+Extras.swift"; sourceTree = "<group>"; };
7D9748CF2E9748930098631A /* BigString+Chunk+Character.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BigString+Chunk+Character.swift"; sourceTree = "<group>"; };
7D9748D02E9748930098631A /* BigString+Chunk+Index.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BigString+Chunk+Index.swift"; sourceTree = "<group>"; };
7D9748D12E9748930098631A /* BigString+Chunk+UnicodeScalar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BigString+Chunk+UnicodeScalar.swift"; sourceTree = "<group>"; };
@@ -978,7 +992,6 @@
7DE91F1F29CA70F3004483EB /* _CharacterRecognizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _CharacterRecognizer.swift; sourceTree = "<group>"; };
7DE91F2029CA70F3004483EB /* String.Index+ABI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String.Index+ABI.swift"; sourceTree = "<group>"; };
7DE91F2129CA70F3004483EB /* Optional Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Optional Utilities.swift"; sourceTree = "<group>"; };
7DE91F2E29CA70F3004483EB /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
7DE91F3029CA70F3004483EB /* _SortedCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _SortedCollection.swift; sourceTree = "<group>"; };
7DE91F3829CA70F3004483EB /* _UniqueCollection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _UniqueCollection.swift; sourceTree = "<group>"; };
7DE91F3B29CA70F3004483EB /* BitSet+SetAlgebra symmetricDifference.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "BitSet+SetAlgebra symmetricDifference.swift"; sourceTree = "<group>"; };
@@ -1238,6 +1251,7 @@
7DFA40832FD3A98D00CD20C1 /* OrderedSet+Move.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderedSet+Move.swift"; sourceTree = "<group>"; };
7DFA40852FD3A99D00CD20C1 /* OrderedDictionary+Move.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OrderedDictionary+Move.swift"; sourceTree = "<group>"; };
7DFA40892FD3ACE700CD20C1 /* UnsafeBufferTrimTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsafeBufferTrimTests.swift; sourceTree = "<group>"; };
7DFC9DF62FEB5D7D00BE8808 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
A93AC20F2E7C841700A824DF /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
A93AC21A2E7C845300A824DF /* ArrayLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrayLayout.swift; sourceTree = "<group>"; };
A93AC21B2E7C845300A824DF /* RigidArrayTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RigidArrayTests.swift; sourceTree = "<group>"; };
@@ -1340,6 +1354,7 @@
children = (
7D2A77332F27F1E4005780C7 /* UniqueBox.swift */,
7DC037C82FE3792300CF0CB8 /* MutableRef.swift */,
7D12E33C2FF5CC2A003050AB /* OutputSpan+Extras.swift */,
7D2A77352F27F1E4005780C7 /* InputSpan.swift */,
7D2A77362F27F1E4005780C7 /* Shared.swift */,
7DACFA112F75FBF100291F2E /* SpanIterator.swift */,
@@ -1452,9 +1467,10 @@
7D48BCCE2E51524200D7F6F7 /* ContainersPreview */ = {
isa = PBXGroup;
children = (
7D59D0602FE49BDA005B5097 /* CMakeLists.txt */,
7D59D0652FE49C87005B5097 /* Conformances */,
7D2A77312F27F1E4005780C7 /* Protocols */,
7D2A77372F27F1E4005780C7 /* Types */,
7D48BCC92E51524200D7F6F7 /* CMakeLists.txt */,
7D6FEE312E88A4B9007C1B86 /* ContainersPreview.docc */,
);
path = ContainersPreview;
@@ -1490,6 +1506,17 @@
path = Container;
sourceTree = "<group>";
};
7D59D0652FE49C87005B5097 /* Conformances */ = {
isa = PBXGroup;
children = (
7D59D0612FE49C87005B5097 /* InputSpan+Container.swift */,
7D59D0622FE49C87005B5097 /* MutableSpan+Container.swift */,
7D59D0632FE49C87005B5097 /* OutputSpan+Container.swift */,
7D59D0642FE49C87005B5097 /* Span+Container.swift */,
);
path = Conformances;
sourceTree = "<group>";
};
7D7246822F3D9DDB00112FD0 /* HashTable */ = {
isa = PBXGroup;
children = (
@@ -1941,6 +1968,7 @@
children = (
7DEBDAE229CBEE5300ADC226 /* IntegerTricks */,
7DEBDADA29CBEE5300ADC226 /* UnsafeBitSet */,
7DFC9DF62FEB5D7D00BE8808 /* CMakeLists.txt */,
7DE91F3029CA70F3004483EB /* _SortedCollection.swift */,
7DE91F3829CA70F3004483EB /* _UniqueCollection.swift */,
7DAD89A82E8B09EC00DD5786 /* Debugging.swift */,
@@ -1956,7 +1984,8 @@
7DAD89AD2E8B09EC00DD5786 /* UnsafeMutableBufferPointer+Extras.swift */,
7DAD89AE2E8B09EC00DD5786 /* UnsafeMutableRawBufferPointer+Extras.swift */,
7DAD89AF2E8B09EC00DD5786 /* UnsafeRawBufferPointer+Extras.swift */,
7DE91F2E29CA70F3004483EB /* CMakeLists.txt */,
7D77E6242FD0F87B003FA63B /* UnsafePointer+Extras.swift */,
7D77E6262FD0F940003FA63B /* UnsafeMutablePointer+Extras.swift */,
);
path = InternalCollectionsUtilities;
sourceTree = "<group>";
@@ -2685,6 +2714,7 @@
7D2A77952F27F2BF005780C7 /* Deque+Codable.swift in Sources */,
7D2A77962F27F2BF005780C7 /* RigidDeque+Experimental.swift in Sources */,
7D2A77972F27F2BF005780C7 /* Deque+Testing.swift in Sources */,
7D12E33D2FF5CC2A003050AB /* OutputSpan+Extras.swift in Sources */,
7D2A77982F27F2BF005780C7 /* RigidDeque+Replacements.swift in Sources */,
7D7246872F3D9DDB00112FD0 /* _HTable+Iteration.swift in Sources */,
7D7246882F3D9DDB00112FD0 /* RigidDictionary.swift in Sources */,
@@ -2718,6 +2748,7 @@
7D57A2B82F33FF48002543BD /* RigidArray+Consumption.swift in Sources */,
7DA23F582F32C66300E4C03A /* RigidArray+Equatable.swift in Sources */,
7D479CFC2F4D080500A8CB59 /* UniqueDictionary+Removals.swift in Sources */,
7D77E6272FD0F94B003FA63B /* UnsafeMutablePointer+Extras.swift in Sources */,
7D479CFD2F4D080500A8CB59 /* UniqueDictionary+Keys.swift in Sources */,
7DE9208A29CA70F4004483EB /* BigString+Comparable.swift in Sources */,
7DE9213629CA70F4004483EB /* TreeSet+SetAlgebra basics.swift in Sources */,
@@ -2731,6 +2762,7 @@
7DE9204629CA70F3004483EB /* _Hashtable+Header.swift in Sources */,
7DE9208129CA70F4004483EB /* BigString+CustomStringConvertible.swift in Sources */,
7DE920A929CA70F4004483EB /* Optional Utilities.swift in Sources */,
7D77E6252FD0F880003FA63B /* UnsafePointer+Extras.swift in Sources */,
7DE920BD29CA70F4004483EB /* BitSet+SetAlgebra symmetricDifference.swift in Sources */,
7DE9208229CA70F4004483EB /* BigString+BidirectionalCollection.swift in Sources */,
7D479CDF2F47D5CA00A8CB59 /* RigidDictionary+Insertions.swift in Sources */,
@@ -3054,6 +3086,10 @@
7DE9217E29CA70F4004483EB /* Heap+ExpressibleByArrayLiteral.swift in Sources */,
7D57EDD32F647DB10029D5E3 /* RandomAccessContainer.swift in Sources */,
7D57EDD52F647DB10029D5E3 /* MutableContainer.swift in Sources */,
7D59D0662FE49C87005B5097 /* Span+Container.swift in Sources */,
7D59D0672FE49C87005B5097 /* InputSpan+Container.swift in Sources */,
7D59D0682FE49C87005B5097 /* MutableSpan+Container.swift in Sources */,
7D59D0692FE49C87005B5097 /* OutputSpan+Container.swift in Sources */,
7D57EDD62F647DB10029D5E3 /* DynamicContainer.swift in Sources */,
7D57EDD72F647DB10029D5E3 /* Drain+Reduce.swift in Sources */,
7D57EDD82F647DB10029D5E3 /* Producer+Map.swift in Sources */,
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2640"
LastUpgradeVersion = "2700"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
-1
View File
@@ -22,7 +22,6 @@ OTHER_SWIFT_FLAGS = $(inherited) \
-enable-experimental-feature AddressableParameters \
-enable-experimental-feature AddressableTypes \
-enable-experimental-feature SuppressedAssociatedTypesWithDefaults \
-enable-experimental-feature BorrowAndMutateAccessors \
-enable-experimental-feature "AvailabilityMacro=SwiftStdlib 5.0: macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" \
-enable-experimental-feature "AvailabilityMacro=SwiftStdlib 5.1: macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" \
-enable-experimental-feature "AvailabilityMacro=SwiftStdlib 5.6: macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" \