|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjlibs.core.util.Range
public class Range
This class represents integer range.
| Field Summary | |
|---|---|
int |
max
|
int |
min
|
| Constructor Summary | |
|---|---|
Range(int min,
int max)
Note that both min and max are inclusive |
|
| Method Summary | |
|---|---|
boolean |
after(int x)
returns true if this range is after given number |
boolean |
before(int x)
return true if this range is before given number |
boolean |
contains(int x)
returns true if this range contains given number |
boolean |
equals(Object obj)
|
int |
hashCode()
|
static List<Range> |
intersection(List<Range> list1,
List<Range> list2)
|
Range |
intersection(Range that)
return the portion of range that is common to this range and given range. If there is nothing common, then null is returned. |
static List<Range> |
minus(List<Range> list1,
List<Range> list2)
|
Range[] |
minus(Range that)
returns the portion(s) of this range that are not present in given range. |
boolean[] |
position(Range that)
tells the position this range with respect to given range. |
static boolean |
same(List<Range> list1,
List<Range> list2)
|
Range[] |
split(Range that)
this method splits this range into 3 regions with respect to given range |
String |
toString()
|
static List<Range> |
union(List<Range> ranges)
|
Range[] |
union(Range that)
returns union of this range with given range. if both ranges are adjacent/intersecting to each other, then the returned array will have only one range. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final int min
public final int max
| Constructor Detail |
|---|
public Range(int min,
int max)
| Method Detail |
|---|
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Objectpublic String toString()
toString in class Objectpublic boolean before(int x)
------------ o
public boolean after(int x)
o --------------
public boolean contains(int x)
------o--------
public boolean[] position(Range that)
the return value is boolean array of size 3.
1st boolean ==> true if some portion of this range is before given rangeideally, you can remebers these boolean as { before, inside, after }
2nd boolean ==> true if this range intersects with given range
3rd boolean ==> true if some portion of this range is after given range
public Range[] split(Range that)
the return value is Range array of size 3.
1st range ==> the portion of this range that is before given rangeNote that the values in returned array can be null, if there is no range satifying the requirement.
2nd range ==> the portion of range that is common to this range and given range
3rd range ==> the portion of this range that is after given range.
public Range intersection(Range that)
public Range[] union(Range that)
public Range[] minus(Range that)
public static List<Range> union(List<Range> ranges)
public static List<Range> intersection(List<Range> list1,
List<Range> list2)
public static List<Range> minus(List<Range> list1,
List<Range> list2)
public static boolean same(List<Range> list1,
List<Range> list2)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||