ListDiff
0.0.1
Um algoritmo leve de diferença O(n) baseado no algoritmo de Paul Heckel. Ele se baseia no BidirecionalCollection genérico e fornece suporte amigável à API baseada em UIKit.
Você pode clonar este repositório e executar ListDiffExample
para ver a animação da visualização da coleção fornecida por ListDiff.
print ( ListDiff . diffing ( oldData : " laksjdzcxlkawiey " , newData : " xclvkbyoieuwyrck " ) )
collectionView . animateItemChanges ( oldData : oldData , newData : newData ) {
dataSource = newData
}
Comparando com CollectionDifference do Swift
Algoritmo básico | Ordem | 500 elementos | 10.000 elementos | |
---|---|---|---|---|
ListaDiff | Heckel | SOBRE) | 0.0037s | 0.0736s |
Swift.CollectionDifference | Myers | SO(ND) | 0.0112s | 4.7747s |
O benchmark pode ser visto aqui.
$ 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
Selecione o menu Xcode File > Swift Packages > Add Package Dependency
e insira o URL do repositório com GUI.
Repository: https://github.com/zzzzeu/ListDiff
Adicione o seguinte às dependências do seu Package.swift
:
. package ( url : " https://github.com/zzzzeu/ListDiff.git " , from : " 0.0.1 " )