Top Description Constructors Methods
org.eclipse.jgit.diff

public abstract Class SequenceComparator<S extends Sequence>

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.jgit.diff.SubsequenceComparator, org.eclipse.jgit.diff.HashedSequenceComparator, org.eclipse.jgit.diff.RawTextComparator
Type Parameters
<S>
type of sequence the comparator supports.

Equivalence function for a org.eclipse.jgit.diff.Sequence compared by difference algorithm.

Difference algorithms can use a comparator to compare portions of two sequences and discover the minimal edits required to transform from one sequence to the other sequence.

Indexes within a sequence are zero-based.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract boolean

Returns:

true if the two items are identical according to this function's equivalence rule.
equals
(S
the first sequence.
a
,
int
item of ai to compare.
ai
,
S
the second sequence.
b
,
int
item of bi to compare.
bi
)

Compare two items to determine if they are equivalent.

public abstract int

Returns:

hash the hash value.
hash
(S
the sequence.
seq
,
int
the item to obtain the hash for.
ptr
)

Get a hash value for an item in a sequence.

public Edit

Returns:

e if it was updated in-place, otherwise a new edit containing the reduced region.
reduceCommonStartEnd
(S
the first sequence.
a
,
S
the second sequence.
b
,
Edit
the edit to start with and update.
e
)

Modify the edit to remove common leading and trailing items.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SequenceComparatorback to summary
public SequenceComparator()

Method Detail

equalsback to summary
public abstract boolean equals(S a, int ai, S b, int bi)

Compare two items to determine if they are equivalent. It is permissible to compare sequence a with itself (by passing a again in position b).

Parameters
a:S

the first sequence.

ai:int

item of ai to compare.

b:S

the second sequence.

bi:int

item of bi to compare.

Returns:boolean

true if the two items are identical according to this function's equivalence rule.

hashback to summary
public abstract int hash(S seq, int ptr)

Get a hash value for an item in a sequence. If two items are equal according to this comparator's equals(Sequence, int, Sequence, int) method, then this hash method must produce the same integer result for both items. It is not required for two items to have different hash values if they are unequal according to the equals() method.

Parameters
seq:S

the sequence.

ptr:int

the item to obtain the hash for.

Returns:int

hash the hash value.

reduceCommonStartEndback to summary
public Edit reduceCommonStartEnd(S a, S b, Edit e)

Modify the edit to remove common leading and trailing items. The supplied edit e is reduced in size by moving the beginning A and B points so the edit does not cover any items that are in common between the two sequences. The ending A and B points are also shifted to remove common items from the end of the region.

Parameters
a:S

the first sequence.

b:S

the second sequence.

e:Edit

the edit to start with and update.

Returns:Edit

e if it was updated in-place, otherwise a new edit containing the reduced region.