LibreOffice Module xmerge (master) 1
|
This is an implementations of DiffAlgorithm
interface which will difference char arrays.
More...
Public Member Functions | |
Difference[] | computeDiffs (char[] orgSeq, char[] modSeq) |
Return an Difference array. More... | |
Private Member Functions | |
int[][] | createDiffTable (char[] orgSeq, char[] modSeq) |
Create the difference table. More... | |
void | generateResult (int[][] diffTable, int i, int j, ArrayList< Difference > diffVector) |
Generate the Difference result vector. More... | |
This is an implementations of DiffAlgorithm
interface which will difference char arrays.
It also use Longest Common Subsequence (LCS). The algorithm is based on the book "Introduction to Algorithms" by Thomas H.Cormen, Charles E.Leiserson, and Ronald L.Riverst (MIT Press 1990) page 314.
Definition at line 32 of file CharArrayLCSAlgorithm.java.
|
inline |
Return an Difference
array.
This method finds out the difference between two sequences.
orgSeq | The original sequence. |
modSeq | The modified (or changed) sequence to compare against the original. |
Difference
array. Definition at line 45 of file CharArrayLCSAlgorithm.java.
References org.openoffice.xmerge.merger.diff.CharArrayLCSAlgorithm.createDiffTable(), and org.openoffice.xmerge.merger.diff.CharArrayLCSAlgorithm.generateResult().
Referenced by org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge.merge().
|
inlineprivate |
Create the difference table.
The difference table is used internal to keep track what elements are common or different in the two sequences.
orgSeq | The original sequence to be used as a base. |
modSeq | The modified sequence to compare. |
Definition at line 77 of file CharArrayLCSAlgorithm.java.
References i.
Referenced by org.openoffice.xmerge.merger.diff.CharArrayLCSAlgorithm.computeDiffs().
|
inlineprivate |
Generate the Difference
result vector.
This method will be called recursively to backtrack the difference table to get the difference result (and also the LCS).
diffTable | The difference table containing the Difference result. |
i | The nth element in original sequence to compare. This method is called recursively with i and j decreased until 0 . |
j | The nth element in modified sequence to compare. |
diffVector | A vector to output the Difference result. Can not use a return variable as it is a recursive method. The vector will contain Difference objects with operation and positions filled in. |
Definition at line 126 of file CharArrayLCSAlgorithm.java.
References org.openoffice.xmerge.merger.Difference.ADD, org.openoffice.xmerge.merger.Difference.CHANGE, org.openoffice.xmerge.merger.Difference.DELETE, org.openoffice.xmerge.merger.diff.CharArrayLCSAlgorithm.generateResult(), and i.
Referenced by org.openoffice.xmerge.merger.diff.CharArrayLCSAlgorithm.computeDiffs(), and org.openoffice.xmerge.merger.diff.CharArrayLCSAlgorithm.generateResult().