Commit Graph
137 Commits
Author SHA1 Message Date
Karoy Lorentey 022795168a [BasicContainers] Enable APIs scheduled to ship in 1.5.0
- `RigidArray.nextMutableSpan(after:maximumCount:)`
- `UniqueArray.nextMutableSpan(after:maximumCount:)`
- `RigidDeque.nextMutableSpan(after:maximumCount:)`
- `UniqueDeque.nextMutableSpan(after:maximumCount:)`
- `UniqueArray.init(minimumCapacity:)` (replacing `.init(capacity:)`)
- `UniqueDeque.init(minimumCapacity:)` (replacing `.init(capacity:)`)
- `RigidDeque.index(before:)`
- `UniqueDeque.index(before:)`
- `RigidDeque.formIndex(before:)`
- `UniqueDeque.formIndex(before:)`
2026-05-05 16:01:31 -07:00
Karoy Lorentey 9364ee33b1 Merge pull request #607 from kastiglione/Debugging-Add-lldb-data-formatter-for-RigidArray
[Debugging] Add lldb data formatter for RigidArray
2026-04-30 17:35:23 -07:00
Karoy Lorentey 215a9ac0a7 Merge pull request #632 from lorentey/assorted-fixes
[BasicContainers, DequeModule]: Assorted fixes
2026-04-30 15:53:21 -07:00
Manoj Mahapatra 6cce7de52e fix: reserveCapacity DocC link in RigidArray 2026-04-29 12:41:08 -07:00
Karoy Lorentey 4b8dc6d951 BasicContainers] RigidDictionary.udateValue(forKey:with:): Fix undefined behavior on removals 2026-04-27 16:42:51 -07:00
Franz Busch 793bcd5d66 Update the count 2026-04-25 17:43:25 +02: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 6ed215dcc2 Merge pull request #629 from lorentey/fix-fancy-rigidarray-replacement
[BasicContainers] RigidArray.replace(removing:consumingWith:addingCount:initializingWith:): Fix correctness issue with partial initialization
2026-04-22 16:10:13 -07:00
Karoy Lorentey d8ace00d14 [BasicContainers] RigidArray.replace(removing:consumingWith:addingCount:initializingWith:): Fix correctness issue with partial initialization
The original code was invoking `_closeGap` with an incorrect size (from `append` rather than `replace`), leading to runtime traps and potential memory safety issues if the `resize` invocation ends up underfilling the container.
2026-04-22 15:32:55 -07:00
Karoy Lorentey b75bd4ef01 [BasicContainers] RigidSet.insert(maximumCount:from:): Fix spurious capacity overflow caused by incorrect accounting 2026-04-22 15:12:55 -07:00
Karoy Lorentey bf8441dc95 [BasicContainers] Fix typos in doc comments 2026-04-08 18:31:11 -07:00
Karoy Lorentey a9b64d4f09 [BasicContainers] RigidArray,UniqueArray: Add Equatable conformance on Swift 6.4
This is currently conditional on the UnstableContainersPreview trait. (Swift 6.4 has not shipped yet, so we cannot unconditionally enable this without risking breakage.)
2026-04-08 18:31:11 -07:00
Karoy Lorentey 917eead3cb [BasicContainers] RigidArray,UniqueArray: Add FIXME for Custom[Debug]StringConvertible conformances 2026-04-08 18:31:11 -07:00
Karoy Lorentey 7f4cebd2c5 BasicContainers] Add UniqueArray.isTriviallyIdentical(to:) 2026-04-08 18:31:10 -07:00
Karoy Lorentey b4bfd6d02e [BasicContainers] RigidArray.isTriviallyIdentical(to:): Don’t require Equatable elements, but do allow noncopyable ones 2026-04-08 18:31:07 -07:00
Karoy Lorentey 35b7d8fba4 Fix lifetime requirements rigidly enforced in the latest nightlies 2026-04-03 17:01:36 -07:00
Dave Lee a2c67046c1 Support single-module mode
When `COLLECTIONS_SINGLE_MODULE` is set, a single `Collections` module is
built. Type names need to match accordingly.
2026-03-31 12:53:53 -07:00
Dave Lee f93d09ec67 Fix copyright dates 2026-03-31 12:53:52 -07:00
Dave Lee 86d184d89c Add generate_formatters.sh script 2026-03-31 09:56:00 -07:00
Dave Lee 7d721cbf7c Add license header 2026-03-31 09:55:49 -07:00
Dave Lee a6cefb8eda Update RigidArray+Formatter.swift 2026-03-30 11:02:31 -07:00
Karoy Lorentey e0ec6b0976 UniqueSet: Fix copypasta 2026-03-27 11:59:41 -07:00
Karoy Lorentey 685ef74751 Fix {Rigid,Unique}{Set,Dictionary} 2026-03-27 11:47:03 -07:00
Karoy Lorentey f83e9b6538 Rename Collection.underestimatedCount_ 2026-03-27 11:47:00 -07:00
Karoy Lorentey 597b7a7dd2 Revert most of the availability constraints from 419e2f and 4c0482 🎉 2026-03-27 11:25:43 -07:00
Nate Cook 61fb6f5d13 Fix errant CMakeList renamings 2026-03-27 11:02:44 -05:00
Nate Cook a99a015934 Disambiguate ContainersPreview and stdlib
Adds trailing underscores to the BorrowingSequence protocols and
requirements, in order to allow both parallel conformances and
the ability to evolve the requirements in this package.
2026-03-27 07:41:32 -05: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 d2d3b917ca [BasicContainers, ContainersPreview, DequeModule] More SuppressedAssociatedTypesWithDefaults fixups 2026-03-26 18:12:41 -07:00
Karoy Lorentey 419e2f7df2 [ContainersPreview] Exhibit A in the case against prototyping things in the stdlib 😞 2026-03-26 17:14:45 -07:00
Karoy Lorentey 70a25f1f69 [ContainersPreview] Bump required toolchain to 6.4 for new protocols 2026-03-26 14:51:08 -07:00
Nate Cook a2cf230400 Align BorrowingSequence etc with proposal
This updates the ContainersPreview module to use the same
API as the proposed BorrowingSequence protocol and its supporting
types. In particular, instead of using Span as the iterator for
itself and other contiguously-stored types, this introduces
SpanIterator.
2026-03-26 14:25:01 -05:00
Dave Lee a4bbcddef5 Make conditional cover whole file 2026-03-18 19:06:25 -07:00
Dave Lee 4e38902c23 Support only Swift 6.3+ 2026-03-18 19:05:15 -07:00
Dave Lee 43c367c3c2 Support compilers prior to 6.3 2026-03-18 19:02:12 -07:00
Dave Lee e6bfc56a47 manually remove trailing comma 2026-03-18 18:47:51 -07:00
Dave Lee 01f2c9101b [Debugging] Add lldb data formatter for RigidArray
This introduces a debugging data formatter for RigidArray using a new feature of LLDB:
[Formatter Bytecode][1]. The scope of this PR is a single initial data type, with the
short and long term plan being to support all types vended by Swift Collections.

