Interface IIntRangeComparator
public interface IIntRangeComparator
{
// Fields
static final int ORDER_AFTER;
static final int ORDER_BEFORE;
static final int ORDER_EQUAL;
// Methods
int compareRanges (IntRanges ranges1, int i1, IntRanges ranges2,
int i2);
void intersectRanges (IntRanges ranges1, int i1,
IntRanges ranges2, int i2, int isectexprnum);
boolean mergeRanges (IntRanges ranges, int i1, int i2);
int orderRanges (IntRanges ranges, int i1, int i2);
void shiftRanges (IntRanges ranges, int start, int count,
int shiftcount);
void splitRange (IntRanges ranges, int i);
void swapRanges (IntRanges ranges, int i1, int i2);
}
This interface supplies a hook for sorting auxiliary data associated with elements of an IntRanges object. The hook is used to help compare equal ranges during a condensing operation, while sorting and merging ranges.
int compareRanges (IntRanges ranges1, int i1, IntRanges ranges2, int i2);
Compares ranges. This method is called by IntRanges.compare.
Return Value:
Returns one of the following values:
- OVERLAP
- The sets of integers are not equal but have a common set of integers.
- DISJOINT
- The sets of integers have no integers in common.
- SUBSET
- The second set of integers includes all of the integers in the first set, plus some integers that are not in the first set.
- EQUAL
- The sets of integers are identical.
- SUPERSET
- The first set of integers includes all of the integers in the second set, plus some integers that are not in the second set.
Parameter | Description |
ranges1
| The first set of ranges to compare.
|
i1
| The index in ranges1 of the first range to compare.
|
ranges2
| The second set of ranges to compare.
|
i2
| The index in ranges2 of the second range to compare.
|
void intersectRanges (IntRanges ranges1, int i1, IntRanges ranges2, int i2,
int isectexprnum);
Called by IntRanges.intersect to intersect any extra data associated with two ranges.
Return Value:
No return value.
Parameter | Description |
ranges1
| The first set of ranges to intersect.
|
i1
| The index into the first set of ranges.
|
ranges2
| The second set of ranges to intersect.
|
i2
| The index into the second set of ranges.
|
isectexprnum
| The intersection expression.
|
boolean mergeRanges (IntRanges ranges, int i1, int i2);
Determines if two overlapping ranges can be merged into a single range. This method is called by IntRanges.condense. If the ranges can be merged, they should be merged into the range and true should be returned.
Return Value:
Returns true if the ranges can be merged; otherwise, returns false.
Parameter | Description |
ranges
| The IntRanges object to merge into.
|
i1
| The index of first range to merge.
|
i2
| The index of second range to merge into the first range.
|
int orderRanges (IntRanges ranges, int i1, int i2);
Compares equal ranges. This method is called by IntRanges.sort.
Return Value:
Returns an integer indicating how to interpret two equal ranges. This can be on of the following values:
- ORDER_BEFORE
- i1 should be placed before i2.
- ORDER_EQUAL
- i1 and i2 are equal.
- ORDER_AFTER
- i1 should be placed after i2.
Parameter | Description |
ranges
| The set of integer ranges to order.
|
i1
| The index of first range.
|
i2
| The index of second range.
|
void shiftRanges (IntRanges ranges, int start, int count, int shiftcount);
Moves the ranges backward.
Return Value:
No return value.
Parameter | Description |
ranges
| The IntRanges object containing the ranges to shift.
|
start
| The starting index of the ranges to move.
|
count
| The number of ranges to move.
|
shiftcount
| The number of ranges to shift backward; if -1, the ranges should be discarded.
|
void splitRange (IntRanges ranges, int i);
Splits a range. This method is called by IntRanges.removeRanges when a range needs to be split to remove elements in the middle of a range. During removal, this will be called, at most, one time.
Return Value:
No return value.
Parameter | Description |
ranges
| The range to be split.
|
i
| The index at which to split.
|
void swapRanges (IntRanges ranges, int i1, int i2);
Swaps ranges. This method is called by IntRanges.sort.
Return Value:
No return value.
Parameter | Description |
ranges
| The IntRanges object in which to swap.
|
i1
| The index of the first range to swap.
|
i2
| The index of the second range to swap.
|
- ORDER_AFTER
- Returned by orderRanges to indicate that the one set of ranges is to be ordered after another set of ranges.
- ORDER_BEFORE
- Returned by orderRanges to indicate that the one set of ranges is to be ordered before another set of ranges.
- ORDER_EQUAL
- Returned by orderRanges to indicate that the one set of ranges is equal to another set of ranges.