Commit Graph
37 Commits
Author SHA1 Message Date
Karoy Lorentey 827fef0660 Merge pull request #817 from Joseph-Cursio/drainable-container-check
Add checkDrainableContainer and fix RigidArray's consumeLast recursion
2026-11-10 11:01:51 -08:00
Joseph CursioandClaude Opus 5.5 8275b719e3 Check UniqueArray with checkPermutableContainer
Run the permutable container checker against UniqueArray, over arrays of
up to ten items, full and with spare capacity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 16:48:47 -06:00
Joseph CursioandClaude Opus 5.5 fe90f11c44 Check UniqueArray with checkDrainableContainer
Run the drainable container checker against UniqueArray, over arrays of
up to six items, full and with spare capacity. UniqueArray doesn't
override the _customConsumeLast(_:) hook, so it passes with #814's fix
reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 19:16:39 -06:00
Joseph CursioandClaude Opus 5.5 d1f377cb2d Check UniqueArray with checkMutableContainer
Run the mutable container checker, which also runs the bidirectional
one, against UniqueArray.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 04:51:50 -05:00
Karoy Lorentey bbdd37ada7 Fix a variety of issues in the nextSpan/previousSpan method family 2026-10-21 19:56:55 -07:00
Karoy Lorentey 4d092451ef Merge pull request #781 from aashish254/fix-772-replace-subrange-returned-range
[BasicContainers] Fix returned range of replaceSubrange(_:addingCount:initializingWith:)
2026-10-21 16:33:43 -07:00
Aashish 96648ca1d8 Fix replaceSubrange(_:addingCount:initializingWith:) returning a range sized by the requested count
The closure-based replaceSubrange overloads on RigidArray (and, through
them, UniqueArray and the generic RangeReplaceableContainer overloads)
returned subrange.lowerBound ..< subrange.lowerBound + newItemCount even
when the initializer performed a short fill, so the returned range could
cover old elements that were never replaced and extend past endIndex.
Return the number of items actually initialized (span.count), matching
insert(addingCount:at:initializingWith:).

Fixes #772
2026-10-20 19:45:05 +05:45
Aniket 80d8052b4b [BasicContainers] Fix UniqueArray.append(moving:) dropping and leaking every element
Signed-off-by: Aniket <aniketkomailkro@gmail.com>
2026-10-17 02:21:15 -07:00
Karoy Lorentey 9e7949017a Tests: add unsafe keywords where needed 2026-10-01 11:44:47 -07:00
Karoy Lorentey 44b674265c Update import statements 2026-09-29 15:41:05 -07:00
Karoy Lorentey 537bf9cbfb Drop support for Swift 6.0 and 6.1
This allows the use of Span types without `#if compiler` guards.
2026-09-21 13:34:39 -07:00
Karoy Lorentey 5cebba6f29 Refactor DrainableContainer/RangeReplaceableContainer/DynamicContainer
Range replacement operations generally need to invalidate all indices, and that means that we lose our position in the container after each insertion/removal, unless we happen to be using a container with looser index invalidation (such as arrays or deques).

A linked list is an example for a container type where insertions/removals need to invalidate all indices — as we need to track index validation using a single version counter that is stored in the list’s head. However, it would not be acceptable to lose our place whenever we insert a new item to the list; therefore, to mitigate the validation issue, this commit changes all range-replacement operations to return a valid index range to the affected items in the container.

This is a radical break from `RangeReplaceableCollection`. It fixes a long-standing defect with it, but it also makes it tricky to conform the same type to both protocol families, as the two require the “same” methods to return different types (`Void` vs `Range<Index>`).

Given that the LSG has intentionally diverged `UniqueArray.removeAll()` from RangeReplaceableCollection semantics, I expect this isn’t going to be an issue. For example, types with existing collection conformances can expose container views, mitigating such semantic differences.

To allow SubrangeConsumers to work without losing position, add a new protocol, `ContainerDrain` with a consuming `finalize` operation that returns a valid index in the resulting container state.

While we’re here, apply the API tweaks from SE-0527:
- Revert the `replace(removing:…:)` names, rolling back to `replaceSubrange(_:…:)` .
- Similarly, rename `consume(_:)` → `consumeSubrange(_:)`
- Rename `reallocate(capacity:)` → `setCapacity(_:)`.
2026-09-14 20:37:12 -07:00
Karoy Lorentey 1f94ac8f54 Implement (partial) Container validation 2026-09-01 10:14:42 -07:00
Karoy Lorentey 3d45fae460 [BasicContainers] Add regression tests for RigidArray/UniqueArray’s expected memory layout 2026-07-22 19:04:48 -07:00
Karoy Lorentey ff695132ed Bump availability of Iterable_ and Container protocols to SwiftStdlib 6.4
This is preparing for switching over to the stdlib’s definition of `protocol Iterable`, assuming it will land with macOS 27/iOS 27 etc availability; `Container` is refining `Iterable`, so it needs matching availability.

