|
PCJ API Version 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bak.pcj.set.LongRange
This class represents ranges of consecutive long values.
Design note: Empty ranges cannot exist. It gives too many problems defining adjacency and intersections, and empty ranges are not really useful for their purpose of backing up range sets. It also removes the problem of overflow checking.
Constructor Summary | |
LongRange(long first,
long last)
Creates a new range of consecutive long values. |
Method Summary | |
boolean |
adjacentTo(LongRange range)
Indicates whether this range is adjacent to a specified range. |
boolean |
canMergeWith(LongRange range)
Indicates whether this can be merged with a specified range. |
int |
compareTo(Object obj)
Compares this range with some object for order. |
boolean |
contains(long v)
Indicates whether a specified value is a member of this range. |
boolean |
equals(Object obj)
Indicates whether this range is equal to some object. |
long |
first()
Returns the first long value in this range. |
int |
hashCode()
Returns a hash code value for this range. |
int |
intersectionLength(LongRange range)
Returns the length of the intersection between this range and a specified range. |
boolean |
intersects(LongRange range)
Indicates whether this range intersects a specified range. |
long |
last()
Returns the last long value in this range. |
int |
length()
Returns the number of values in this range. |
LongRange |
mergeWith(LongRange range)
Creates a new range as a merge between this range and a specified range. |
String |
toString()
Returns a string representation of this range. |
LongRange |
tryMergeWith(LongRange range)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public LongRange(long first, long last)
first
- the first long value in the range.last
- the last long value in the range.
IllegalArgumentException
- if first > last.Method Detail |
public long first()
public long last()
public int length()
public boolean intersects(LongRange range)
range
- the range with which to compare this range.
NullPointerException
- if range is null.public boolean adjacentTo(LongRange range)
range
- the range with which to compare this range.
NullPointerException
- if range is null.public boolean canMergeWith(LongRange range)
range
- the range to merge with.
NullPointerException
- if range is null.public LongRange mergeWith(LongRange range)
range
- the range with which to merge this range.
NullPointerException
- if range is null.
IllegalArgumentException
- if this range cannot be merged with the specified
range.public LongRange tryMergeWith(LongRange range)
public int intersectionLength(LongRange range)
range
- the range with which to intersect this rance.
NullPointerException
- if range is null.public boolean contains(long v)
v
- the value to test for membership.
public boolean equals(Object obj)
obj
- the object with which to compare this range.
public int compareTo(Object obj)
compareTo
in interface Comparable
obj
- the object with which to compare this range.
NullPointerException
- if obj is null.
ClassCastException
- if obj is not of class LongRange.public int hashCode()
public String toString()
|
PCJ API Version 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |