public abstract class DiffAlgorithm extends Object
Sequences to create an EditList of changes.
An algorithm's diff method must be callable from concurrent threads
without data collisions. This permits some algorithms to use a singleton
pattern, with concurrent invocations using the same singleton. Other
algorithms may support parameterization, in which case the caller can create
a unique instance per thread.
| Modifier and Type | Class and Description |
|---|---|
static class |
DiffAlgorithm.SupportedAlgorithm
Supported diff algorithm
|
| Constructor and Description |
|---|
DiffAlgorithm() |
| Modifier and Type | Method and Description |
|---|---|
<S extends Sequence> |
diff(SequenceComparator<? super S> cmp,
S a,
S b)
Compare two sequences and identify a list of edits between them.
|
abstract <S extends Sequence> |
diffNonCommon(SequenceComparator<? super S> cmp,
S a,
S b)
Compare two sequences and identify a list of edits between them.
|
static DiffAlgorithm |
getAlgorithm(DiffAlgorithm.SupportedAlgorithm alg) |
public static DiffAlgorithm getAlgorithm(DiffAlgorithm.SupportedAlgorithm alg)
alg - the diff algorithm for which an implementation should be
returnedpublic <S extends Sequence> EditList diff(SequenceComparator<? super S> cmp, S a, S b)
S - type of sequence being compared.cmp - the comparator supplying the element equivalence function.a - the first (also known as old or pre-image) sequence. Edits
returned by this algorithm will reference indexes using the
'A' side: Edit.getBeginA(), Edit.getEndA().b - the second (also known as new or post-image) sequence. Edits
returned by this algorithm will reference indexes using the
'B' side: Edit.getBeginB(), Edit.getEndB().cmp's rules. The
result list is never null.public abstract <S extends Sequence> EditList diffNonCommon(SequenceComparator<? super S> cmp, S a, S b)
diff(SequenceComparator, Sequence, Sequence)
method, which invokes this method using Subsequences.S - type of sequence being compared.cmp - the comparator supplying the element equivalence function.a - the first (also known as old or pre-image) sequence. Edits
returned by this algorithm will reference indexes using the
'A' side: Edit.getBeginA(), Edit.getEndA().b - the second (also known as new or post-image) sequence. Edits
returned by this algorithm will reference indexes using the
'B' side: Edit.getBeginB(), Edit.getEndB().Copyright © 2014. All rights reserved.