Daily iOS
CS fundamentals and algorithms

Diff algorithms

When you apply a new snapshot to UICollectionViewDiffableDataSource, how does it compute the inserts, deletes, and moves? And why do item identifiers have to be Hashable?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

It matches the identifier sets by hash to extract deletes, inserts, and moves in close to O(n) (a Heckel style approach). The identifier is the item's identity, so it has to be Hashable.

Share a question