Closed benqo closed 6 years ago
@benqo Hi, to make it work like you describe, then we need a function to merge delete
and insert
changes at the same index to form a update
change.
However, how can we tell if an object has been changed or not? The way DeepDiff works now is to base on the hashValue
to tell if we are talking about the same object, usually we have object ID for uniqueness, and use Equatable
conformance to tell if any of its properties have changed, you can take a look at https://github.com/onmyway133/DeepDiff/blob/master/DeepDiffTests/HeckelTests.swift#L55
@onmyway133 thanks! Tried it again with my Hashable struct and works as expected. It detects if an object is replaced with a new (different) one or the same one is just updated.
@benqo Glad that it works for you 🥂
Hi,
I have a problem with the Hecker algorithm, I think it doesn't detect replaces correctly. A simple example:
diff(old: Array("abc"), new: Array("adc"))
This will return delete at 1 and insert at 1.Using WagnerFischer, it works as expected:
diff(old: Array("abc"), new: Array("adc"), algorithm: WagnerFischer())
This returns replace at 1.Is this algorithm specific or just a bug?
Thanks!