|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsk.baka.ambient.commons.Interval
public final class Interval
Specifies an integer index interval. Immutable. Iterator simply iterates over indices contained in this interval.
| Field Summary | |
|---|---|
static Interval |
EMPTY
An empty interval. |
int |
end
Index of last item in the interval. |
int |
length
Number of successive items in the interval. |
int |
start
Index of first item in the interval. |
| Constructor Summary | |
|---|---|
Interval(int start,
int length)
Creates new interval. |
|
| Method Summary | |
|---|---|
boolean |
contains(int index)
Checks if given item is contained in the interval. |
boolean |
contains(Interval other)
Checks if given interval is contained in the interval. |
boolean |
endsWith(Interval other)
Checks if given interval covers items at the end of this interval. |
boolean |
equals(int start,
int end)
Compares this interval to the interval specified by two integers. |
boolean |
equals(Object o)
|
static Interval |
fromItem(int itemIndex)
Returns interval which contains only a single item. |
static Interval |
fromRange(int intervalStart,
int intervalEnd)
Creates given interval. |
int |
hashCode()
|
boolean |
isEmpty()
Checks if at least a single item is in the interval. |
boolean |
isEndpoint(int i)
Checks if given index is an endpoint of this interval (i.e. |
Iterator<Integer> |
iterator()
|
boolean |
startsWith(Interval other)
Checks if given interval covers items at the beginning of this interval. |
Object |
subtract(Interval other)
Subtracts given interval from this one and returns result. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final int start
public final int length
public static final Interval EMPTY
public final int end
| Constructor Detail |
|---|
public Interval(int start,
int length)
start - Index of first item in the interval.length - Number of successive items in the interval.| Method Detail |
|---|
public boolean isEmpty()
false if at least single item is in the interval,
true otherwise.public boolean contains(int index)
index - index of item
true if the item belongs to the interval.public boolean contains(Interval other)
other - the other interval
true if given interval belongs to the interval.
public static Interval fromRange(int intervalStart,
int intervalEnd)
intervalStart - start of intervalintervalEnd - end of interval
public static Interval fromItem(int itemIndex)
itemIndex - the item index.
public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectpublic Iterator<Integer> iterator()
iterator in interface Iterable<Integer>public boolean isEndpoint(int i)
i - the index to check
true if given index is an endpoint,
false otherwise.
public boolean equals(int start,
int end)
start - the first end of the intervalend - the second end of the interval
true if two intervals contain the same items,
false otherwise.public boolean startsWith(Interval other)
other - the other interval
true if other interval covers items at the
beginning of this interval.public boolean endsWith(Interval other)
other - the other interval
true if other interval covers items at the
end of this interval.public Object subtract(Interval other)
other - the interval to subtract
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||