The bytecode for this implementation is produced using a Python -> Formatter Bytecode
compiler, contained in the [`formatter_bytecode`][2] module.

The workflow for authoring and shipping the formatter is:

1. Update RigidArray.py as needed
2. Compile RigidArray.py to RigidArray+Formatter.swift (again, `formatter_bytecode`)
3. Compile RigidArray+Formatter.swift as part of the BasicContainers module

By including the bytecode in the binary, lldb can load RigidArray's data formatter
automatically, without any friction that comes with installation, setup, config,
updating, or versioning.

[1]: https://lldb.llvm.org/resources/formatterbytecode.html
[2]: https://github.com/llvm/llvm-project/blob/main/lldb/examples/python/formatter_bytecode.py
2026-03-18 18:40:36 -07:00
Karoy Lorentey a8389f300a [BasicContainers, DequeModule] Avoid defining new API in a point release
Stash them behind the UnstableContainersPreview package trait for now (making them non-public API).
2026-03-17 16:33:20 -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 6bbed0e1e2 [ContainersPreview] Conform [Unique,Rigid]Array and [Unique,Rigid]Deque to container protocols 2026-03-17 13:13:42 -07:00
Karoy Lorentey fda65e149b [BasicContainers] Hashed containers: Make _checkInvariants() dump the hash table on failure 2026-03-11 00:31:37 -07:00
Karoy Lorentey 16e7715941 [BasicContainers] Speed up removals from hashed containers 2026-03-10 23:50:41 -07:00
Karoy Lorentey a8cf90f49c [BasicContainers] Hashed containers: slightly improve maxProbeLength after removals 2026-03-10 23:50:40 -07:00
Karoy Lorentey 5636b32db7 [BasicContainers] Scramble small hashed containers
Don’t just append new items to the end of storage — it misleads clients into assuming that the containers preserve insertion order, when they most certainly don’t do that.

Instead, insert new items into the middle of storage, using an extra swap.
2026-03-10 23:06:08 -07:00
Karoy Lorentey e69d570c59 [BasicContainers] Implement shortcut for insertions
We don’t need to calculate the probe length of the item currently occupying the new item’s ideal bucket — it cannot possibly be lower than the new item’s. This spares one hash operation during insertions that result in a hash collision.
2026-03-10 23:06:08 -07:00
Karoy Lorentey 2a53ad50b0 [BasicContainers] Fix insertion algorithm
Due to a number of cascading off-by-one errors, the maximum probe length could end up getting set lower than the actual value, _sometimes_ rendering some items unreachable.

Weirdly, the issue seems to be rare enough that it somehow never triggered in any of my previous test runs.
2026-03-10 23:06:07 -07:00
Karoy Lorentey 634a0ae766 [BasicContainers] Implement _checkInvariants on hashed containers 2026-03-10 23:04:49 -07:00
Karoy Lorentey de436301e5 [BasicContainers] Allow standalone use of the UnstableHashedContainers trait
Oops, I lost a change that allowed enabling the UnstableHashedContainers trait without also opting into UnstableContainersPreview. Reimplement this functionality.
2026-03-09 15:59:38 -07:00
Karoy Lorentey 94e8cabe4b [BasicContainers] RigidArray: Correct spelling of replacement for deprecated method 2026-03-06 16:10:48 -08:00
Karoy Lorentey 5605e14682 [BasicContainers] Avoid defining set/dictionary types unless UnstableHashedContainers is enabled 2026-03-06 11:17:39 -08:00