C# Class ScrewTurn.Wiki.Difference

O(ND) Difference Algorithm for C# Created by Matthias Hertel, see http://www.mathertel.de This work is licensed under a Creative Commons Attribution 2.0 Germany License. see http://creativecommons.org/licenses/by/2.0/de/
显示文件 Open project: mono/ScrewTurnWiki

Public Methods

Method Description
DiffInt ( int ArrayA, int ArrayB ) : System.Item[]

Find the difference in 2 arrays of integers.

DiffText ( string TextA, string TextB ) : System.Item[]

Find the difference in 2 texts, comparing by textlines.

DiffText ( string TextA, string TextB, bool trimSpace, bool ignoreSpace, bool ignoreCase ) : System.Item[]

Find the difference in 2 text documents, comparing by textlines. The algorithm itself is comparing 2 arrays of numbers so when comparing 2 text documents each line is converted into a (hash) number. This hash-value is computed by storing all textlines into a common hashtable so i can find dublicates in there, and generating a new number each time a new textline is inserted.

Private Methods

Method Description
CreateDiffs ( DiffData DataA, DiffData DataB ) : System.Item[]

Scan the tables of which lines are inserted and deleted, producing an edit script in forward order.

DiffCodes ( string aText, Hashtable h, bool trimSpace, bool ignoreSpace, bool ignoreCase ) : int[]

Converts all textlines of the text into unique numbers for every unique textline so further work can work only with simple numbers.

LCS ( DiffData DataA, int LowerA, int UpperA, DiffData DataB, int LowerB, int UpperB ) : void

This is the divide-and-conquer implementation of the longes common-subsequence (LCS) algorithm. The published algorithm passes recursively parts of the A and B sequences. To avoid copying these arrays the lower and upper bounds are passed while the sequences stay constant.

SMS ( DiffData DataA, int LowerA, int UpperA, DiffData DataB, int LowerB, int UpperB ) : SMSRD

This is the algorithm to find the Shortest Middle Snake (SMS).

Method Details

DiffInt() public static method

Find the difference in 2 arrays of integers.
public static DiffInt ( int ArrayA, int ArrayB ) : System.Item[]
ArrayA int A-version of the numbers (usualy the old one)
ArrayB int B-version of the numbers (usualy the new one)
return System.Item[]

DiffText() public method

Find the difference in 2 texts, comparing by textlines.
public DiffText ( string TextA, string TextB ) : System.Item[]
TextA string A-version of the text (usualy the old one)
TextB string B-version of the text (usualy the new one)
return System.Item[]

DiffText() public static method

Find the difference in 2 text documents, comparing by textlines. The algorithm itself is comparing 2 arrays of numbers so when comparing 2 text documents each line is converted into a (hash) number. This hash-value is computed by storing all textlines into a common hashtable so i can find dublicates in there, and generating a new number each time a new textline is inserted.
public static DiffText ( string TextA, string TextB, bool trimSpace, bool ignoreSpace, bool ignoreCase ) : System.Item[]
TextA string A-version of the text (usualy the old one)
TextB string B-version of the text (usualy the new one)
trimSpace bool When set to true, all leading and trailing whitespace characters are stripped out before the comparation is done.
ignoreSpace bool When set to true, all whitespace characters are converted to a single space character before the comparation is done.
ignoreCase bool When set to true, all characters are converted to their lowercase equivivalence before the comparation is done.
return System.Item[]