Package org.eclipse.jgit.diff

## Class SubsequenceComparator<S extends Sequence>

- java.lang.Object
- - org.eclipse.jgit.diff.SequenceComparator<Subsequence<S>>
  - - org.eclipse.jgit.diff.SubsequenceComparator<S>

Type Parameters:
  `S` - the base sequence type.

    public final class SubsequenceComparator<S extends Sequence>
    extends SequenceComparator<Subsequence<S>>

Wrap another comparator for use with `Subsequence`.

This comparator acts as a proxy for the real comparator, translating element indexes on the fly by adding the subsequence's begin offset to them. Comparators of this type must be used with a `Subsequence`.

### Constructor Summary

Constructors
`SubsequenceComparator​(SequenceComparator<? super S> cmp)` Construct a comparator wrapping another comparator.

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `equals​(Subsequence<S> a, int ai, Subsequence<S> b, int bi)` Compare two items to determine if they are equivalent.
`int` `hash​(Subsequence<S> seq, int ptr)` Get a hash value for an item in a sequence.

### Methods inherited from class org.eclipse.jgit.diff.SequenceComparator

`reduceCommonStartEnd`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SubsequenceComparator

    public SubsequenceComparator​(SequenceComparator<? super S> cmp)

Construct a comparator wrapping another comparator.

Parameters:
  `cmp` - the real comparator.

### Method Detail

#### equals

    public boolean equals​(Subsequence<S> a,
                          int ai,
                          Subsequence<S> b,
                          int bi)

Description copied from class: `SequenceComparator`
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`).

Specified by:
  `equals` in class `SequenceComparator<Subsequence<S extends Sequence>>`
Parameters:
  `a` - the first sequence.
  `ai` - item of `ai` to compare.
  `b` - the second sequence.
  `bi` - item of `bi` to compare.
Returns:
  true if the two items are identical according to this function's equivalence rule.

#### hash

    public int hash​(Subsequence<S> seq,
                    int ptr)

Description copied from class: `SequenceComparator`
Get a hash value for an item in a sequence. If two items are equal according to this comparator's `SequenceComparator.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 are unequal according to the `equals()` method.

Specified by:
  `hash` in class `SequenceComparator<Subsequence<S extends Sequence>>`
Parameters:
  `seq` - the sequence.
  `ptr` - the item to obtain the hash for.
Returns:
  hash the hash value.