Commit Graph
149 Commits
Author SHA1 Message Date
Karoy Lorentey ff2d526c1b [PersistentDictionary] Doc fixes 2022-10-31 17:27:49 -07:00
Karoy Lorentey 7d0d627f44 [PersistentSet] Fix doc typo 2022-10-31 17:20:15 -07:00
Karoy Lorentey 898d3c9a51 [PersistentCollections] Doc & benchmark updates in preparation of API review 2022-10-31 16:45:42 -07:00
Karoy Lorentey 581490a735 [CMake] Update CMakeLists.txts 2022-10-31 15:10:11 -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 14e86daeeb [PersistentSet] Iterator.next(): Make inlinable
For a cool 4x performance improvement. 😣
2022-10-31 14:03:49 -07:00
Karoy Lorentey d19fb14c46 [CMake] Update CMake configuration 2022-10-28 18:18:39 -07:00
Karoy Lorentey 98d62d236b [PersistentDictionary] More keys diffing APIs; additional documentation & testing 2022-10-28 12:19:08 -07:00
Karoy Lorentey 18a01247a3 [PersistentDictionary] Add missing documentation comments 2022-10-27 18:08:27 -07:00
Karoy Lorentey 57554c65c2 [PersistentDictionary] Add an argument label for init(keys:valueGenerator:) 2022-10-27 18:08:27 -07:00
Karoy Lorentey 6dd3756609 [PersistentDictionary] Remove init(uniqueKeys:values:)
This initializer was interesting for OrderedDictionary, where it made
for more efficient initialization of storage, but it’s less useful for
other dictionary types.
2022-10-27 18:08:27 -07:00
Karoy Lorentey 8a1b16229b [PersistentDictionary] Add initializer taking Self 2022-10-27 18:08:27 -07:00
Karoy Lorentey 1e1decfa6e [PersistentCollections] Tweak DocC docs 2022-10-27 18:08:27 -07:00
Karoy Lorentey d8e8f5cc19 [PersistentDictionary] Tweak docs 2022-10-27 18:08:27 -07:00
Karoy Lorentey 16687d78af [PersistentSet] Add more tests 2022-10-27 18:08:27 -07:00
Karoy Lorentey 1d2a52779c [PersistentSet] Add missing docs 2022-10-27 18:08:27 -07:00
Karoy Lorentey 84356e58c7 [PersistentCollection] Back out BidirectionalCollection conformance
BidirectionalCollection has the connotation that the ordering
of elements is meaningful, which isn’t the case for PersistentSet
and PersistentDictionary.
2022-10-27 18:08:27 -07:00
Karoy Lorentey 82b7a53960 [PersistentCollections] Categorize member APIs 2022-10-27 18:08:27 -07:00
Karoy Lorentey 3d807118ba [PersistentCollections] Start working on DocC support 2022-10-27 18:08:27 -07:00
Karoy Lorentey 648aaa7f56 [PersistentSet] Review, test, fix, and document binary set operations 2022-10-21 18:24:08 -07:00
Karoy Lorentey ab750075a2 [PersistentCollections] Add missing Custom[Debug]StringConvertable conformances, review existing ones
Add `Custom[Debug]StringConformance` conformances on:

- `PersistentDictionary.Keys`
- `PersistentDictionary.Values`
- `PersistentDictionary.Index`
- `PersistentSet.Index`
2022-10-20 17:14:52 -07:00
Karoy Lorentey 5783b82d72 [PersistentCollections] Fix building with library stability enabled
Building this package with library stability enabled
is entirely unsupported, but let’s add a few @frozen
attributes to fix such builds anyway.

This package is explicitly not ABI stable; the @frozen
attribute does not mean a guarantee to leave
layout unchanged in future revisions.
2022-10-19 19:33:33 -07:00
Saleem Abdulrasool 67fdff5a25 Update CMakeLists.txt
Remove missing file.  Thanks to @stevenbrix for identifying this!

(cherry picked from commit 5e0a0149a4)
2022-10-19 17:58:47 -07:00
Karoy Lorentey 56be3ae3fd [PersistentSet] Adjust code after merge 2022-10-19 17:58:47 -07:00
Karoy Lorentey 25fd503fac [PersistentCollections] Fix up code added since c73a8caa originally landed
(cherry picked from commit 4c842df1b8)
2022-10-19 17:58:47 -07:00
Karoy Lorentey bceadab267 [PersistentCollections] Reduce popcount usages where possible
# Conflicts:
#	Sources/PersistentCollections/Node/_Node+Primitive Removals.swift

