Package ca.phon.util
Class Range
java.lang.Object
ca.phon.util.Range
- All Implemented Interfaces:
Serializable
,Iterable<Integer>
An iterable integer range.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(int val) boolean
static Range
fromString
(String rangeStr) Parse a string into a range object.int
getEnd()
int
getFirst()
int
getLast()
int
getRange()
int
getStart()
int
hashCode()
boolean
iterator()
static void
boolean
reduceRanges
(List<Range> ranges) This method takes a list of ranges and attempts to reduce them.void
setEnd
(int end) void
setExcludesEnd
(boolean excludesEnd) void
setStart
(int start) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Range
public Range() -
Range
public Range(int start, int end) -
Range
public Range(int start, int end, boolean excludesEnd)
-
-
Method Details
-
getStart
public int getStart() -
setStart
public void setStart(int start) -
getEnd
public int getEnd() -
getRange
public int getRange() -
setEnd
public void setEnd(int end) -
isExcludesEnd
public boolean isExcludesEnd() -
getFirst
public int getFirst() -
getLast
public int getLast() -
setExcludesEnd
public void setExcludesEnd(boolean excludesEnd) -
hashCode
public int hashCode() -
iterator
-
overlaps
-
contains
-
contains
public boolean contains(int val) -
intersect
-
main
-
toString
-
fromString
Parse a string into a range object. Supported formats are the same as return values from toString()- Parameters:
rangeStr
-- Returns:
- Range
-
reduceRanges
This method takes a list of ranges and attempts to reduce them. If one range is completely contained within another only the larger range is kept.- Parameters:
ranges
-- Returns:
- List
-