All Projects → mcudich → Heckeldiff

mcudich / Heckeldiff

Licence: mit
A fast Swift diffing library.

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Heckeldiff

Awesome Website Change Monitoring
A curated list of awesome tools for website diffing and change monitoring.
Stars: ✭ 224 (+36.59%)
Mutual labels:  diffing
Buffer
Swift μ-framework for efficient array diffs and datasource adapters.
Stars: ✭ 349 (+112.8%)
Mutual labels:  diffing
Allkit
🛠 Async List Layout Kit
Stars: ✭ 40 (-75.61%)
Mutual labels:  diffing
AngleSharp.Diffing
A library that makes it possible to compare two AngleSharp node lists and get a list of differences between them.
Stars: ✭ 27 (-83.54%)
Mutual labels:  diffing
Multidiff
Binary data diffing for multiple objects or streams of data
Stars: ✭ 282 (+71.95%)
Mutual labels:  diffing
Bento
Swift library for building component-based interfaces on top of UITableView and UICollectionView 🍱
Stars: ✭ 371 (+126.22%)
Mutual labels:  diffing
Collor
A declarative-ui framework for UICollectionView with great and useful features.
Stars: ✭ 182 (+10.98%)
Mutual labels:  diffing
Diffimg
Differentiate images in python - get a ratio or percentage difference, and generate a diff image
Stars: ✭ 146 (-10.98%)
Mutual labels:  diffing
Pgdiff
Compares the PostgreSQL schema between two databases and generates SQL statements that can be run manually against the second database to make their schemas match.
Stars: ✭ 333 (+103.05%)
Mutual labels:  diffing
Sketchdiff
💎 Generate visual differences between two Sketch files or a previous git commit
Stars: ✭ 14 (-91.46%)
Mutual labels:  diffing
CollectionViewDiffableGameDB
Game DB iOS App using iOS 13 NSDiffableDataSourceSnapshot to filter, sort, and search with animations
Stars: ✭ 17 (-89.63%)
Mutual labels:  diffing
Differencekit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
Stars: ✭ 2,986 (+1720.73%)
Mutual labels:  diffing
Diffabledatasources
💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
Stars: ✭ 601 (+266.46%)
Mutual labels:  diffing
go-delta
go-delta - A Go package and utility to generate and apply binary delta updates.
Stars: ✭ 25 (-84.76%)
Mutual labels:  diffing
Carbon
🚴 A declarative library for building component-based user interfaces in UITableView and UICollectionView.
Stars: ✭ 1,034 (+530.49%)
Mutual labels:  diffing
Asm Dom
A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications)
Stars: ✭ 2,604 (+1487.8%)
Mutual labels:  diffing
Jsondiffpatch
Diff & patch JavaScript objects
Stars: ✭ 3,951 (+2309.15%)
Mutual labels:  diffing
Iglistkit
A data-driven UICollectionView framework for building fast and flexible lists.
Stars: ✭ 12,196 (+7336.59%)
Mutual labels:  diffing
Datasource
Simplifies the setup of UITableView data sources using type-safe descriptors for cells and sections. Animated diffing built-in.
Stars: ✭ 72 (-56.1%)
Mutual labels:  diffing
Sirix
SirixDB is a temporal, evolutionary database system, which uses an accumulate only approach. It keeps the full history of each resource. Every commit stores a space-efficient snapshot through structural sharing. It is log-structured and never overwrites data. SirixDB uses a novel page-level versioning approach called sliding snapshot.
Stars: ✭ 638 (+289.02%)
Mutual labels:  diffing

HeckelDiff

Swift Carthage compatible CocoaPods Compatible Platform License

Pure Swift implementation of Paul Heckel's A Technique for Isolating Differences Between Files

Features

This is a simple diff algorithm that provides the minimum set of steps to transform one collection into another. Transformations are listed as discrete operations:

  • Insertion - what items should be inserted into the array, and at what index.
  • Deletion - what items should be removed from the array, and at what index.
  • Move - what items should be moved, and their origin and destination indices.
  • Update - what items should be updated/replaced with new context, and at what index.

These operations are calculated in linear time, using the algorithm described in this paper.

Knowing this set of operations is especially handy for efficiently updating UITableViews and UICollectionViews.

Example

Consider a simple example that compares lists of integers:

let o = [1, 2, 3, 3, 4]
let n = [2, 3, 1, 3, 4]
let result = diff(o, n)
// [.move(1, 0), .move(2, 1), .move(0, 2)]

let o = [0, 1, 2, 3, 4, 5, 6, 7, 8]
let n = [0, 2, 3, 4, 7, 6, 9, 5, 10]
let result = diff(o, n)
// [.delete(1), .delete(8), .move(7, 4), .insert(6), .move(5, 7), .insert(8)]

orderedDiff is also available, which provides a set of operations that are friendly for batched updates in UIKit contexts (note how move is replaced by pairs of insert and delete operations):

let o = [1, 2, 3, 3, 4]
let n = [2, 3, 1, 3, 4]
let result = orderedDiff(o, n)
// [.delete(2), .delete(1), .delete(0), .insert(0), .insert(1), .insert(2)]

UITableView/UICollectionView Support

HeckelDiff has built-in support for generating efficient batched updates for UITableView and UICollectionView. Methods are made available on both that allow informing the corresponding table or collection view that their data model has changed.

For example:

tableView.applyDiff(previousItems, newItems, withAnimation: .fade)

or

collectionView.applyDiff(previousItems, newItems)

Update Support

Elements in collections passed into diff must conform to Hashable. HeckelDiff uses elements' hashValues to determine whether they should be inserted, deleted or moved. In some cases, elements are instead marked for update. This is because even though the hashValues of two elements might be equivalent, the elements may not be equal. You can take advantage of this by implementing the Hashable protocol in such a way that your elements get updated when appropriate.

For example, you may have two records that refer to the same person (perhaps you use a record ID as a hash value). You may want to support a case where a person's phone number may change, but the record itself remains in the same position in the array. Your Equatable implementation may take the phone number value into account, whereas your hashValue may only reflect the underlying record ID value.

In the context of a UITableView or UICollectionView, you would most efficiently handle this by reloading the given row that needs updating (rather than deleting it and re-inserting it). Use the supplied applyDiff functions to have HeckelDiff perform this for you.

Installation

Carthage

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

Add the following line to your Cartfile:

github "mcudich/HeckelDiff"

Run carthage update, then make sure to add HeckelDiff.framework to "Linked Frameworks and Libraries" and "copy-frameworks" Build Phases.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate TemplateKit into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'HeckelDiff', '~> 0.1.0'
end

Then, run the following command:

$ pod install

Requirements

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 3.0+
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].