Top Description Fields Constructors Methods
com.github.difflib.algorithm.myers

public final Class MyersDiff<T>

extends Object
implements DiffAlgorithmI<T>
Class Inheritance
All Implemented Interfaces
com.github.difflib.algorithm.DiffAlgorithmI
Imports
com.github.difflib.algorithm.Change, .DiffAlgorithmFactory, .DiffAlgorithmI, .DiffAlgorithmListener, com.github.difflib.patch.DeltaType, .Patch, java.util.ArrayList, .List, .Objects, java.util.function.BiPredicate

A clean-room implementation of Eugene Myers greedy differencing algorithm.

Field Summary

Modifier and TypeField and Description
private final BiPredicate<T, T>

Constructor Summary

AccessConstructor and Description
public
public
MyersDiff(final BiPredicate<T, T> equalizer)

Method Summary

Modifier and TypeMethod and Description
private PathNode

Returns:

A minimum Path accross the differences graph.
buildPath
(final List<T>
The original sequence.
orig
,
final List<T>
The revised sequence.
rev
,
DiffAlgorithmListener progress)

Computes the minimum diffpath that expresses de differences between the original and revised sequences, according to Gene Myers differencing algorithm.

private List<Change>

Returns:

A Patch script corresponding to the path.
buildRevision
(PathNode
The path.
actualPath
,
List<T>
The original sequence.
orig
,
List<T>
The revised sequence.
rev
)

Constructs a Patch from a difference path.

public List<Change>
computeDiff(final List<T> source, final List<T> target, DiffAlgorithmListener progress)

Implements com.github.difflib.algorithm.DiffAlgorithmI.computeDiff.

Computes the changeset to patch the source list to the target list.

public static DiffAlgorithmFactory
factory()

Factory to create instances of this specific diff algorithm.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

equalizerback to summary
private final BiPredicate<T, T> equalizer

Constructor Detail

MyersDiffback to summary
public MyersDiff()
MyersDiffback to summary
public MyersDiff(final BiPredicate<T, T> equalizer)

Method Detail

buildPathback to summary
private PathNode buildPath(final List<T> orig, final List<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:List<T>

The original sequence.

rev:List<T>

The revised sequence.

Returns:PathNode

A minimum Path accross the differences graph.

Exceptions
IllegalStateException:
if a diff path could not be found.
buildRevisionback to summary
private List<Change> buildRevision(PathNode actualPath, List<T> orig, List<T> rev)

Constructs a Patch from a difference path.

Parameters
actualPath:PathNode

The path.

orig:List<T>

The original sequence.

rev:List<T>

The revised sequence.

Returns:List<Change>

A Patch script corresponding to the path.

Exceptions
IllegalStateException:
if a Patch could not be built from the given path.
computeDiffback to summary
public List<Change> computeDiff(final List<T> source, final List<T> target, DiffAlgorithmListener progress)

Implements com.github.difflib.algorithm.DiffAlgorithmI.computeDiff.

Doc from com.github.difflib.algorithm.DiffAlgorithmI.computeDiff.

Computes the changeset to patch the source list to the target list. Return empty diff if get the error while procession the difference.

Annotations
@Override
factoryback to summary
public static DiffAlgorithmFactory factory()

Factory to create instances of this specific diff algorithm.