DifferenceUtility.Net
1.0.1.9
dotnet add package DifferenceUtility.Net --version 1.0.1.9
NuGet\Install-Package DifferenceUtility.Net -Version 1.0.1.9
<PackageReference Include="DifferenceUtility.Net" Version="1.0.1.9" />
paket add DifferenceUtility.Net --version 1.0.1.9
#r "nuget: DifferenceUtility.Net, 1.0.1.9"
// Install DifferenceUtility.Net as a Cake Addin #addin nuget:?package=DifferenceUtility.Net&version=1.0.1.9 // Install DifferenceUtility.Net as a Cake Tool #tool nuget:?package=DifferenceUtility.Net&version=1.0.1.9
<div align="center">
<img src="assets/logo.png" width="50%" height="50%">
</div>
DifferenceUtility.Net
DifferenceUtility.Net is a library for .NET that handles the calculation and dispatch of the shortest possible path to convert one collection to another, resulting in a quick and smooth transition.
The library uses Eugene W. Myers' diff algorithm to calculate the difference between two collections (see docs). It also has an optional extra layer for calculating moves for items that are persistant between the two collections, but might be in different positions.
Getting Started
Diff Callback
Start by creating the diff callback for your chosen data type by implementing IDiffCallback
. Alternatively, you can extend BaseDiffCallback
depending on the use case. Examples of various implementations can be found within the sample projects.
Calculate Diff
Call DiffUtil.CalculateDiff
to calculate the difference between your two collections. The source collection, destination collection, and diff callback for the same data type must be provided. You can optionally disable move detection via the detectMoves
parameter. This is recommended if your data is sorted by the same constraint (for example: date/time order), or whenever you know there won't be any moves that need to be made.
Depending on the size of your collections, it is recommended to calculate the difference on a background thread, then dispatch them on the main thread. This is especially recommended for UI applictions so not to block the main thread.
Dispatching the Changes
Calling DiffUtil.CalculateDiff
will return a DiffResult
object which contains the necessary instructions to convert the source collection into the destination collection. Call DiffResult.DispatchUpdatesTo
and provide either an ObservableCollection
or an ICollectionUpdateCallback
to receive the changes.
Sample Projects
- MvvmCross core project
- MvvmCross Android project
- Console characters project: A console project that converts one string to another.
- Console people project: A console project that uses simple user/people objects.
- Console reliability project: A console project that generates random strings, along with pre-made ones, to stress test the system.
- Console path deconstruction project: A console project that deconstructs the calculated diff path to visually show the insert, remove, and update steps.
Benchmarking
The project can be benchmarked using simple data within the benchmarking project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1.9 | 453 | 5/9/2022 |
1.0.1.9-alpha | 163 | 5/7/2022 |
1.0.1.5 | 414 | 5/5/2022 |
1.0.1.5-alpha | 174 | 3/21/2022 |
1.0.1.4 | 437 | 3/16/2022 |
1.0.1.4-alpha | 193 | 3/16/2022 |
1.0.1.3-alpha | 158 | 3/13/2022 |
1.0.1 | 427 | 3/12/2022 |
1.0.0.8-alpha | 154 | 3/12/2022 |
1.0.0 | 452 | 1/25/2022 |
1.0.0-alpha-d84cf33 | 182 | 1/25/2022 |
1.0.0-alpha-c273645 | 173 | 1/25/2022 |
1.0.0-alpha-8a1e33e | 187 | 1/25/2022 |
1.0.0-alpha-4515657 | 176 | 1/25/2022 |
1.0.0-alpha-37ad425 | 170 | 1/25/2022 |
0.1.2-alpha-9618ec1 | 204 | 12/21/2021 |
0.1.1-alpha-ff0534b | 209 | 12/17/2021 |
0.1.1-alpha-f52866d | 175 | 12/7/2021 |
0.1.1-alpha-e5ffc2f | 205 | 12/14/2021 |
0.1.1-alpha-cd8a2fa | 206 | 12/18/2021 |
0.1.1-alpha-4eba9e6 | 1,276 | 11/26/2021 |
0.1.1-alpha-223c71e | 167 | 12/15/2021 |
0.1.1-alpha-1a52911 | 189 | 12/11/2021 |
0.1.1-alpha-14ce4df | 205 | 12/18/2021 |
0.1.1-alpha-0afd709 | 210 | 12/15/2021 |
0.1.0-alpha-2d57c7b | 226 | 10/22/2021 |