If `Iterable` won’t ship in Swift 6.4, then we’ll need to bump this again.
2026-07-07 14:22:45 -07:00
Karoy Lorentey 1f5d0ab343 [BasicContainers, DequeModule] Resolve warnings in 6.4 2026-06-18 13:21:42 -07:00
Karoy Lorentey 9aca86f36b Update to reflect new name of expect{Rigid,Unique}ArrayContents 2026-06-17 13:58:54 -07:00
Karoy Lorentey 28e9d98a7e Fix deprecation warnings 2026-06-17 13:48:54 -07:00
Alejandro Alonso 6da58357a3 Rename reallocate to setCapacity for Rigid and UniqueArray
Update UniqueArray.swift

Update UniqueArray.swift
2026-06-17 13:48:53 -07:00
Franz Busch 3c373b900c Use the defines from traits directly
Package traits already pass defines with their trait name when building. Instead of adding our own conditional defines based on the traits we can use the trait provided defines directly. I observed that various tooling behaves better with the trait provided defines.
2026-05-06 07:41:02 -07:00
Karoy Lorentey 5bd8ab095d [BasicContainers] UniqueArray.replace(removing:copying): Fix overallocation issue
`UniqueArray.replace(removing:copying:)` overloads overestimated the amount of memory they need, sometimes leading to unnecessary reallocations. Fix this.
2026-04-22 16:23:15 -07:00
Karoy Lorentey 597b7a7dd2 Revert most of the availability constraints from 419e2f and 4c0482 🎉 2026-03-27 11:25:43 -07:00
Karoy Lorentey 4c04822689 [ContainersPreview] Exhibit B in the case against prototyping things in the stdlib 😳 2026-03-26 18:13:22 -07:00
Karoy Lorentey 70a25f1f69 [ContainersPreview] Bump required toolchain to 6.4 for new protocols 2026-03-26 14:51:08 -07:00
Karoy Lorentey 8f88cce7c7 [BasicContainers, ContainersPreview] Make sure package traits “work” on 6.2 toolchains
“Work” in this case means that they can be enabled without breaking the build — not necessarily that all features are available.

Swift 6.2 is highly prone to runtime crashes in `swift_getTypeByMangledName` in generic code that uses ownership features. Swift 6.3 will resolve that.
2026-03-17 15:38:34 -07:00
Karoy Lorentey 1c69635852 Add SPDX-License-Identifier tags 2026-03-05 19:39:24 -08:00
Karoy Lorentey d9b09ecde8 Update copyright dates 2026-03-05 19:39:20 -08:00
Alejandro Alonso 3bf8de6e2b Add new span taking copying initializers to Rigid and UniqueArray 2026-02-12 11:01:30 -08:00
Karoy Lorentey 653a60b8e7 replaceSubrange(_:...) → replace(removing:...) 2026-02-05 14:56:51 -08:00
Karoy Lorentey fabe5d8c87 RigidArray, UniqueArray, RigidDeque tests: Rework some assertions 2026-01-20 17:46:23 -08:00
Karoy Lorentey 7b5221ea24 RigidDeque: Add Container conformance and allow copying from Containers 2026-01-20 10:51:17 -08:00
Karoy Lorentey 67abaf5182 Replace Container with a far less powerful (but more universal) Iterable construct
I’m hoping Container will return later.
2026-01-08 17:28:23 -08:00
Karoy Lorentey 1dc2b7717f Revert "Don’t allow backdeployment of any Span types below the most recent Darwin OS releases"
This reverts commit 485e69bfb1.

# Conflicts:
#	CMakeLists.txt
2025-09-27 12:15:30 -07:00
Karoy Lorentey 485e69bfb1 Don’t allow backdeployment of any Span types below the most recent Darwin OS releases
References to Span types trigger an issue where SwiftPM isn’t able to run command line executable targets or tests on older OSes.

Set the availability of everything that needs span types to the most recent Apple OS releases.

Hopefully we’ll be able to revert this once we figure out a better workaround.
2025-09-26 22:38:18 -07:00
Karoy Lorentey 174efda735 RigidArray/UniqueArray: Final API cleanup pass
- Set availability to match Span availability
- Split implementation into multiple source files
- Add OutputSpan-based primitives that can be the bases of all append/insertion/replaceSubrange variants
- Add the ability to consume a subrange of items using an InputSpan
- Add bulk copying operations generic over the new Container protocol
2025-09-26 18:39:56 -07:00
Karoy Lorentey 8890f47600 Remove workaround for lack of recent snapshots for Swift 6.2 on Windows 2025-09-04 15:28:15 -07:00
Karoy Lorentey 7a4e26b4c3 Renaming: DynamicArray → UniqueArray; ArrayModule → BasicContainers 2025-09-04 15:26:13 -07:00