|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.faunos.util.dim.line.Ranges
public class Ranges
Utility for sorting and searching through Range
s.
Range
Method Summary | |
---|---|
static int |
containingIndexOf(long value,
List<? extends Range> ranges)
Returns the index of the given sorted ranges at which the
range contains
the specified value , if such a range exists; o.w. |
static int |
containingIndexOf(long value,
Range[] ranges)
Returns the index of the given sorted ranges at which the
range contains
the specified value , if such a range exists; o.w. |
static boolean |
contains(long value,
Range range)
Determines whether the given value falls in the
specified range . |
static Range |
createRange(long lo,
long hi)
Creates and returns a new Range instance. |
static boolean |
hasOverlaps(List<? extends Range> ranges)
Determines whether the given ranges overlap. |
static boolean |
hasOverlaps(Range[] ranges)
Determines whether the given ranges overlap. |
static OutCode |
outCode(long value,
Range range)
Returns the outcode of the given value
relative to the specified range . |
static void |
sort(List<? extends Range> ranges)
Sorts the given ranges in ascending order of their lo
property. |
static void |
sort(Range[] ranges)
Sorts the given ranges in ascending order of their lo
property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void sort(List<? extends Range> ranges)
lo
property.
RangeComparator
public static void sort(Range[] ranges)
lo
property.
RangeComparator
public static boolean hasOverlaps(List<? extends Range> ranges)
ranges
are assumed to be already sorted. The behavior is undefined, if not
already sorted.
sort(List)
public static boolean hasOverlaps(Range[] ranges)
ranges
are assumed to be already sorted. The behavior is undefined, if not
already sorted.
sort(Range[])
public static boolean contains(long value, Range range)
value
falls in the
specified range
.
public static OutCode outCode(long value, Range range)
value
relative to the specified range
.
public static int containingIndexOf(long value, List<? extends Range> ranges)
ranges
at which the
range contains
the specified value
, if such a range exists; o.w. it encodes
the index of where such a range should have been to satisfy
the search as a negative number.
Note the return value has roughly the same semantics as that of
Collections.binarySearch(List, Object)
.
value
,
if it is contained in the list; otherwise,
(-(insertion point) - 1)
.
The insertion point is defined as the point at which a Range
could be inserted into the sorted list that would satisfy
the search. Note that this guarantees that the return value will be ≥ 0
if and only if the key is found.public static int containingIndexOf(long value, Range[] ranges)
ranges
at which the
range contains
the specified value
, if such a range exists; o.w. it encodes
the index of where such a range should have been to satisfy
the search as a negative number.
Note the return value has roughly the same semantics as that of
Arrays.binarySearch(long[], long)
.
value
,
if it is contained in the array; otherwise,
(-(insertion point) - 1)
.
The insertion point is defined as the point at which a Range
could be inserted into the sorted array (imagining the array's
size is somehow increased by 1) that would satisfy
the search. Note that this guarantees that the return value will be ≥ 0
if and only if the key is found.public static Range createRange(long lo, long hi) throws IllegalArgumentException
IllegalArgumentException
- if hi ≤ lo
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |