ddmp.diff

Undocumented in source.

Members

Enums

Operation
enum Operation

- The data structure representing a diff is a List of Diff objects: {Diff(Operation.DELETE, "Hello"), Diff(Operation.INSERT, "Goodbye"), Diff(Operation.EQUAL, " world.")} which means: delete "Hello", add "Goodbye" and keep " world."

Functions

bisect
Diff[] bisect(string text1, string text2, SysTime deadline)
Undocumented in source. Be warned that the author may not have intended to support it.
bisectSplit
Diff[] bisectSplit(string text1, string text2, int x, int y, SysTime deadline)
Undocumented in source. Be warned that the author may not have intended to support it.
charsToLines
void charsToLines(Diff[] diffs, string[] lineArray)
Undocumented in source. Be warned that the author may not have intended to support it.
cleanupEfficiency
void cleanupEfficiency(Diff[] diffs)

Reduce the number of edits by eliminating operationally trivial equalities. @param diffs List of Diff objects.

cleanupMerge
void cleanupMerge(Diff[] diffs)

Reorder and merge like edit sections. Merge equalities. Any edit section can move as long as it doesn't cross an equality. @param diffs List of Diff objects.

cleanupSemantic
void cleanupSemantic(Diff[] diffs)
Undocumented in source. Be warned that the author may not have intended to support it.
cleanupSemanticLossless
void cleanupSemanticLossless(Diff[] diffs)

Look for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary. e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came. @param diffs List of Diff objects.

cleanupSemanticScore
int cleanupSemanticScore(string one, string two)

Given two strings, comAdde a score representing whether the internal boundary falls on logical boundaries. Scores range from 6 (best) to 0 (worst). @param one First string. @param two Second string. @return The score.

commonOverlap
int commonOverlap(string text1, string text2)

Determine if the suffix of one string is the prefix of another. @param text1 First string. @param text2 Second string. @return The number of characters common to the end of the first string and the start of the second string.

commonPrefix
int commonPrefix(string text1, string text2)
Undocumented in source. Be warned that the author may not have intended to support it.
commonSuffix
int commonSuffix(string text1, string text2)
Undocumented in source. Be warned that the author may not have intended to support it.
computeDiffs
Diff[] computeDiffs(string text1, string text2, bool checklines, SysTime deadline)

Find the differences between two texts. Assumes that the texts do not have any common prefix or suffix. @param text1 Old string to be diffed. @param text2 New string to be diffed. @param checklines Speedup flag. If false, then don't run a line-level diff first to identify the changed areas. If true, then run a faster slightly less optimal diff. @param deadline Time when the diff should be complete by. @return List of Diff objects.

diff_lineMode
Diff[] diff_lineMode(string text1, string text2, SysTime deadline)
Undocumented in source. Be warned that the author may not have intended to support it.
diff_main
Diff[] diff_main(string text1, string text2)

Find the differences between two texts. Run a faster, slightly less optimal diff. This method allows the 'checklines' of diff_main() to be optional. Most of the time checklines is wanted, so default to true. @param text1 Old string to be diffed. @param text2 New string to be diffed. @return List of Diff objects.

diff_main
Diff[] diff_main(string text1, string text2, bool checklines)

Find the differences between two texts. @param text1 Old string to be diffed. @param text2 New string to be diffed. @param checklines Speedup flag. If false, then don't run a line-level diff first to identify the changed areas. If true, then run a faster slightly less optimal diff. @return List of Diff objects.

diff_main
Diff[] diff_main(string text1, string text2, bool checklines, SysTime deadline)

Find the differences between two texts. Simplifies the problem by stripping any common prefix or suffix off the texts before diffing. @param text1 Old string to be diffed. @param text2 New string to be diffed. @param checklines Speedup flag. If false, then don't run a line-level diff first to identify the changed areas. If true, then run a faster slightly less optimal diff. @param deadline Time when the diff should be complete by. Used internally for recursive calls. Users should set DiffTimeout instead. @return List of Diff objects.

diff_text1
string diff_text1(Diff[] diffs)

Compute and return the source text (all equalities and deletions). @param diffs List of Diff objects. @return Source text.

diff_text2
string diff_text2(Diff[] diffs)

Compute and return the destination text (all equalities and insertions). @param diffs List of Diff objects. @return Destination text.

fromDelta
Diff[] fromDelta(string text1, string delta)

Given the original text1, and an encoded string which describes the operations required to transform text1 into text2, comAdde the full diff. @param text1 Source string for the diff. @param delta Delta text. @return Array of Diff objects or null if invalid. @throws ArgumentException If invalid input.

halfMatch
bool halfMatch(string text1, string text2, HalfMatch halfmatch)
Undocumented in source. Be warned that the author may not have intended to support it.
halfMatchI
bool halfMatchI(string longtext, string shorttext, int i, HalfMatch hm)
Undocumented in source. Be warned that the author may not have intended to support it.
levenshtein
int levenshtein(Diff[] diffs)

Compute the Levenshtein distance; the number of inserted, deleted or substituted characters. @param diffs List of Diff objects. @return Number of changes.

linesToChars
LinesToCharsResult linesToChars(string text1, string text2)
Undocumented in source. Be warned that the author may not have intended to support it.
linesToCharsMunge
string linesToCharsMunge(string text, string[] lines, int[string] linehash)
Undocumented in source. Be warned that the author may not have intended to support it.
toDelta
string toDelta(Diff[] diffs)

Crush the diff into an encoded string which describes the operations required to transform text1 into text2. E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. Operations are tab-separated. Inserted text is escaped using %xx notation. @param diffs Array of Diff objects. @return Delta text.

xIndex
int xIndex(Diff[] diffs, int loc)

loc is a location in text1, comAdde and return the equivalent location in text2. e.g. "The cat" vs "The big cat", 1->1, 5->8 @param diffs List of Diff objects. @param loc Location within text1. @return Location within text2.

Static functions

unescapeForEncodeUriCompatability
string unescapeForEncodeUriCompatability(string str)

Unescape selected chars for compatability with JavaScript's encodeURI. In speed critical applications this could be dropped since the receiving application will certainly decode these fine. Note that this function is case-sensitive. Thus "%3F" would not be unescaped. But this is ok because it is only called with the output of HttpUtility.UrlEncode which returns lowercase hex.

Structs

Diff
struct Diff

Struct representing one diff operation.

HalfMatch
struct HalfMatch
Undocumented in source.
LinesToCharsResult
struct LinesToCharsResult
Undocumented in source.

Variables

DIFF_EDIT_COST
int DIFF_EDIT_COST;
Undocumented in source.
diffTimeout
Duration diffTimeout;
Undocumented in source.

Meta