Commit Graph
1206 Commits
Author SHA1 Message Date
Karoy Lorentey 2dae6db88f Merge pull request #697 from Hashim1999164/fix/sorted-dictionary-keys-values-equality
Fix inverted SortedDictionary Keys/Values/SubSequence equality
2026-08-11 14:25:33 -07:00
Karoy Lorentey 2875152465 Merge pull request #688 from inju2403/cleanup/replaceelement-reuse-replace
[OrderedCollections] Share OrderedSet's replace primitive with OrderedDictionary.replaceElement
2026-08-11 14:11:16 -07:00
Alejandro Alonso b2a1f89cc6 Add mutableValue(forKey:) to new dictionary types 2026-08-10 17:48:13 -07:00
Hashim1999164 01d981c87e Use tuple inequality in SortedDictionary.SubSequence equality.
Match the Keys and Values comparison style after review feedback.
2026-08-02 22:52:49 +05:00
Hashim1999164 1efcb6cabd Fix inverted equality in SortedDictionary Keys, Values, and SubSequence.
Equality comparisons returned false for matching elements and true for mismatches. Correct the comparisons and add coverage for the affected views.
2026-08-02 22:52:49 +05:00
Karoy Lorentey 2e10584446 Add a default implementation for MutableContainer.swapAt (for copyable elements) 2026-07-28 19:43:07 -07:00
Karoy Lorentey ec66640a15 Add some (untested) PermutableContainer algorithms 2026-07-28 19:43:07 -07:00
Karoy Lorentey fbe36a7af5 Rearrange Sources/ContainersPreview/Protocols/* 2026-07-28 19:43:06 -07:00
Karoy Lorentey 669eb09cea Use Iterable from the Standard Library, replacing the local definition 2026-07-27 13:32:46 -07:00
Karoy Lorentey 6b76536758 BidirectionalContainer: don’t re-declare distance(from:to:) as a non-overriding method
The original `Container` requirement is defined with the same semantics.
2026-07-22 19:07:41 -07:00
Karoy Lorentey 58e13a0525 Stop requiring BidirectionalContainer to provide comparable indices
This allows doubly linked lists to conform to the protocol.
2026-07-22 19:07:13 -07:00
Alejandro Alonso 73b55d00d0 Fix deinit on older compilers 2026-07-22 15:07:46 -07:00
Alejandro Alonso 4e6dc1b9dc Update CMakeLists.txt 2026-07-22 15:07:46 -07:00
Alejandro Alonso 389f79fd11 Fix unsafe pointer sources for older compiles 2026-07-22 15:07:45 -07:00
Alejandro Alonso 7f05a23266 Update CMakeLists.txt
Update CMakeLists.txt
2026-07-22 15:07:44 -07:00
Alejandro Alonso cbdda61d5d Split up the buffer pointer in RIgidArray 2026-07-22 15:07:41 -07:00
Karoy Lorentey 8380ca41da Merge pull request #682 from lorentey/container-updates
[ContainersPreview] Update Container protocols
2026-07-22 13:08:25 -07:00
Karoy Lorentey 06f6b6bf49 Use borrow & mutate accessors in InputSpan’s unchecked subscript 2026-07-21 16:32:03 -07:00
Karoy Lorentey 232dc7f9ee Add second parameter to Container.makeBorrowingIterator(from:to:) 2026-07-21 15:21:45 -07:00
Seungju LeeandKaroy Lorentey 771d6984e4 [OrderedCollections] Use exchange(_:with:) to avoid copying the old value
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2026-07-21 19:37:07 +09:00
Karoy Lorentey 98bc1f9965 Fix some issues on earlier toolchains 2026-07-20 16:54:23 -07:00
Karoy Lorentey ea64e6332f Update RandomAccessContainer
- Require Index to be Comparable
- Add `formIndex(_:offsetBy:limitedBy:)` algorithm
2026-07-20 15:45:32 -07:00
Karoy Lorentey e75f053e46 Update MutableContainer
- Add `nextMutableSpan(after:)` and `nextMutableSpan(after:maxCount:limitedBy)`, replacing `nextMutableSpan(after:maxCount:)` as the core access primitives
- Add `previousMutableSpan` default algorithms on bidirectional mutable containers
2026-07-20 15:44:35 -07:00
Karoy Lorentey ef0fba7f7f Resolve some implementation issues 2026-07-20 15:42:28 -07:00
Karoy Lorentey 95395ad9d2 Add BidirectionalContainer.spanBoundary(before:maxDistance:limitedBy:) and make it the core primitive 2026-07-20 11:51:43 -07:00
Karoy Lorentey e70b4df228 Introduce Container.nextSpan(after:maxCount:limitedBy:) and make it the core Container primitive 2026-07-18 14:14:13 -07:00
inju2403 f2d090be11 [OrderedCollections] Share OrderedSet's replace primitive with OrderedDictionary.replaceElement
#669 left `OrderedDictionary.replaceElement` untouched to keep that PR purely additive, noting it could later be reimplemented on top of `replace(at:with:)`. Both it and `OrderedSet.replace(at:with:)` performed the same "append the new member, swap it into position, then remove the old one from the end" step inline.

Factor that step into an internal `OrderedSet._replaceNew(at:with:in:)` primitive and call it from both, matching the existing `_appendNew` / `_removeExistingMember` primitives that `OrderedDictionary` already delegates its key-side mutations to. In `replaceElement` only the keys go through the primitive; the value at `index` is overwritten in place.

Sharing the mechanical step this way — rather than having `replaceElement` call `replace` directly — keeps each type's diagnostics intact: `OrderedDictionary` still traps with "Duplicate key: '\(key)'" and "Index out of range", not `OrderedSet`'s "Duplicate element" / "Index out of bounds". The shared step is already verified by the caller, so there is no behavior change.
2026-07-18 18:20:02 +09:00
Karoy Lorentey 391693a8ba Review and update BidirectionalContainer’s default implementations 2026-07-17 16:58:01 -07:00
Karoy Lorentey a7f6b90c99 Make the limit optional in Container.nextSpan(after:limitedBy:). Review and update default implementations
- Make `nextSpan(after:limitedBy:)` the core iteration interface
- Review default algorithms and update them to use it, speeding them up
- Spin off `Span._nextSpan(after:maxCount)` and `Span._nextSpan(after:limitedBy:)` with copying lifetime semantics. This allows forwarding to these without having to override lifetimes.
2026-07-17 16:57:26 -07:00
Karoy Lorentey 27fe58c42c Beef up ContainerIterator’s provided algorithms 2026-07-17 11:51:20 -07:00
Karoy Lorentey 99ac14d1fa previousSpan(before:maxCount:) ⟹ spanBoundary(before:maxDistance:)
This allows MutableContainers to support mutating iteration backwards without requiring a separate MutableBidirectionalContainer protocol.
2026-07-17 11:50:38 -07:00
Karoy Lorentey ea581e47e1 Add UnfoldProducer 2026-07-15 15:10:58 -07:00
Karoy Lorentey dcaffab0af Update Container
- Require Index to be Hashable
- Add strong complexity expectations. Require `isEmpty`, `count` and `endIndex` to have O(1) complexity. Recommend most index navigation methods to be linear in the distance traveled.
- Remove `index(alignedDown:)` and `index(alignedUp:)`; Collection views are far less relevant in this model, so index rounding is mostly unnecessary. (The need can still pop up when indices are shared between several views of layout-compatible Element types — such as a container of UInt64 than can also be interpreted as a container of UInt8; if that becomes a thing, we may need to bring these requirements back.)
- Add `nextSpan(after:limitedBy:)` as an alternative to `nextSpan(after:maximumCount:)`. This makes it possible to provide fast default implementations for `distance(from:to:)` and `formIndex(_:offsetBy:limitedBy:)`.
2026-07-15 15:10:58 -07:00
Karoy Lorentey 6210abf469 Update Producer/Drain algorithms
- Implement skip(by:) whenever possible
2026-07-14 17:54:03 -07:00
Karoy Lorentey dfd2e34009 Overhaul Producer’s skip(by:) to better align with Iterable
- Don’t allow `skip(by:)` to skip fewer than the requested number of items, unless it hits the end of the sequence or an error. Remove its Boolean return value.
- Introduce a variant of `skip(by:)` that doesn’t take an inout argument, losing the ability to report which item triggered a throw. This is just a standard algorithm; the protocol continues to require proper reporting of partial success.
- Use the stdlib’s `withTemporaryAllocation` method where possible to create temporary buffers.
2026-07-14 17:45:27 -07:00
Karoy Lorentey 899809d3f8 Merge pull request #669 from inju2403/feature/ordered-set-replace-at-index
[OrderedCollections] Add OrderedSet.replace(_:at:)
2026-07-13 13:04:37 -07:00
inju2403 1f0184e99d [OrderedCollections] Rename OrderedSet.replace(_:at:) to replace(at:with:)
Swap the parameter order and add the `with` label so the API matches the shape of `replaceSubrange(_:with:)` on RangeReplaceableCollection, per review feedback.
2026-07-08 17:57:15 +09:00
Karoy Lorentey 70dc238938 [BasicContainers] RigidDictionary, UniqueDictionary: Add keys property
This replaces `withKeys`, which is now deprecated.
2026-07-07 16:52:33 -07:00
Karoy Lorentey 62332dc40a Avoid borrow/mutate accessors before Swift 6.4 2026-07-07 16:52:32 -07:00
Karoy Lorentey b1cba02393 [DequeModule] Disable Equatable/Hashable conformance on pre-6.4 toolchains 2026-07-07 16:47:05 -07:00
Karoy Lorentey fbb8aa1e36 [DequeModule] UniqueDeque: Add isTriviallyIdentical(to:) 2026-07-07 16:42:51 -07:00
Karoy Lorentey 920bc2a81f [DequeModule] RigidDeque: Fix duplicate Equatable conformance 2026-07-07 15:21:26 -07:00
Karoy Lorentey 90f26545ce Merge pull request #673 from wjdtjq6/fix/doc-comment-typos
Fix typos in doc comments and a DocC article
2026-07-07 15:09:13 -07:00
Karoy Lorentey 638c62cd7b Merge pull request #674 from wjdtjq6/fix/superset-doc-comments
Fix superset set algebra doc comments
2026-07-07 15:08:52 -07:00
Karoy Lorentey 957813c2f4 Merge pull request #668 from inju2403/perf/orderedset-reverse-in-place
[OrderedCollections] OrderedSet.reverse(): update the hash table in place
2026-07-07 14:44:03 -07:00
Karoy Lorentey c6eabe862a Resolve access issues & missing imports 2026-07-07 14:34:41 -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 a80c9d1257 Container: Add makeBorrowingIterator(from:) and currentIndex(of:) requirements 2026-07-07 14:21:54 -07:00
Karoy Lorentey 721b5bce41 Iterable_: Define an ambiguity resolver for the default underEstimatedCount 2026-07-07 14:21:54 -07:00
Karoy Lorentey d0b4c4c215 IterableIterator_ → BorrowingIterator_ 2026-07-07 14:21:53 -07:00