@GwtCompatible
public class IntegerRange
extends java.lang.Object
implements java.lang.Iterable<java.lang.Integer>
start up to end with an increment of step.
The value of start is always included.
The value of end is included only if the difference between end-start is a multiple of step.
The step can be positive or negative, but never 0. It must have the same signum as of end-start.| Constructor and Description |
|---|
IntegerRange(int start,
int end)
Constructs a new IntegerRange object.
|
IntegerRange(int start,
int end,
int step)
Constructs a new IntegerRange object.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(int number)
Checks whether this contains the given number, i.e.
|
int |
getEnd() |
int |
getSize()
Returns the number of elements in this IntegerRange.
|
int |
getStart() |
int |
getStep() |
java.util.ListIterator<java.lang.Integer> |
iterator() |
IntegerRange |
withStep(int step) |
@Pure public IntegerRange(int start, int end)
start - the start value (inclusive)end - the end value (inclusive)@Pure public IntegerRange(int start, int end, int step)
start - the start value (inclusive)end - the end value (inclusive if end-start%step == 0)step - the increment@Pure public java.util.ListIterator<java.lang.Integer> iterator()
iterator in interface java.lang.Iterable<java.lang.Integer>ListIterator for this.@Pure public int getStart()
@Pure public int getStep()
@Pure public int getEnd()
@Pure public int getSize()
(end-start)/step + 1.@Pure public IntegerRange withStep(int step)
step - the step of the new range.@Pure public boolean contains(int number)
0..2.by(2) will not contain 1.number - the number to be checked for containment.