Commit Graph
27 Commits
Author SHA1 Message Date
Karoy Lorentey ffa4a58bc1 Update remaining copyright notices 2024-02-02 16:20:22 -08:00
Karoy Lorentey 09c09f0f73 Fix CustomStringConvertible/CustomDebugStringConvertible conformances
- For CustomStringConvertible, `description` should print elements using `String(reflecting:)` rather than `String(describing:)`, to avoid element output from interfering with syntactically relevant punctuation within structured list displays.
- To make this work without making displays overly verbose, make `debugDescription` mostly the same as `description`, except for escaping raw string displays when and if needed.
- Avoid printing type names in `debugDescription` — it is generally not helpful, as the type is already easily accessible elsewhere. Including it makes for overly verbose displays when the type serves as an Element of a collection.
- Avoid having `debugDescription` return the empty string — it can be confusing when such a description appears in list displays.

Resolves #301.
2023-07-06 17:25:11 -07:00
Karoy Lorentey de0f594185 [BitSet] Fix a thinko in BitSet.isEqualSet 2023-05-18 18:36:29 -07:00
Karoy Lorentey cbab9e3737 Introduce COLLECTIONS_SINGLE_MODULE condition 2023-03-21 18:42:33 -07:00
Karoy Lorentey 8f7d5fd505 [SetAlgebra types] isEqual(to:) → isEqualSet(to:)
The `isEqual(to:)` methods are a bit too confusing — they implement
mathematical set comparisons (ignoring element ordering and, in the
case of the Sequence variant, even element multiplicities), so it
seems better to highlight this by putting a `Set` in the name.
2022-10-31 15:05:12 -07:00
Karoy Lorentey ba7e3927e7 [BitSet] Adjust test for updated mirror display style 2022-10-28 10:40:42 -07:00
Karoy Lorentey 1355d478af [BitSet] Review, test, extend, and document binary set operations 2022-10-21 19:49:07 -07:00
Karoy Lorentey 9cd030f21e [BitSet] Add missing Custom[Debug]StringConvertable conformances, review existing ones
Add `Custom[Debug]StringConvertible` conformance on `BitSet.Index`.
2022-10-20 17:14:52 -07:00
Karoy Lorentey 001df8e325 [BitSet] Review, test, fix, and document set relation predicates
- Update documentation
- Improve performance where possible
- Add missing test coverage where needed
2022-10-19 15:20:17 -07:00
Karoy Lorentey 291623d391 [BitSet] Implement isEqual(to:) family of functions 2022-10-19 01:40:06 -07:00
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 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
Károly Lőrentey a137a71c6f [BitSet] Use a platform-independent Codable encoding 2022-09-04 19:26:34 -07:00
Karoy Lorentey 72497fe212 [BitSet] Add Codable conformance 2022-08-28 17:32:33 -07:00
Karoy Lorentey c02557f717 [BitSet] Add member subscripts 2022-08-28 16:33:50 -07:00
Karoy Lorentey b5511d3711 [BitSet] Add custom implementation for filter 2022-08-26 14:21:37 -07:00
Karoy Lorentey b9ea3f0dd3 [BitSet] Add Custom[Debug]StringConvertible, CustomReflectable conformances 2022-08-26 14:21:15 -07:00
Karoy Lorentey fcac09d86a [BitSet, BitArray] Add random factories 2022-08-25 22:21:34 -07:00
Karoy Lorentey da84296b9b [BitSet] Add custom sorted(), returning self 2022-08-16 15:53:06 -07:00
Karoy Lorentey 4cb8ecebee [BitSet] Add new initializers (from words & bit arrays) 2022-08-16 15:44:13 -07:00
Karoy Lorentey cbf933665b [BitSet] Revert to non-generic BitSet
Also, remove members that were generic over FixedWidthInteger.
2022-08-12 19:22:24 -07:00
Károly Lőrentey 1d1fbc82d4 [BitSet] Make BitSet generic over its Element
This gets rid of the weird asymmetry between reading the contents of a BitSet (where we used to always get Int values) and mutating it (where we used to be able to give it values fo any fixed-width integer type).
2022-07-30 23:25:53 -07:00
Karoy Lorentey 84e6c006f5 [BitSet][test] withInterestingSets: fix 9% sampling 2022-06-20 12:54:53 -07:00
Károly Lőrentey 8f2e0c79c3 Review & update BitSet
This is a work in progress; in particular, it adds a cached `count` to BitSet, which may turn out to be a bad idea. (It generates extra work for bulk operations even if the count is never needed.) I think replacing this with a cached `startIndex` might be more useful in practice.

The `_UnsafeBitset` type from the OrderedCollections module is brought over as `BitSet._UnsafeHandle`. This implements an (internal-only) fixed-size bitset.

`BitSet` now conforms to `SetAlgebra`. We decided against this in the initial implementation, but on reflection, it seems like the right move. (The somewhat nonsensical `insert` and `update` methods are unfortunate, but consistency is valuable.)
2022-01-10 23:35:33 -08:00
Károly Lőrentey b33bd007d6 Remove benchmark results from source root 2022-01-10 17:10:23 -08:00
Károly Lőrentey 537382f2a6 BitArrayModule ⟹ BitCollections 2021-12-28 15:45:38 -08:00