T - The type of the compared elements in the 'lines'.public class MyersDiff<T> extends java.lang.Object implements DiffAlgorithm<T>
A clean-room implementation of Eugene Myers differencing algorithm.
See the paper at http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps
| Modifier and Type | Field and Description |
|---|---|
private Equalizer<T> |
equalizer
The equalizer.
|
| Constructor and Description |
|---|
MyersDiff()
Constructs an instance of the Myers differencing algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
PathNode |
buildPath(java.util.List<T> orig,
java.util.List<T> rev)
Computes the minimum diffpath that expresses de differences
between the original and revised sequences, according
to Gene Myers differencing algorithm.
|
Patch<T> |
buildRevision(PathNode path,
java.util.List<T> orig,
java.util.List<T> rev)
Constructs a
Patch from a difference path. |
private java.util.List<T> |
copyOfRange(java.util.List<T> original,
int fromIndex,
int to)
Creates a new list containing the elements returned by
List.subList(int, int). |
Patch<T> |
diff(java.util.List<T> original,
java.util.List<T> revised)
Computes the difference between the original sequence and the revised
sequence and returns it as a
Patch object. |
private boolean |
equals(T orig,
T rev) |
public MyersDiff()
public Patch<T> diff(java.util.List<T> original, java.util.List<T> revised)
Patch object.
Return empty diff if get the error while procession the difference.diff in interface DiffAlgorithm<T>original - The original sequence. Must not be null.revised - The revised sequence. Must not be null.null.public PathNode buildPath(java.util.List<T> orig, java.util.List<T> rev)
orig - The original sequence.rev - The revised sequence.Path across the differences graph.java.lang.IllegalStateException - if a diff path could not be found.public Patch<T> buildRevision(PathNode path, java.util.List<T> orig, java.util.List<T> rev)
Patch from a difference path.path - The path.orig - The original sequence.rev - The revised sequence.Patch script corresponding to the path.private java.util.List<T> copyOfRange(java.util.List<T> original, int fromIndex, int to)
List.subList(int, int).original - The original sequence. Must not be null.fromIndex - low endpoint (inclusive) of the subList.to - high endpoint (exclusive) of the subList.