All Projects → jflinter → Dwifft

jflinter / Dwifft

Licence: mit
Swift Diff

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to Dwifft

Swiftlcs
Swift implementation of the longest common subsequence (LCS) algorithm.
Stars: ✭ 207 (-88.64%)
Mutual labels:  algorithm, diff
Textdistance
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
Stars: ✭ 2,575 (+41.33%)
Mutual labels:  algorithm, diff
Dtl
diff template library written by C++
Stars: ✭ 180 (-90.12%)
Mutual labels:  algorithm, diff
Differencekit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
Stars: ✭ 2,986 (+63.89%)
Mutual labels:  algorithm, diff
Editscript
A library designed to diff and patch Clojure data structures
Stars: ✭ 281 (-84.58%)
Mutual labels:  algorithm, diff
Nanomorph
🚅 - Hyper fast diffing algorithm for real DOM nodes
Stars: ✭ 621 (-65.92%)
Mutual labels:  algorithm, diff
Diffabledatasources
💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
Stars: ✭ 601 (-67.01%)
Mutual labels:  algorithm, diff
Onp
The implementations of "An O(NP) Sequence Comparison Algorithm"
Stars: ✭ 100 (-94.51%)
Mutual labels:  algorithm, diff
Web Development Articles
Monthly Series - Top 10 Web Development Articles
Stars: ✭ 143 (-92.15%)
Mutual labels:  algorithm
Tqsdk Python
天勤量化开发包, 期货量化, 实时行情/历史数据/实盘交易
Stars: ✭ 2,213 (+21.46%)
Mutual labels:  diff
Lago
📕 Data Structures and Algorithms library in TypeScript
Stars: ✭ 1,966 (+7.9%)
Mutual labels:  algorithm
E Books
A collections of FREE ebooks
Stars: ✭ 143 (-92.15%)
Mutual labels:  algorithm
Algorithm Pattern
算法模板,最科学的刷题方式,最快速的刷题路径,你值得拥有~
Stars: ✭ 12,970 (+611.86%)
Mutual labels:  algorithm
Algorithm
「面试算法练级攻略」 - 「LeetCode题解」 - 「剑指offer题解」
Stars: ✭ 142 (-92.21%)
Mutual labels:  algorithm
Competitive Programming
VastoLorde95's solutions to 2000+ competitive programming problems from various online judges
Stars: ✭ 147 (-91.93%)
Mutual labels:  algorithm
Sitediff
SiteDiff makes it easy to see differences between two versions of a website.
Stars: ✭ 139 (-92.37%)
Mutual labels:  diff
Rbush
RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles
Stars: ✭ 1,881 (+3.24%)
Mutual labels:  algorithm
Algorithm
算法和数据结构练习(Leetcode)
Stars: ✭ 148 (-91.88%)
Mutual labels:  algorithm
Data Structure And Algorithms
Every thing related to data structure and algorithms.
Stars: ✭ 146 (-91.99%)
Mutual labels:  algorithm
Leetcode
leetcode刷题
Stars: ✭ 145 (-92.04%)
Mutual labels:  algorithm

Build Status Current Version

Dwifft!

In 10 seconds

Dwifft is a small Swift library that tells you what the "diff" is between two collections, namely, the series of "edit operations" required to turn one into the other. It also comes with UIKit bindings, to automatically, animatedly keep a UITableView/UICollectionView in sync with a piece of data by making the necessary row/section insertion/deletion calls for you as the data changes.

Longer version

Dwifft is a Swift library that does two things. The first thing sounds interesting but perhaps only abstractly useful, and the other thing is a very concretely useful thing based off the first thing.

The first thing (found in Dwifft.swift) is an algorithm that calculates the diff between two collections using the Longest Common Subsequence method. If this kind of thing is interesting to you, there's a pretty great paper on diffing algorithms: http://www.xmailserver.org/diff2.pdf

The second thing (found in Dwifft+UIKit.swift) is a series of diff calculators for UITableViews and UICollectionViews. Let's say you have a UITableView that's backed by a simple array of values (like a list of names, e.g. ["Alice", "Bob", "Carol"]. If that array changes (maybe Bob leaves, and is replaced by Dave, so our list is now ["Alice, "Carol", "Dave"]), we'll want to update the table. The easiest way to do this is by calling reloadData on it. This has a couple of downsides: the transition isn't animated, and it'll cause your user to lose their scroll position if they've scrolled the table. The nicer way is to use the insertRowsAtIndexPaths:withRowAnimation and deleteRowsAtIndexPaths:withRowAnimation methods on UITableView, but this requires you to figure out which index paths have changed in your array (in our example, you'd have to figure out that the row at index 1 should be removed, and a new row should be inserted at index 2 should then be added). If only we had a way to diff the previous value of our array with it's new value. Wait a minute.

When you wire up a TableViewDiffCalculator to your UITableView (or a CollectionViewDiffCalculator to your UICollectionView, it'll automatically calculate diffs and trigger the necessary animations on it whenever you change its sectionedValues property. Neat, right? Notably, as of Dwifft 0.6, Dwifft will also figure out section insertions and deletions, as well as how to efficiently insert and delete rows across different sections, which is just so massively useful if you have a multi-section table. If you're currently using a <0.6 version of Dwifft and want to do this, read the 0.6 release notes.

Even longer version

Learn more about the history of Dwifft, and how it works, in this exciting video of a talk recorded at the Brooklyn Swift meetup in March 2017.

Why you should use Dwifft

  • Dwifft is useful - it can help you build a substantially better user experience if you have table/collection views with dynamic content in your app.
  • Dwifft is safe - there is some non-trivial index math inside of this diff algorithm that is easy to screw up. Dwifft has 100% test coverage on all of its core algorithms. Additionally, all of Dwifft's core functionality is tested with SwiftCheck, meaning it has been shown to behave correctly under an exhausting set of inputs and edge cases.
  • Dwifft is fast - a lot of time has been spent making Dwifft considerably (many orders of magnitude) faster than a naïve implementation. It almost certainly won't be the bottleneck in your UI code.
  • Dwifft is small - Dwifft believes (to the extent that a software library can "believe" in things) in the unix philosophy of small, easily-composed tools. It's unopinionated and flexible enough to fit into most apps, and leaves a lot of control in your hands as a developer. As such, you can probably cram it into your app in less than 5 minutes. Also, because it's small, it can actually achieve nice goals like 100% test and documentation coverage.

How to get started

  • First, you should take a look at the example app, to get a feel for how Dwifft is meant to be used.
  • Next, you should just sit down and read the entire documentation - it will take you <10 minutes, and you'll leave knowing everything there is to know about Dwifft.
  • Then, install Dwifft via cocoapods or carthage or whatever people are using these days.
  • Then get to Dwiffing.

Contributing

Contributions are welcome, with some caveats - please read the contributing guidelines before opening a PR to avoid wasting both our time.

Ok, that's it, there's nothing more here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].