(cherry picked from commit e153ebf798)
2022-10-19 17:58:46 -07:00
Karoy Lorentey 6b516b72fb [PersistentCollections] Slightly more readable index descriptions
(cherry picked from commit 785caa4a55)
2022-10-19 17:58:46 -07:00
Karoy Lorentey 2e276ba42b [PersistentCollections] Clean up _Node.Builder & removals
This sanitizes the semantics of _Node.Builder, removing
the (unneccessary) need to pass around hash paths.

It also slightly refactors removal operations, but stops short of
implementing node shrinking.

# Conflicts:
#	Sources/PersistentCollections/Node/_Node+Builder.swift
#	Sources/PersistentCollections/Node/_Node+Initializers.swift
#	Sources/PersistentCollections/Node/_Node+Structural intersection.swift
#	Sources/PersistentCollections/Node/_Node+Structural subtracting.swift
#	Sources/PersistentCollections/Node/_Node+Subtree Modify.swift
#	Sources/PersistentCollections/Node/_Node+Subtree Removals.swift
#	Sources/PersistentCollections/PersistentDictionary/PersistentDictionary+Initializers.swift
#	Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra Initializers.swift
#	Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra intersection.swift
#	Sources/PersistentCollections/PersistentSet/PersistentSet+SetAlgebra subtracting.swift

(cherry picked from commit c73a8caad1)
2022-10-19 17:58:46 -07:00
Karoy Lorentey 8ce8a6bc86 [PersistentSet] Review, test, fix, and document set relation predicates 2022-10-19 15:20:17 -07:00
Karoy Lorentey f843bd40bf [PersistentSet] Add update(_:at:) 2022-10-19 15:20:17 -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 f76630db8e [Internals] Add missing internal checking predicates & docs for all 2022-10-18 22:13:19 -07:00
Karoy Lorentey 5b5651957b [PersistentSet] Doc updates 2022-10-18 21:57:46 -07:00
Karoy Lorentey 5aed92655d [CMake] Update CMake build configuration 2022-10-11 13:11:37 -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 c1b8d2aa9c [PersistentSet] Round out Collection conformance with underscored requirements
The two highlights are _customIndexOfEquatableElement and _customLastIndexOfEquatableElement, speeding up the implementation of `firstIndex(of:)` and `lastIndex(of:)`.
2022-10-09 15:23:12 -07:00
Karoy Lorentey d7dbaee8b9 [PersistentCollections] Minor enhancements 2022-10-09 15:20:40 -07:00
Karoy Lorentey 3238b9b575 [PersistentDictionary] PersistentDictionary, .Iterator, .Index, .Keys, .Keys.Iterator, .Values, .Values.Iterator: Explicitly conform to Sendable when Key and Value are both Sendable 2022-10-05 11:46:43 -07:00
Karoy Lorentey 4b04acfe65 [PersistentSet] PersistentSet, .Iterator, .Index: Explicitly conform to Sendable where Element is Sendable 2022-10-05 11:45:23 -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 963011b1e5 [PersistentSet] insert: Don’t invalidate indices when the inserted member already exists 2022-09-30 12:20:12 -07:00
Karoy Lorentey 6dfad714a1 [PersistentCollections] _Node.update → _Node.updateValue
To prevent confusion with the low-level _Node.update method.

This also switches PersistentSet.insert to use `_Node.insert` instead of `_Node.updateValue`, to fix its semantics. `insert` no longer invalidates indices when the new member already exists in the collection.
2022-09-30 12:19:40 -07:00
Karoy Lorentey 8e3e205954 [PersistentCollections] Add missing import 2022-09-29 17:54:08 -07:00
Karoy Lorentey 19c9f282c9 Delete _FastMembershipCheckable
We don’t actually need this, as `_customContainsEquatableElement`
returning non-nil is a perfectly suitable indication that containment
checking is fast.
2022-09-29 17:37:48 -07:00
Karoy Lorentey 81acdb7f8d [PersistentSet] Implement structural symmetricDifference
I think this may be the last missing non-trivial algorithm for this module.
2022-09-29 17:33:10 -07:00
Karoy Lorentey 54b265ea5d [PersistentSet] Don’t check underestimatedCount in is[Strict][Sub,Super]set implementations
The input sequence may include duplicate items, which may break these shortcuts.
2022-09-28 18:40:17 -07:00
Karoy Lorentey 876177dbb5 [PersistentSet] Test & fix symmetricDifference 2022-09-28 18:38:14 -07:00
Karoy Lorentey d6b1e6c767 [PersistentSet] Add some documentation 2022-09-28 18:37:49 -07:00
Karoy Lorentey 562b21e70f [PersistentCollections] filter, intersection, subtracting: Don’t build a result node until we know for sure we won’t just clone self 2022-09-28 14:45:44 -07:00