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.
BidirectionalCollection has the connotation that the ordering
of elements is meaningful, which isn’t the case for PersistentSet
and PersistentDictionary.
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.
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)
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.
The two highlights are _customIndexOfEquatableElement and _customLastIndexOfEquatableElement, speeding up the implementation of `firstIndex(of:)` and `lastIndex(of:)`.
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.
We don’t actually need this, as `_customContainsEquatableElement`
returning non-nil is a perfectly suitable indication that containment
checking is fast.
This adds an experimental _FastMembershipCheckable protocol to speed
up these relationship predicates when possible — having separate
overloads for each known collection with a fast containment check
is not going to scale for long.
This commit also introduces a set of isEqual(to:) methods that
generalize ==.
This will simplify merge operations as we no longer have to spend effort on preventing repeated rehashings of items within collision nodes.
Also, review and simplify node allocation and lookup code.