Interface IRangeComparator
-
- All Known Subinterfaces:
ITokenComparator
- All Known Implementing Classes:
TokenComparator
public interface IRangeComparatorFor breaking an object to compare into a sequence of comparable entities.It is used by
RangeDifferencerto find longest sequences of matching and non-matching ranges.For example, to compare two text documents and find longest common sequences of matching and non-matching lines, the implementation must break the document into lines.
getRangeCountwould return the number of lines in the document, andrangesEqualwould compare a specified line given with one in anotherIRangeComparator.Clients should implement this interface; there is no standard implementation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetRangeCount()Returns the number of comparable entities.booleanrangesEqual(int thisIndex, IRangeComparator other, int otherIndex)Returns whether the comparable entity given by the first index matches an entity specified by the otherIRangeComparatorand index.booleanskipRangeComparison(int length, int maxLength, IRangeComparator other)Returns whether a comparison should be skipped because it would be too costly (or lengthy).
-
-
-
Method Detail
-
getRangeCount
int getRangeCount()
Returns the number of comparable entities.- Returns:
- the number of comparable entities
-
rangesEqual
boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex)Returns whether the comparable entity given by the first index matches an entity specified by the otherIRangeComparatorand index.- Parameters:
thisIndex- the index of the comparable entity within thisIRangeComparatorother- the IRangeComparator to compare this withotherIndex- the index of the comparable entity within the otherIRangeComparator- Returns:
trueif the comparable entities are equal
-
skipRangeComparison
boolean skipRangeComparison(int length, int maxLength, IRangeComparator other)Returns whether a comparison should be skipped because it would be too costly (or lengthy).- Parameters:
length- a number on which to base the decision whether to returntrueorfalsemaxLength- another number on which to base the decision whether to returntrueorfalseother- the otherIRangeComparatorto compare with- Returns:
trueto avoid a too lengthy range comparison
-
-