-
-
Notifications
You must be signed in to change notification settings - Fork 145
Heckel algorithm does not want to do replacements. #23
Comments
@onmyway133 isn't the way you're using hashvalue technically incorrect? You're using it as a unique identifier for an object and the two aren't necessarily the same thing. A hash of a struct should be computed based on all its properties, not just one. This makes it hard to handle replacement operations. I like what the android DiffUtil library does in this case where it gives the library user the callback to determine whether two items are the same and if they are, then it compares their contents to figure out if they are the same. This leads to a very straightforward implementation:
Any chance something like this could be implemented? |
@ValCanBuild Hi, I was thinking so too. I 'd like to expose comparison callback instead of implicitly relying on Hashable. |
@archagon Hi, I introduced DiffAware protocol to make diff changes more explicit https://github.com/onmyway133/DeepDiff/releases/tag/2.0.0. Can you check if that works for you ? |
@onmyway133 shouldn't DiffAware be constrained to a |
@ValCanBuild I can't see any reason for that, would you care to enlighten me? |
@snoozemoose well in order to use the So either |
@ValCanBuild I haven't yet submitted a pull request for this but I've changed the UICollectionView extension to be |
PR is submitted now: #31 |
❤️ |
I'm having trouble getting the default algorithm to do replacements instead of deletes followed by inserts. Even this basic code...
...gives me a delete followed by an insert. Whereas using
let changes = diff(old: old, new: new, algorithm: WagnerFischer())
makes everything work correctly.Is this an intentional attribute of the Heckel algorithm?
The text was updated successfully, but these errors were encountered: