Swiftpack.co -  zzzzeu/ListDiff as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A lightweight, pure-Swift and faster O(n) difference algorithm based on the Paul Heckel's algorithm.
.package(url: "https://github.com/zzzzeu/ListDiff.git", from: "0.0.1")


A lightweight O(n) difference algorithm based on the Paul Heckel's algorithm. It builds on top of generic BidirectionalCollection, provide friendly support to UIKit based API.

Getting start

You can clone this repository and run the ListDiffExample to see the collection view animation provided by ListDiff.

Basic usage

print(ListDiff.diffing(oldData: "laksjdzcxlkawiey", newData: "xclvkbyoieuwyrck"))

Use with CollectionView / TableView

collectionView.animateItemChanges(oldData: oldData, newData: newData) {
    dataSource = newData


Comparing to Swift's CollectionDifference

Base algorithm Order 500 elements 10,000 elements
ListDiff Heckel O(N) 0.0037s 0.0736s
Swift.CollectionDifference Myers O(ND) 0.0112s 4.7747s

Benchmark could be seen here.

$ swift run -c release ListDiffBenchmark
name                                 time              std        iterations
ListDiff 500 elements                   3719045.000 ns ±  11.13 %        377
ListDiff 10,000 elements               73628145.000 ns ±   1.01 %         17
CollectionDifference 500 elements      11225107.000 ns ±   4.66 %        120
CollectionDifference 10,000 elements 4774718233.000 ns ±   0.67 %          2


Swift Package Manager for Apple platforms

Select Xcode menu File > Swift Packages > Add Package Dependency and enter repository URL with GUI.

Repository: https://github.com/zzzzeu/ListDiff

Swift Package Manager

Add the following to the dependencies of your Package.swift:

.package(url: "https://github.com/zzzzeu/ListDiff.git", from: "0.0.1")


Stars: 0
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Related Packages

Release Notes

2 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API