1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 11:02:26 +03:00

Document dictionary diffing as an approach stemming from set reconciliation.

This commit is contained in:
Rob Rix 2015-10-07 13:25:02 -04:00
parent 21ac5822a0
commit 06c456f1cd

View File

@ -95,6 +95,7 @@ public enum Algorithm<A, B> {
? Diff($1)
: recur($0, $1)
}
// Essentially [set reconciliation](https://en.wikipedia.org/wiki/Data_synchronization#Unordered_data) on the keys, followed by recurring into the values of the intersecting keys.
let deleted = Set(a.keys).subtract(b.keys).map { ($0, Diff.Pure(Patch.Delete(a[$0]!))) }
let inserted = Set(b.keys).subtract(a.keys).map { ($0, Diff.Pure(Patch.Insert(b[$0]!))) }
let patched = Set(a.keys).intersect(b.keys).map { ($0, recur(a[$0]!, b[$0]!)) }