Differific - a fast and convenient diffing framework.

Overview

Differific

CI Status Version Carthage Compatible codecov License Platform Swift

Description

Differific Icon

Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm. Creating a changeset is seamless for all your diffing needs. The library also includes some convenience extensions to make life easier when updating data sources.

The library is based and highly influenced by Matias Cudich's (@mcudich) HeckelDiff library that aims to solve the same issue. Versions prior to 0.3.0 was based on DeepDiff. For more information about how the algorithm works and the performance of the algorithm, head over to DeepDiff. For the time being, both frameworks are very similar; this is subject to change when the frameworks evolve.

Features

  • 🍩 Built-in extensions for updating table & collection views.
  • 🎩 Customizable diffing.
  • 🏎 High performance.
  • 📱 iOS support.
  • 💻 macOS support.
  • 📺 tvOS support.

Usage

Diffing two collections

let old = ["Foo", "Bar"]
let new = ["Foo", "Bar", "Baz"]
let manager = DiffManager()
let changes = manager.diff(old, new)

Updating a table or collection view

// uiElement is either your table view or collection view.
let old = dataSource.models
let new = newCollection
let changes = DiffManager().diff(old, new)
uiElement.reload(with: changes, before: { dataSource.models = new })

Installation

Differific is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Differific'

Differific is also available through Carthage. To install just write into your Cartfile:

github "zenangst/Differific"

Differific can also be installed manually. Just download and drop Sources folders in your project.

Author

Contributing

We would love you to contribute to Differific, check the CONTRIBUTING file for more info.

License

Differific is available under the MIT license. See the LICENSE file for more info.

Comments
  • Demo

    Demo

    In response

    https://github.com/zenangst/Differific/issues/6#issuecomment-446855458

    I thought I would go all out on this one.

    TOOK AGES guys 😓

    It's really hot shit 😎

    opened by ghost 3
  • Make Algorithm static and optimize diff method

    Make Algorithm static and optimize diff method

    The diff method has been made static and the implementation has been optimized. Now the for-loop retain their own index, it also iterates over ArraySlices.

    opened by zenangst 2
  • Add safe-guard for reloading without a superview

    Add safe-guard for reloading without a superview

    Fixes crash where the view has yet to get a superview. Instead of running the performBatchUpdates, the implementation will now invoke reloadData followed by completion?() and return early.

    opened by zenangst 1
  • Improve diff performance

    Improve diff performance

    This PR improves diff performance by using reserving capacity of the arrays before diffing. It also simplifies the implementation by removing enum and uses concrete value types instead, this should not affect performance but in my own personal opinion, it is easier to reason about as opposed to looking "fancy".

    The use of defer has also been removed to make the code more linear.

    opened by zenangst 1
  • Fix crash with only one new match

    Fix crash with only one new match

    Fix crash when trying to diff two collection where the new one only contains one item. When this happens the algorithm went out of bounds as it moves the offset around.

    opened by zenangst 1
  • Fix crash when new array only contains one item

    Fix crash when new array only contains one item

    Fix crash when trying to diff two collection where the new one only contains one item. When this happens the algorithm went out of bounds as it moves the offset around.

    opened by zenangst 1
  • Improve user interface extensions

    Improve user interface extensions

    The user interface extensions have been refactored to run the update closure inside of performBatchUpdates. The closure has also been renamed from before to updateDataSource.

    opened by zenangst 1
  • Refactor implementation to handle updates properly

    Refactor implementation to handle updates properly

    The implementation of the algorithm has been refactored and partially rewritten to handle updates properly.

    Thanks to @mcudich for his library HeckelDiff (https://github.com/mcudich/HeckelDiff).

    opened by zenangst 1
  • Improve public API on extensions.

    Improve public API on extensions.

    There is really no need to pass the UI element into the before closure as it is available at the call-site. So instead of always writing _ in, the element is no longer passed into the closure.

    • Remove UI element from before closure.
    • Call setNeedsLayout() and layoutIfNeeded() in extension methods.
    opened by zenangst 0
Releases(0.8.4)
Owner
Christoffer Winterkvist
random hero at @finkoslo by day, cocoa vigilante by night, dad at dawn. my life is awesome. Previously @hyperoslo
Christoffer Winterkvist
🦀Amazingly incredible extraordinary lightning fast diffing in Swift

DeepDiff ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut man

Khoa 2k Dec 29, 2022
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.

A fast and flexible O(n) difference algorithm framework for Swift collection. The algorithm is optimized based on the Paul Heckel's algorithm. Made wi

Ryo Aoyama 3.3k Jan 4, 2023
Fast sorted collections for Swift using in-memory B-trees

Fast Sorted Collections for Swift Using In-Memory B-Trees Overview Reference Documentation Optimizing Collections: The Book What Are B-Trees? Why In-M

null 1.3k Dec 20, 2022
Swift μ-framework for efficient array diffs and datasource adapters.

Buffer Swift μ-framework for efficient array diffs, collection observation and data source implementation. C++11 port here Installation cd {PROJECT_RO

Alex Usbergo 348 Aug 2, 2022
TemplateKit - React inspired framework for building component-based user interfaces in Swift

TemplateKit React-inspired framework for building component-based user interface

null 0 Feb 6, 2022
Examples of commonly used data structures and algorithms in Swift.

Swift Structures This project provides a framework for commonly used data structures and algorithms written in a new iOS development language called S

Wayne Bishop 2.1k Dec 28, 2022
:droplet: A generic view model for both basic and complex scenarios

Brick Description Brick is a generic view model for both basic and complex scenarios. Mapping a basic table view cells is as easy as pie, if you have

HyperRedink 59 Jul 31, 2021
Algorithms and data structures in Swift, with explanations!

Welcome to the Swift Algorithm Club! Here you'll find implementations of popular algorithms and data structures in everyone's favorite new language Sw

raywenderlich 27.3k Jan 8, 2023
Swift library to generate differences and patches between collections.

Differ Differ generates the differences between Collection instances (this includes Strings!). It uses a fast algorithm (O((N+M)*D)) to do this. Featu

Tony Arnold 628 Dec 29, 2022
A Swift probability and statistics library

Probably Probably is a set of Swift structures for computing the probability and cumulative distributions of different probablistic functions. Right n

Harlan Haskins 270 Dec 2, 2022
KeyPathKit is a library that provides the standard functions to manipulate data along with a call-syntax that relies on typed keypaths to make the call sites as short and clean as possible.

KeyPathKit Context Swift 4 has introduced a new type called KeyPath, with allows to access the properties of an object with a very nice syntax. For in

Vincent Pradeilles 406 Dec 25, 2022
Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.

SPDiffable Apple's diffable API requerid models for each object type. If you want use it in many place, you pass many time to implemenet and get over

Ivan Vorobei 114 Jan 3, 2023
Swivl - A set of BLAS-accelerated linerar algebra structures and functions

Swivl - Swift Vector Library A set of BLAS-accelerated linerar algebra structure

null 0 Jan 19, 2022
Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm

Differific is a diffing tool that helps you compare Hashable objects using the Paul Heckel's diffing algorithm. Creating a chan

Christoffer Winterkvist 127 Jun 3, 2022
🦀Amazingly incredible extraordinary lightning fast diffing in Swift

DeepDiff ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut man

Khoa 2k Dec 29, 2022
A fast Swift diffing library.

HeckelDiff Pure Swift implementation of Paul Heckel's A Technique for Isolating Differences Between Files Features This is a simple diff algorithm tha

Matias Cudich 166 Oct 6, 2022
🦀Amazingly incredible extraordinary lightning fast diffing in Swift

DeepDiff ❤️ Support my apps ❤️ Push Hero - pure Swift native macOS application to test push notifications PastePal - Pasteboard, note and shortcut man

Khoa 2k Dec 29, 2022
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.

MJExtension A fast, convenient and nonintrusive conversion framework between JSON and model. 转换速度快、使用简单方便的字典转模型框架 ?? ✍??Release Notes: more details Co

M了个J 8.5k Jan 3, 2023
A super fast & convenient object mapper tailored for your needs

A super fast & convenient object mapper tailored for your needs. Mapping objects to arrays or dictionaries can be a really cumbersome task, but those

Christoffer Winterkvist 246 Sep 9, 2022
A collection of tools for debugging, diffing, and testing your application's data structures.

Custom Dump A collection of tools for debugging, diffing, and testing your application's data structures. Motivation customDump diff XCTAssertNoDiffer

Point-Free 631 Jan 3, 2023