|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mozilla.util.Range
public class Range
An Range is an object representing a range of integer values. A range has a start index and a count. The count must be greater than or equal to 0. Instances of this class are immutable, but subclasses may introduce mutability. A mutable range will return true from isMutable().
,
Serialized FormField Summary | |
---|---|
protected int |
count
The length of the range |
protected int |
start
The start index of the range |
static Range |
ZeroRange
A zero range |
Constructor Summary | |
---|---|
Range(int newStart,
int newCount)
Creates an instance of Range with a start index newStart and an extent newCount. |
|
Range(Range otherRange)
Creates an instance of Range from another Range object otherRange which must be non-null. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Creates and returns an Range that is identical to this one. |
boolean |
containsIndex(int index)
Returns true if and only if index lies within this range. |
boolean |
containsRange(Range otherRange)
Returns true if and only if every element in otherRange is contained in this range. |
boolean |
equals(java.lang.Object otherRange)
Returns true if and only if otherRange is an Range with the same start and count as this range. |
protected int |
getConstrainedInt(int number)
Returns a number guaranteed to be within this range, including endpoints |
int |
getCount()
Returns the number of elements in this range. |
int |
getEnd()
Returns the the last index contained within the range. |
int |
getMax()
Returns the max index (the index at start + count). |
int |
getStart()
Returns the start index of the range. |
int |
hashCode()
Overridden because equals() is overridden. |
boolean |
intersectsWithRange(Range otherRange)
Returns true if and only if otherRange intersects with this range. |
boolean |
isAdjacentToRange(Range otherRange)
Returns true if and only if otherRange is adjacent to this range; two ranges are adjacent if the max of one range is equal to the start of the other. |
boolean |
isAfterIndex(int index)
Returns true if and only if the start index of this range is greater than index. |
protected boolean |
isAfterRange(Range otherRange)
Returns true if this range is after otherRange and the two ranges do not overlap. |
boolean |
isBeforeIndex(int index)
Return true if and only if the end index of this range is less than index. |
boolean |
isBeforeRange(Range otherRange)
Returns true if and only if this range is before otherRange and the two ranges do not overlap. |
boolean |
isMutable()
Returns true only if this instance can change after it is created. |
int |
overlapWithRange(Range otherRange)
Returns the number of elements that are in both this range and otherRange. |
Range |
rangeFromIntersection(Range otherRange)
Returns the intersection of this range and otherRange. |
Range |
rangeFromUnion(Range otherRange)
Returns the union of this range and otherRange. |
Range |
rangeShiftedByOffset(int offset)
Returns this range, with its start shifted by offset. |
java.lang.String |
toString()
Returns a String representation of this Range. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Range ZeroRange
protected int start
protected int count
Constructor Detail |
---|
public Range(Range otherRange)
otherRange
- the reference range to create this range from
java.lang.IllegalArgumentException
- if otherRange is nullpublic Range(int newStart, int newCount)
newStart
- the start index of the rangenewCount
- the number of elements in the range
RangeException
- if newCount is less than 0.Method Detail |
---|
public int getStart()
public int getCount()
public int getEnd()
public int getMax()
protected int getConstrainedInt(int number)
public boolean containsIndex(int index)
public boolean isAfterIndex(int index)
public boolean isBeforeIndex(int index)
public boolean containsRange(Range otherRange)
java.lang.IllegalArgumentException
- if otherRange is nullintersectsWithRange(Range otherRange)
public boolean intersectsWithRange(Range otherRange)
java.lang.IllegalArgumentException
- if otherRange is nullpublic int overlapWithRange(Range otherRange)
otherRange
- a range to check overlaps with this range
java.lang.IllegalArgumentException
- if otherRange is nullpublic boolean isAdjacentToRange(Range otherRange)
java.lang.IllegalArgumentException
- if otherRange is nullpublic boolean isBeforeRange(Range otherRange)
java.lang.IllegalArgumentException
- if otherRange is nullprotected boolean isAfterRange(Range otherRange)
java.lang.IllegalArgumentException
- if otherRange is nullpublic Range rangeFromIntersection(Range otherRange)
java.lang.IllegalArgumentException
- if otherRange is nullpublic Range rangeFromUnion(Range otherRange)
java.lang.IllegalArgumentException
- if otherRange is nullpublic Range rangeShiftedByOffset(int offset)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isMutable()
The default implementation returns false because instances of this class can't change; subclasses that introduce mutability should override this method to return true.
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object otherRange)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |