Commit Graph
20 Commits
Author SHA1 Message Date
Karoy Lorentey 51a1554f89 Introduce _UniqueCollection & _SortedCollection
These marker-like protocols will allow certain
generic operations to get a performance boost
if the passed-in value happens to be guaranteed
to contain unique elements or to be sorted.

Also, review API checker protocols for Sets and
sorted collections and adjust things as needed.

BitSet gains custom implementations for min()
and max() as part of these improvements.
2022-10-19 01:40:06 -07:00
Karoy Lorentey 02ea4e8492 [_CollectionsTestSupport] Move StringConvertibleValue under Utilities 2022-10-18 21:44:24 -07:00
Karoy Lorentey 2e9447fb1c [_CollectionsTestSupport] Richer support for combinatorial testing 2022-10-13 15:45:08 -07:00
Karoy Lorentey 6286cd0b99 Restore support for building with Swift 5.5
This is mostly about adding more type declarations to deal with type checker limitations in the older compiler.
This also includes workarounds that allow better support for CodingKeyRepresentable in PersistentDictionary, and it fixes a couple of small oversights on various #else branches.
2022-10-10 18:07:49 -07:00
Karoy Lorentey 0b86bb11d2 [PersistentSet] Flesh out API surface
Add customary overloads for high-level Set operations.
2022-10-09 15:26:32 -07:00
Karoy Lorentey 4604c1bc38 [test] Add SetAPIChecker protocol
This is useful for validating the API surface of set-like types,
ensuring that we haven’t forgotten to implement members that
are part of users’ baseline expectations.

To ensure maximum utility, this protocol refines neither Collection
nor SetAlgebra.
2022-10-09 13:33:23 -07:00
Karoy Lorentey 78ac2eaed7 [BitSet] Add remove(at:) implementation 2022-10-09 13:20:12 -07:00
Karoy Lorentey f71ebd9494 [PersistentDictionary] Implement structural merge operations
Merging is best done in-place, as merging a non-empty dictionary will
always mutate the dictionary, so we don’t have to tiptoe around
uniqueness issues.

(The union operation on PersistentSet is vaguely similar, but not
quite — unlike with merge, union is able directly link shared subtrees
into the result. However, a similar optimization may be worthwhile for
symmetricDifference.)
2022-09-30 19:55:04 -07:00
Karoy Lorentey a453335b26 [tests] Delay checking Indices until we’re done with the collection itself
Also, don’t check `DefaultIndices` — it’s fine to
assume it implements Collection as long as the base collection is
correct.
2022-09-23 11:15:46 -07:00
Karoy Lorentey b7bfc52664 [test] Add Dictionary API checker protocol
This can be used to verify that a new dictionary implementation
provides all expected members.
2022-09-19 21:25:07 -07:00
Karoy Lorentey d2e82ada53 [tests] checkBidirectionalCollection: Don’t pointlessly repeat index(_:offsetBy:limitedBy:) probe 2022-09-19 17:27:22 -07:00
Karoy Lorentey de31437ee5 Merge branch 'feature/PersistentCollections' into release/1.1 2022-09-19 16:02:51 -07:00
Karoy Lorentey 31eca4a02c Merge branch 'feature/BitSet' into release/1.1
# Conflicts:
#	Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/Collections.xcscheme
2022-09-19 16:00:20 -07:00
Karoy Lorentey 52e3ea6ca9 [test] LifetimeTracked: Implement high-fidelity hash forwarding
`RawCollider` doesn’t like to get called through the high-level
hashing APIs.
2022-09-16 01:31:15 -07:00
Karoy Lorentey fcac09d86a [BitSet, BitArray] Add random factories 2022-08-25 22:21:34 -07:00
Karoy Lorentey 30da8ea7a1 [test] Enable index(_:offsetBy:limitedBy:) checks 2022-08-25 20:26:48 -07:00
Konrad `ktoso` Malawski 876586f924 expect type is correct 2022-08-17 11:06:07 +09:00
Karoy Lorentey 565c09e8d5 Review & update BitArray 2022-02-06 22:38:35 -08:00
Károly Lőrentey 13b5889757 [OrderedCollections][test] Strengthen withHiddenCopies tests
`withHiddenCopies(if:of:)` is supposed to check for value semantic violations where mutations of one copy affect another -- however, it currently only checks that iteration returns the same items before/after the change, not that the old copy is still in a fully consistent state.

Add an extra parameter that can be set to a closure that performs stricter checks.

Use it to call `_checkInvariants()` in ordered collections tests, uncovering a missing uniqueness check in `OrderedSet._insertNew(_:at:in:)`.
2021-11-11 00:39:29 -08:00
Karoy Lorentey f1f48d569a [test] CollectionsTestSupport → _CollectionsTestSupport
The underscored module name makes it clear that this isn't public API.
2021-09-03 15:57:09 -07:00