| Modifier and Type | Class and Description |
|---|---|
| public static class | IntegerSequence.
Utility that increments a counter until a maximum is reached, at
which point, the instance will by default throw a
|
| public static class | IntegerSequence.
Generates a sequence of integers. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static IntegerSequence. | Returns: a range.First value of the range. start, int Last value of the range. end)Creates a sequence |
| public static IntegerSequence. | Returns: a range.First value of the range. start, final int Last value of the range that satisfies the above
construction rule. max, final int Increment. step)Creates a sequence \( a_i, i < 0 <= n \) where \( a_i = start + i * step \) and \( n \) is such that \( a_n <= max \) and \( a_{n+1} > max \). |
| IntegerSequence | back to summary |
|---|---|
| private IntegerSequence() Utility class contains only static methods. | |
| range | back to summary |
|---|---|
| public static IntegerSequence. Creates a sequence
| |
| range | back to summary |
|---|---|
| public static IntegerSequence. Creates a sequence \( a_i, i < 0 <= n \) where \( a_i = start + i * step \) and \( n \) is such that \( a_n <= max \) and \( a_{n+1} > max \).
| |
MaxCountExceededException.
However, the user is able to override this behaviour by defining a
custom callback, in order to e.g.
select which exception must be thrown.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | IntegerSequence.
Defines a method to be called at counter exhaustion. |
| Modifier and Type | Field and Description |
|---|---|
| private static final IntegerSequence. | CALLBACK
Default callback. |
| private int | count
Current count. |
| private final int | increment
Increment. |
| private final int | init
Initial value the counter. |
| private final IntegerSequence. | maxCountCallback
Function called at counter exhaustion. |
| private final int | maximalCount
Upper limit for the counter. |
| Access | Constructor and Description |
|---|---|
| private | Incrementor(int
Initial value. start, int Maximal count. max, int Increment. step, IntegerSequence.Function to be called when the maximal count has been reached. cbCreates an incrementor. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public boolean | canIncrement(int
Number of increments. nTimes)Checks whether incrementing the counter several times is allowed. |
| public static IntegerSequence. | |
| public int | |
| public int | |
| public boolean | |
| public void | |
| public void | |
| public Integer | |
| public void | |
| public IntegerSequence. | Returns: a new instance.Callback to be called at counter exhaustion. cbCreates a new instance with a given callback. |
| public IntegerSequence. | Returns: a new instance.Increment. step)Creates a new instance with a given increment. |
| public IntegerSequence. | Returns: a new instance.Maximal count. max)Creates a new instance with a given maximal count. |
| public IntegerSequence. | Returns: a new instance.Initial value of the counter. start)Creates a new instance with a given initial value. |
| CALLBACK | back to summary |
|---|---|
| private static final IntegerSequence. Default callback. | |
| count | back to summary |
|---|---|
| private int count Current count. | |
| increment | back to summary |
|---|---|
| private final int increment Increment. | |
| init | back to summary |
|---|---|
| private final int init Initial value the counter. | |
| maxCountCallback | back to summary |
|---|---|
| private final IntegerSequence. Function called at counter exhaustion. | |
| maximalCount | back to summary |
|---|---|
| private final int maximalCount Upper limit for the counter. | |
| Incrementor | back to summary |
|---|---|
| private Incrementor(int start, int max, int step, IntegerSequence. Creates an incrementor.
The counter will be exhausted either when
| |
| canIncrement | back to summary |
|---|---|
| public boolean canIncrement() Checks whether incrementing the counter
| |
| canIncrement | back to summary |
|---|---|
| public boolean canIncrement(int nTimes) Checks whether incrementing the counter several times is allowed.
| |
| create | back to summary |
|---|---|
| public static IntegerSequence. Factory method that creates a default instance.
The initial and maximal values are set to 0.
For the new instance to be useful, the maximal count must be set
by calling
| |
| getCount | back to summary |
|---|---|
| public int getCount() Gets the current count.
| |
| getMaximalCount | back to summary |
|---|---|
| public int getMaximalCount() Gets the upper limit of the counter.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| increment | back to summary |
|---|---|
| public void increment(int nTimes) throws MaxCountExceededException Performs multiple increments.
| |
| increment | back to summary |
|---|---|
| public void increment() throws MaxCountExceededException Adds the increment value to the current iteration count.
At counter exhaustion, this method will call the
| |
| next | back to summary |
|---|---|
| public Integer next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Not applicable. | |
| withCallback | back to summary |
|---|---|
| public IntegerSequence. Creates a new instance with a given callback. The counter is reset to the initial value.
| |
| withIncrement | back to summary |
|---|---|
| public IntegerSequence. Creates a new instance with a given increment. The counter is reset to the initial value.
| |
| withMaximalCount | back to summary |
|---|---|
| public IntegerSequence. Creates a new instance with a given maximal count. The counter is reset to the initial value.
| |
| withStart | back to summary |
|---|---|
| public IntegerSequence. Creates a new instance with a given initial value. The counter is reset to the initial value.
| |
trigger method should usually throw an exception.
| Modifier and Type | Method and Description |
|---|---|
| public void |
| trigger | back to summary |
|---|---|
| public void trigger(int maximalCount) throws MaxCountExceededException Function called when the maximal count has been reached.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final int | max
Final value. |
| private final int | size
Number of integers contained in this range. |
| private final int | start
First value. |
| private final int | step
Increment. |
| Access | Constructor and Description |
|---|---|
| public | Range(int
First value of the range. start, int Last value of the range that satisfies the above
construction rule. max, int Increment. step)Creates a sequence \( a_i, i < 0 <= n \) where \( a_i = start + i * step \) and \( n \) is such that \( a_n <= max \) and \( a_{n+1} > max \). |
| max | back to summary |
|---|---|
| private final int max Final value. | |
| size | back to summary |
|---|---|
| private final int size Number of integers contained in this range. | |
| start | back to summary |
|---|---|
| private final int start First value. | |
| step | back to summary |
|---|---|
| private final int step Increment. | |
| Range | back to summary |
|---|---|
| public Range(int start, int max, int step) Creates a sequence \( a_i, i < 0 <= n \) where \( a_i = start + i * step \) and \( n \) is such that \( a_n <= max \) and \( a_{n+1} > max \).
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type | |
| size | back to summary |
|---|---|
| public int size() Gets the number of elements contained in the range.
| |