Package org.eclipse.jgit.diff
Class HashedSequenceComparator<S extends Sequence>
- java.lang.Object
-
- org.eclipse.jgit.diff.SequenceComparator<HashedSequence<S>>
-
- org.eclipse.jgit.diff.HashedSequenceComparator<S>
-
- Type Parameters:
S- the base sequence type.
public final class HashedSequenceComparator<S extends Sequence> extends SequenceComparator<HashedSequence<S>>
Wrap another comparator for use withHashedSequence.This comparator acts as a proxy for the real comparator, evaluating the cached hash code before testing the underlying comparator's equality. Comparators of this type must be used with a
HashedSequence.To construct an instance of this type use
HashedSequencePair.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(HashedSequence<S> a, int ai, HashedSequence<S> b, int bi)Compare two items to determine if they are equivalent.inthash(HashedSequence<S> seq, int ptr)Get a hash value for an item in a sequence.-
Methods inherited from class org.eclipse.jgit.diff.SequenceComparator
reduceCommonStartEnd
-
-
-
-
Method Detail
-
equals
public boolean equals(HashedSequence<S> a, int ai, HashedSequence<S> b, int bi)
Compare two items to determine if they are equivalent. It is permissible to compare sequenceawith itself (by passingaagain in positionb).- Specified by:
equalsin classSequenceComparator<HashedSequence<S extends Sequence>>- Parameters:
a- the first sequence.ai- item ofaito compare.b- the second sequence.bi- item ofbito compare.- Returns:
- true if the two items are identical according to this function's equivalence rule.
-
hash
public int hash(HashedSequence<S> seq, int ptr)
Get a hash value for an item in a sequence. If two items are equal according to this comparator'sSequenceComparator.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 theequals()method.- Specified by:
hashin classSequenceComparator<HashedSequence<S extends Sequence>>- Parameters:
seq- the sequence.ptr- the item to obtain the hash for.- Returns:
- hash the hash value.
-
-