Commit Graph
12 Commits
Author SHA1 Message Date
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 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 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 03c1bd958a [PersistentSet] Implement structural union operation (untested) 2022-09-27 14:18:39 -07:00
Karoy Lorentey 826e22c91e [PersistentDictionary] Implement structural filter & compactMapValues
Plus add tests covering these as well and mapValues.
2022-09-24 17:09:36 -07:00
Karoy Lorentey 9150bbf06e [PersistentCollections] Cache the item hash within collision nodes
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.
2022-09-23 11:15:56 -07:00
Karoy Lorentey eefef1e585 [PersistentCollections] Small path-related adjustments 2022-09-23 11:15:46 -07:00
Karoy Lorentey 958fd47539 [PersistentSet] Start drafting the new type 2022-09-21 10:45:20 -07:00
Karoy Lorentey ea30715a6c [PersistentDictionary] Implement Keys and Values views 2022-09-19 21:25:07 -07:00
Karoy Lorentey a2491aac45 [PersistentDictionary] Improved copy & resize operations
Don’t copy the current node and then insert a new item into it.
Instead, create the copy with the new item already inserted.

Ditto for new collisions.
2022-09-19 21:25:07 -07:00
Karoy Lorentey f7c419d7cf [PersistentDictionary] Rework allocations 2022-09-19 21:25:07 -07:00
Karoy Lorentey 53895c6537 [PersistentCollections] Split up node mutations into multiple files 2022-09-19 21:24:37 -07:00