Commit Graph
1760 Commits
Author SHA1 Message Date
Karoy Lorentey 9d0f2adb6b Update README 2026-06-05 18:50:16 -07:00
Karoy Lorentey f3ede2e378 Delete unused test source 2026-06-05 18:46:12 -07:00
Karoy Lorentey e31c04143e Update CMake & Xcode build configurations 2026-06-05 18:45:56 -07:00
Karoy Lorentey 5c8d97dccb Merge pull request #660 from apple/dn/ordered-set-move
[OrderedCollections] Add move operations
2026-06-05 17:45:16 -07:00
David Nadoba 72f074a23a [OrderedCollections] Use pre-removal destination index for move APIs 2026-06-05 17:05:03 -07:00
David Nadoba 5a6af29d55 [OrderedCollections] Refine move APIs and simplify no-op check 2026-06-05 14:44:22 -07:00
David Nadoba a83773321e [OrderedCollections] Rework move APIs and extend to OrderedDictionary
Reworks the relocation API and extends it to `OrderedDictionary`:

* Renames the index-range move to `moveSubrange(_:to:)` (with a
  `RangeExpression` overload) and the by-value move to `move(contentsOf:to:)`,
  matching the conventions of `removeSubrange`/`insert(_:at:)`. Adds
  `move(fromIndices:to:)`, which takes the source indices directly.
* Factors the element rearrangement into generic
  `UnsafeMutableBufferPointer` operations (rotation / rotation+permutation /
  scatter) so `OrderedDictionary` relocates its keys and values in lockstep
  through the same code, adding only the parallel value move; the hash-table
  maintenance stays entirely in `OrderedSet`.
* The hot path runs in O(*d* + *k*) and falls back to O(`count`) for large
  moves; bucket maintenance chooses targeted updates or a full rebuild by the
  same threshold.
* `move(contentsOf:to:)` ignores elements/keys that aren't present; duplicate
  members are detected and trap.

Adds tests (exhaustive hash-table integrity, value alignment under lifetime
tracking) and move benchmarks for both types.
2026-06-04 22:33:54 -07:00
Karoy Lorentey 9ade2f7ba3 Merge pull request #664 from lorentey/benchmark-updates
Small benchmarking improvements
2026-06-02 18:13:55 -07:00
Karoy Lorentey c86ed20fc1 [Benchmark] Shareable(Set|Dictionary)Benchmarks → Tree$1Benchmarks 2026-06-02 17:57:49 -07:00
Karoy Lorentey b78086e6df [Benchmark] Resolve warnings under Swift 6.4 2026-06-02 17:48:22 -07:00
Karoy Lorentey 7a32c7582b [Benchmark] Enable sorted collection benchmarks, conditional on UnstableSortedCollections 2026-06-02 17:48:04 -07:00
Karoy Lorentey 346ab74f17 [Benchmark] Properly declare module dependencies 2026-06-02 17:47:14 -07:00
Karoy Lorentey 7220421ea8 [Benchmark] Define forwarding traits for swift-collections options 2026-06-02 17:46:53 -07:00
Karoy Lorentey 76f3560f3f [Benchmark] ENABLE_RUST_BENCHMARKS → EnableRustBenchmarks 2026-06-02 17:43:37 -07:00
Karoy Lorentey 0e46e9ba55 Merge pull request #661 from adityasingh2400/fix-issue-257
[SortedCollections] Fix _BTree default node capacity capping at 16
2026-06-02 17:04:51 -07:00
Aditya Singh ce67d512d5 [SortedCollections] Fix _BTree default node capacity capping at 16
The defaultInternalCapacity and defaultLeafCapacity computations used
Swift.min(16, capacityInBytes / MemoryLayout<Key>.stride), which capped
the node capacity at 16 regardless of element size. This defeated the
byte-budget intent: small elements should yield larger nodes, not be
clamped to 16. Use Swift.max instead so 16 acts as a floor and the
byte budget governs the upper bound, as confirmed by the maintainer
in issue #257.

Fixes #257
2026-05-29 00:52:15 -07:00
Karoy Lorentey cef9727051 Merge pull request #659 from adityasingh2400/fix-unsafe-buffer-trim
[InternalCollectionsUtilities] Fix _trim returning the wrong buffer region
2026-05-26 17:00:10 -07:00
David Nadoba 508f36f48d [OrderedSet] Add move(_:toOffset:)
Adds two overloads for relocating elements within an `OrderedSet`: one
taking a contiguous `Range<Int>`, and one taking a `Sequence<Element>`.
The moved elements occupy consecutive positions starting at the
destination, in the order they appear in the input.

The hot path runs in O(*d* + *k*) time, where *d* is the distance moved
and *k* is the number of elements moved; the implementation falls back
to O(`count`) for large moves.
2026-05-25 23:01:28 -07:00
Aditya Singh 0a3dcfd3a8 [InternalCollectionsUtilities] Fix _trim returning the wrong buffer region
The `_trim(first:)` and `_trim(last:)` helpers reassign `self` to the
remaining slice and then build the trimmed result from `self`'s now-updated
`baseAddress`/`count`, so they hand back a region that points into the wrong
place in the buffer.

`UnsafeMutableBufferPointer._trim(first:)` had this exact bug fixed earlier (it
captures `oldStart` before the reassignment), but three sibling helpers were
left untouched:

  * `UnsafeBufferPointer._trim(first:)` reads `baseAddress` after advancing
    `self`, so the returned prefix starts at the remainder instead of at the
    original head.
  * `UnsafeBufferPointer._trim(last:)` and
    `UnsafeMutableBufferPointer._trim(last:)` recompute `count &- cut` after
    shrinking `self`, so the returned suffix starts `cut` elements too early.

