|
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.ShortRange
This class represents ranges of consecutive short 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 | |
ShortRange(short first,
short last)
Creates a new range of consecutive short values. |
Method Summary | |
boolean |
adjacentTo(ShortRange range)
Indicates whether this range is adjacent to a specified range. |
boolean |
canMergeWith(ShortRange 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(short 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. |
short |
first()
Returns the first short value in this range. |
int |
hashCode()
Returns a hash code value for this range. |
int |
intersectionLength(ShortRange range)
Returns the length of the intersection between this range and a specified range. |
boolean |
intersects(ShortRange range)
Indicates whether this range intersects a specified range. |
short |
last()
Returns the last short value in this range. |
int |
length()
Returns the number of values in this range. |
ShortRange |
mergeWith(ShortRange range)
Creates a new range as a merge between this range and a specified range. |
String |
toString()
Returns a string representation of this range. |
ShortRange |
tryMergeWith(ShortRange range)
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ShortRange(short first, short last)
first
- the first short value in the range.last
- the last short value in the range.
IllegalArgumentException
- if first > last.Method Detail |
public short first()
public short last()
public int length()
public boolean intersects(ShortRange range)
range
- the range with which to compare this range.
NullPointerException
- if range is null.public boolean adjacentTo(ShortRange range)
range
- the range with which to compare this range.
NullPointerException
- if range is null.public boolean canMergeWith(ShortRange range)
range
- the range to merge with.
NullPointerException
- if range is null.public ShortRange mergeWith(ShortRange 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 ShortRange tryMergeWith(ShortRange range)
public int intersectionLength(ShortRange range)
range
- the range with which to intersect this rance.
NullPointerException
- if range is null.public boolean contains(short 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 ShortRange.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 |