sdlip.helpers
Class RangeEnumerator
java.lang.Object
|
+--sdlip.helpers.RangeEnumerator
- public class RangeEnumerator
- extends java.lang.Object
Enumerates integers using one-based selection.
Examples:
"1-" all positive integers
"1,3-5,7" = "1,3,4,5,7"
next() or nextRange() must be called before calling get() for the first time
Method Summary |
int |
get()
Gets the current position
-1: invalid position |
int |
limit()
Gets the current position
-1: invalid position |
static void |
main(java.lang.String[] args)
|
boolean |
next()
moves the pointer to the next position
false if no more |
boolean |
nextRange()
moves the pointer to the next range
e.g., if range is 1-3,7-9,15- and get() returns 8, after nextRange(),
get() will return 15. |
void |
set(int nv)
Sets the current position |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
NONE
public static final int NONE
INFINITY
public static final int INFINITY
RangeEnumerator
public RangeEnumerator(java.lang.String selection)
next
public boolean next()
- moves the pointer to the next position
false if no more
nextRange
public boolean nextRange()
- moves the pointer to the next range
e.g., if range is 1-3,7-9,15- and get() returns 8, after nextRange(),
get() will return 15. For all other cases, it behaves the same as next()
false if no more
get
public int get()
- Gets the current position
-1: invalid position
limit
public int limit()
- Gets the current position
-1: invalid position
set
public void set(int nv)
- Sets the current position
toString
public java.lang.String toString()
- Overrides:
- toString in class java.lang.Object
main
public static void main(java.lang.String[] args)
throws java.lang.Exception