spkl.Diffs 2.1.0

dotnet add package spkl.Diffs --version 2.1.0                
NuGet\Install-Package spkl.Diffs -Version 2.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="spkl.Diffs" Version="2.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add spkl.Diffs --version 2.1.0                
#r "nuget: spkl.Diffs, 2.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install spkl.Diffs as a Cake Addin
#addin nuget:?package=spkl.Diffs&version=2.1.0

// Install spkl.Diffs as a Cake Tool
#tool nuget:?package=spkl.Diffs&version=2.1.0                

Diffs

Provides a .NET implementation to the diff algorithm (shortest edit script) described by Eugene Myers in "An O(ND) Difference Algorithm and Its Variations". Unlike some other implementations, this one can compare sequences of any object type, using the standard Equals method or a custom IEqualityComparer.

Example Usage

In this example, we will diff two string sequences:

   0 1 2 3 4 5 6 (These are the indexes)
A: a b c a b b a
B: c b a b a c

To do this, we use the following code:

// using spkl.Diffs;
string[] a = new[] { "a", "b", "c", "a", "b", "b", "a" };
string[] b = new[] { "c", "b", "a", "b", "a", "c" };
MyersDiff<string> diff = new MyersDiff<string>(a, b);

Using generic typing, you can diff all sorts of types. You can also customize which values are considered equal by specifying a third constructor parameter (IEqualityComparer<T>).

There are two methods to access the results: GetEditScript() and GetResult().

GetEditScript()

GetEditScript() returns a sequence of edit instructions. You can understand these as instructions to follow to transform sequence A to sequence B. Every instruction contains four integers, a starting line number in A and B and the number of lines to add or remove. In this case, the return value would look like this:

LineA LineB CountA CountB
0 0 1 1
2 2 1 0
5 4 1 0
7 5 0 1

To better understand this, let's follow these instructions:

  1. In A, starting at line 0 (LineA), remove 1 line (CountA). From B, starting at line 0 (LineB), add 1 line (CountB) at position 0 (LineA). (This removes the first "a" and adds the first "c")

  2. In A, starting at line 2, remove 1 line. (This removes the "c")

  3. In A, starting at line 5, remove 1 line. (This removes the last "b")

  4. From B, starting at line 5 (LineB), add 1 line (CountB) at position 7 (LineA). (This adds the last "c")

Following these instructions, abcabba is transformed to cbabac.

GetResult()

GetResult() returns the resulting diff as a sequence of tuples that represent lines. In this case, the return value would look like this:

ResultType AItem BItem
A a
B c
Both b b
A c
Both a a
Both b b
A b
Both a a
B c

This is similar to how the result would be displayed in a visual comparison application. The AItem and BItem columns contain sequence A and B, respectively. The ResultType column shows whether a line contains a value from sequence A, B, or from both. You can see which values were matched with each other.

GetResult(ResultOrder)

You can specify the order in which you want unmatched lines to appear by using the GetResult(ResultOrder) overload. To visualize this, we need to use a new example.

A: a b c
B: x y

The following table shows how the result would be returned when specifying the different ResultOrder values AABB, BBAA, ABAB and BABA:

AABB BBAA ABAB BABA
a - - x a - - x
b - - y - x a -
c - a - b - - y
- x b - - y b -
- y c - c - c -
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 is compatible.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on spkl.Diffs:

Package Downloads
VertiGIS.Mobile

Create VertiGIS Mobile apps for Android, iOS, and UWP. Extend your apps with custom components, operations and services.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 865 5/5/2024
2.0.3-alpha.0.9 66 5/5/2024
2.0.2 515 1/20/2024
2.0.1 109 1/20/2024
2.0.0 107 1/20/2024
1.2.1 55,276 4/5/2021
1.2.0 342 3/21/2021
1.1.0 343 2/3/2021
1.0.1 330 1/31/2021
1.0.0 324 1/27/2021

- Provided snupkg for debug symbols.