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