Package jdiff
Class DiffMyers
- java.lang.Object
-
- jdiff.DiffMyers
-
public class DiffMyers extends java.lang.ObjectA class to compare vectors of objects. The result of comparison is a list ofchangeobjects which form an edit script. The objects compared are traditionally lines of text from two files. Comparison options such as "ignore whitespace" are implemented by modifying theequalsandhashcodemethods for the objects compared.The basic algorithm is described in: "An O(ND) Difference Algorithm and its Variations", Eugene Myers, Algorithmica Vol. 1 No. 2, 1986, p 251.
This class outputs different results from GNU diff 1.15 on some inputs. Our results are actually better (smaller change list, smaller total size of changes), but it would be nice to know why. Perhaps there is a memory overwrite bug in GNU diff 1.15.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDiffMyers.changeThe result of comparison is an "edit script": a chain of change objects.
-
Field Summary
Fields Modifier and Type Field Description booleanheuristicWhen set to true, the comparison uses a heuristic to speed it up.booleanno_discardsWhen set to true, the algorithm returns a guarranteed minimal set of changes.
-
Constructor Summary
Constructors Constructor Description DiffMyers(java.lang.Object[] a, java.lang.Object[] b)Prepare to find differences between two arrays.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DiffMyers.changediff_2(boolean reverse)
-
-
-
Field Detail
-
heuristic
public boolean heuristic
When set to true, the comparison uses a heuristic to speed it up. With this heuristic, for files with a constant small density of changes, the algorithm is linear in the file size.
-
no_discards
public boolean no_discards
When set to true, the algorithm returns a guarranteed minimal set of changes. This makes things slower, sometimes much slower.
-
-
Constructor Detail
-
DiffMyers
public DiffMyers(java.lang.Object[] a, java.lang.Object[] b)Prepare to find differences between two arrays. Each element of the arrays is translated to an "equivalence number" based on the result ofequals. The original Object arrays are no longer needed for computing the differences. They will be needed again later to print the results of the comparison as an edit script, if desired.
-
-
Method Detail
-
diff_2
public DiffMyers.change diff_2(boolean reverse)
-
-