For a five-element buffer, `_trim(first: 2)` returned the bytes of `[30, 40]`
rather than `[10, 20]`, and `_trim(last: 2)` returned `[20, 30]` rather than
`[40, 50]`; trimming more than the count walked off the end of the buffer.

Capture the original start (and, for the suffix case, the post-trim count)
before mutating `self`, matching the already-correct `_trim(first:)` on the
mutable buffer. Adds direct tests covering both overloads on both buffer types.
2026-05-24 18:22:45 -07:00
Karoy Lorentey 9c02ebb097 Merge pull request #655 from apple/borrow-availability
Add missing availability to Borrow
2026-05-21 11:13:14 -07:00
Guoye Zhang 8cacd3c125 Add missing availability to Borrow 2026-05-18 17:50:20 -07:00
Karoy Lorentey fea17c02d7 Merge pull request #654 from lorentey/adjust-reexports
Resolve source break in the Collections module
1.5.1
2026-05-15 17:19:31 -07:00
Karoy Lorentey 1b3ec29d61 [Collections] Declare generic arguments on forwarding typealiases
Otherwise the typealiases do not work as intended on public API that mentions them in client modules.
2026-05-15 17:02:45 -07:00
Karoy Lorentey c3ba833517 Add basic tests for Collections module 2026-05-15 16:57:22 -07:00
Karoy Lorentey de84ac97fe Merge pull request #650 from lorentey/disable-formatter-on-wasm
[BasicContainers] Don’t define LLDB formatter symbol on Wasm
2026-05-15 10:53:12 -07:00
Karoy Lorentey a731a7fdad [BasicContainers] Don’t define LLDB formatter symbol on Wasm
While we’re here, follow our explicit access control rule when defining the variable.
2026-05-12 15:33:22 -07:00
Karoy Lorentey 7b371ce850 Merge pull request #649 from apple/fb-unique-box-borrow
Guard `UniqueBox.borrow` correctly
2026-05-11 18:36:53 -07:00
Franz Busch f674e13c3d Guard UniqueBox.borrow correctly
Correctly guard the `borrow` method behind the compiler version
2026-05-11 14:43:54 +02:00
Karoy Lorentey 03cc312c2c Merge pull request #647 from lorentey/work/release-prep
1.5.0 release preparations
1.5.0
2026-05-07 16:47:02 -07:00
Karoy Lorentey 599e65addc Silence bogus license checker error for the FormatterFixtures package manifest 2026-05-07 16:32:38 -07:00
Karoy Lorentey 8ecf8c711c [Xcode] Don’t enable traits by default 2026-05-07 16:25:00 -07:00
Karoy Lorentey 3614f74e05 Clean up package manifest 2026-05-07 16:24:37 -07:00
Karoy Lorentey c38e47d03e [BasicContainers, DequeModule] Avoid using deprecated API 2026-05-07 16:17:20 -07:00
Karoy Lorentey 72ee2bf645 [BasicContainers] Update CMakeLists.txt 2026-05-07 16:16:57 -07:00
Karoy Lorentey f196269e7f Define placeholder availability macro for SwiftStdlib 6.5 2026-05-07 16:16:34 -07:00
Karoy Lorentey f83bd74aea Move FormatterFixtures into a nested package 2026-05-07 16:15:02 -07:00
Karoy Lorentey e5236d4e8e Update README 2026-05-07 15:46:33 -07:00
Karoy Lorentey db24e1b90a Merge pull request #646 from lorentey/work/mutableref
[ContainersPreview] `struct Inout` ⟹ `struct MutableRef`
2026-05-07 10:31:33 -07:00
Karoy Lorentey 40c730869d [ContainersPreview] Add more detailed tests for MutableRef’s API surface 2026-05-06 18:34:57 -07:00
Karoy Lorentey 16d6b8e1fe [ContainersPreview] Inout ⟹ MutableRef 2026-05-06 18:28:07 -07:00
Karoy Lorentey 77e99ff65a Merge pull request #643 from lorentey/work/ref
[ContainersPreview] `struct Borrow` ⟹ `struct Ref`
2026-05-06 18:16:08 -07:00
Karoy Lorentey 05f19cf771 [ContainersPreview] Add more detailed tests for struct Ref 2026-05-06 18:00:13 -07:00
Karoy Lorentey 1fd366764d [ContainersPreview] Ref: Fix fallback implementation; make sure we have deprecated aliases for old names 2026-05-06 18:00:13 -07:00
Karoy Lorentey 18c58bcca4 [ContainersPreview] Ref: Disable Builtin.Borrow for now 2026-05-06 18:00:13 -07:00
Karoy Lorentey a6fd64697a [ContainersPreview] Borrow ⟹ Ref
Also update the type’s public API surface to reflect SE-0519, leaving deprecated aliases for the old names.
2026-05-06 18:00:13 -07:00
Karoy Lorentey 90d8735151 Merge pull request #644 from FranzBusch/fb-trait-defines
Use the defines from traits directly
2026-05-06 15:12:46 -07:00
Karoy Lorentey 702b6cf218 Merge pull request #624 from apple/dependabot/github_actions/swiftlang/github-workflows/dot-github/workflows/swift_package_test.yml-0.0.11
Bump swiftlang/github-workflows/.github/workflows/swift_package_test.yml from 0.0.9 to 0.0.11
2026-05-06 15:10:41 -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 12eb78f778 Merge pull request #640 from lorentey/uniquebox
Rename `Box` to `UniqueBox`; align API surface with SE-0517
2026-05-05 17:47:42 -07:00
Karoy Lorentey bb7839ae50 Merge pull request #642 from lorentey/doc-fix
[BasicContainers] Fix copypasta in `UniqueArray.edit`’s docs
2026-05-05 17:31:51 -07:00