Class MyersDiff<T>
java.lang.Object
com.github.difflib.algorithm.myers.MyersDiff<T>
- All Implemented Interfaces:
DiffAlgorithmI<T>
A clean-room implementation of Eugene Myers greedy differencing algorithm.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate PathNodeComputes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.Constructs aPatchfrom a difference path.computeDiff(List<? extends T> source, List<? extends T> target, DiffAlgorithmListener progress) Computes the changeset to patch the source list to the target list.static DiffAlgorithmFactoryfactory()Factory to create instances of this specific diff algorithm.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DiffAlgorithmI
computeDiff
-
Field Details
-
equalizer
-
-
Constructor Details
-
MyersDiff
public MyersDiff() -
MyersDiff
-
-
Method Details
-
computeDiff
public List<Change> computeDiff(List<? extends T> source, List<? extends T> target, DiffAlgorithmListener progress) Computes the changeset to patch the source list to the target list. Return empty diff if get the error while procession the difference.- Specified by:
computeDiffin interfaceDiffAlgorithmI<T>- Parameters:
source- source datatarget- target dataprogress- progress listener- Returns:
-
buildPath
private PathNode buildPath(List<? extends T> orig, List<? extends T> rev, DiffAlgorithmListener progress) Computes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.- Parameters:
orig- The original sequence.rev- The revised sequence.- Returns:
- A minimum
Pathaccross the differences graph. - Throws:
IllegalStateException- if a diff path could not be found.
-
buildRevision
private List<Change> buildRevision(PathNode actualPath, List<? extends T> orig, List<? extends T> rev) Constructs aPatchfrom a difference path.- Parameters:
actualPath- The path.orig- The original sequence.rev- The revised sequence.- Returns:
- A
Patchscript corresponding to the path. - Throws:
IllegalStateException- if aPatchcould not be built from the given path.
-
factory
Factory to create instances of this specific diff algorithm.
-