• Stars
    star
    238
  • Rank 163,764 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 7 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Swift port of IGListKit's IGListDiff

Build Status CocoaPods Compatible

ListDiff

ListDiff is a Swift port of IGListKit's IGListDiff. It is an implementation of an algorithm by Paul Heckel that calculates the diff between 2 arrays.

Motivation

The motivation for this project came from the following challenge which I learnt about it from Ryan Nystrom's talk at iOSConf.SG.

Getting Started

swift package generate-xcodeproj

Installation

CocoaPods

pod 'ListDiff'

Carthage

github "lxcid/ListDiff" "master"

Usage

import ListDiff

extension Int : Diffable {
    public var diffIdentifier: AnyHashable {
        return self
    }
}
let o = [0, 1, 2]
let n = [2, 1, 3]
let result = List.diffing(oldArray: o, newArray: n)
// result.hasChanges == true
// result.deletes == IndexSet(integer: 0)
// result.inserts == IndexSet(integer: 2)
// result.moves == [List.MoveIndex(from: 2, to: 0), List.MoveIndex(from: 1, to: 1)]
// result.changeCount == 4

Rationale

During the port, I made several decisions which I would like to rationalize here.

  • Using caseless enum as namespace. See Erica Sadun's post here.
  • No support for index paths. Decided that this is out of the scope.
  • Stack vs Heap. AFAIK, Swift does not advocates thinking about stack vs heap allocation model, leaving the optimization decisions to compiler instead. Nevertheless, some of the guideline do favour struct more, so only List.Entry is a (final) class as we need reference to its instances.

Alternatives

More Repositories

1

LXReorderableCollectionViewFlowLayout

Extends `UICollectionViewFlowLayout` to support reordering of cells. Similar to long press and pan on books in iBook.
Objective-C
1,835
star
2

LXPagingViews

A small, efficient and flexible implementation for common paging scroll view patterns.
Objective-C
65
star
3

LXReceiptStore

Built on top of CargoBay, LXReceiptStore provides a simpler interface aims at helping you make sense out of your In-App Purchase receipts.
Objective-C
23
star
4

AdvancedUserInterfacesUsingCollectionView

WWDC 2014 Session 232
Objective-C
7
star
5

LXSupport

A project aspired to be the ActiveSupport of Cocoa.
Objective-C
7
star
6

ToolingInSwift

A talk that I gave at iOS Conf SG on 24th Oct 2015.
Shell
6
star
7

SVShareViewController

A simple compose UI for posting textual content to Facebook and Twitter.
Objective-C
6
star
8

sgbusroutes

Objective-C
5
star
9

LXXcodeTools

The bridge between Xcode CLI Tools and Swift.
Swift
3
star
10

LXStateMachine

A simple event-driven mealy state machine.
Swift
2
star
11

UIKitGuard

Guard against accessing UIKit on threads other than main.
Objective-C
2
star
12

inspect-3rd-party-app

2
star
13

zookeeper-consul-docker

ZooKeeper coordinated using Consul
Python
2
star
14

UI-Automation-on-CI

Attempts to run UI Automation on Travis CI.
Objective-C
2
star
15

LXNetwork

Swift
2
star
16

ReactNativeBug-NestedViewInTextInput

JavaScript
1
star
17

LXDeltaCalculation

To calculate the differences between 2 collections. A clone of BKDeltaCalculator.
Objective-C
1
star
18

xcode_manager

A framework for writing automated tasks for managing Xcode projects.
Ruby
1
star
19

LXSupportKit

A collection of codes to support my iOS development.
Objective-C
1
star
20

modern-react-with-redux

JavaScript
1
star
21

nextid

Smallest(Possible IDs - Used IDs)
Java
1
star
22

TicTacToe

A simple Tic Tac Toe iPhone app I developed while learning iOS Development. Using Xcode 3.x.x.
Objective-C
1
star
23

ReactNative-AndroidKeyPress

example project to show a KeyPress bug in Android for React Native 0.53.3
Objective-C
1
star
24

docker-swift

1
star
25

ComposeKit

Swift Port of Composable Data Sources
Swift
1
star
26

kafka-docker

Yet another Kafka's Docker repository
Shell
1
star
27

ios-mac-osx-tips-and-tricks

I want to write a book some day, here is where I start. A collection of tips and tricks I have learnt about iOS and Mac OS X development.
1
star
28

react-native-awesome-project

react-native init AwesomeProject --version ${REACT_NATIVE_VERSION}
Objective-C
1
star