insert(addingCount:initializingWith:) batches elements through a
temporary OutputSpan and loops while `remainder > 0`. When the
`UnstableContainersPreview` trait is disabled, the span's `defer`
handler moved elements out of the temporary buffer but never decremented
`remainder`, so the loop spun forever whenever the initializer didn't
fill every batch. Update `remainder` the same way the preview branch
already does, and add a regression test (issue #774).
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
prepend(from:) looped calling uncheckedPrepend, which each time placed the
new batch at index 0 of the deque. Later batches ended up in front of earlier
ones, producing items in the wrong order.
Fix: use uncheckedInsert(addingCount:at:added) so each new batch is inserted
immediately after the items already prepended in earlier passes. Promote the
overload from internal to package so ContainersPreview can reach it.
Adds a regression test covering single- and multi-batch producers prepending
into empty and non-empty deques. Fixes#763.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Run the member identity checker against SortedSet, including a
multi-level tree. With #761's fix reverted, it fails with the wrong
member stored by insert(_:) and update(with:), as reported in #760.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the member identity checker against OrderedSet's unordered view,
covering both the unhashed and hashed storage paths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check which of two equal but distinguishable members insert(_:),
update(with:) and remove(_:) keep and return, using Set as the
reference.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_rawHashValue(seed:) looped on nextSpan() without checking for the
empty span the iterator returns once it is exhausted, so hashing any
RigidSet or UniqueSet spun forever. Break on an empty span, as == does.
Add test_hashable for both types, modeled on RigidArrayTests: equal
sets built with different capacities and insertion orders must hash
equally. Both tests hang without the fix.
Fixes#765.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BitSet.Counted keeps its own count and forwards its index operations to
BitSet, but no test ran it through a collection checker. Run
checkBidirectionalCollection on it with the same inputs as BitSet's
test_collection_strides.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Doubling the other model's elements only exposes an implementation that
counts occurrences instead of distinct members when the two sets share
at least half of the receiver's elements, which depended on the models
a test happened to pick. A BitSet.isStrictSubset that counted
duplicates passed every model pair. Repeat the other model
`xm.count + 2` times instead, so a shared element always appears more
often than the receiver has members.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every sequence the checker passed reported its exact count, so an
implementation that trusts underestimatedCount went unnoticed: an empty
TreeSet whose isEqualSet returned `other.underestimatedCount == 0`
passed every test. Also check the predicates and isEqualSet against a
single-pass MinimalSequence, whose underestimatedCount is 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BitSet.Counted's tests declare SetAPIExtras, but it was never run
through checkSetAlgebra. Use the same models as BitSet's test. With the
isEqualSet check from the previous commit, this fails if #749's fix is
reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No checker exercised isEqualSet(to:), and no test passed it a sequence
with duplicates, so #749's bug, where BitSet.Counted rejected such
sequences, went unnoticed until it was reported. Add a checkSetAlgebra
overload for SetAPIExtras types that also checks isEqualSet against the
models: given another Self, an Array, an Array with duplicates, and a
Set, which takes the _UniqueCollection path in the types that have one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The five predicates were only ever given another Self, so a type whose
Sequence-taking overloads first check for Self never ran their
general path under the checker. Check them against an Array of the
other model, with and without duplicates, as the set operations
already are.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SortedSet declares SetAPIChecker since #746, but was never run through
checkSetAlgebra. The models are the same as TreeSet's and OrderedSet's,
plus three larger ones so that the sets span more than one B-tree level
in debug builds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>