Add tree-diffing algorithm to efficiently compute table view section changes
jflinter opened this issue · comments
Jack Flintermann commented
Ideally, it would be nice to be able to calculate diffs for 2 (or, really, N)-dimensional arrays. This would allow animated section + row changes for UITableView
/UICollectionView
.
I think the work for this looks something like:
- Implement a functional N-ary tree class, and code to convert an array to such a representation.
- Use a tree-diffing algorithm to compute the diff between two such trees. http://www.sciencedirect.com/science/article/pii/S0304397505000174 seems like a good place to start here.
- This previous step will need to have the added wrinkle that the diff must be constrained to a maximum "depth" of 2, since otherwise the individual transformation steps must either map to a UITableView section or row insertion.
- Once the diff is obtained, update
TableViewDiffCalculator
to transform the diff steps into a series of animated updates.
Jack Flintermann commented
Oh man I am so pleased to be closing this!
Jack Flintermann commented
(Because I did it, I mean)