Class IntRangeIterator
- java.lang.Object
-
- ru.ispras.testbase.knowledge.iterator.IntRangeIterator
-
- All Implemented Interfaces:
BoundedIterator<java.lang.Integer>
,Iterator<java.lang.Integer>
public final class IntRangeIterator extends java.lang.Object implements BoundedIterator<java.lang.Integer>
IntRangeIterator
implements an integer number iterator over given range.
-
-
Constructor Summary
Constructors Modifier Constructor Description IntRangeIterator(int max)
Constructs an integer number range iterator with the lower bound equal to zero and the increment value equal to one.IntRangeIterator(int min, int max)
Constructs an integer number range iterator with the increment value equal to one.IntRangeIterator(int min, int max, int inc)
Constructs an integer number range iterator.protected
IntRangeIterator(IntRangeIterator other)
Constructs a copy of the iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IntRangeIterator
clone()
Creates a copy of the iterator.boolean
hasValue()
Checks if the iterator is not exhausted (a value is available).void
init()
Initializes the iterator.void
next()
Makes an iteration.void
setValue(int value)
Sets the current value.int
size()
Returns the size of the collection of the iterated items.void
stop()
Stops the iterator.java.lang.Integer
value()
Returns the current value of the iterator.
-
-
-
Constructor Detail
-
IntRangeIterator
public IntRangeIterator(int min, int max, int inc)
Constructs an integer number range iterator.- Parameters:
min
- the lower bound.max
- the upper bound.inc
- the increment value (step).
-
IntRangeIterator
public IntRangeIterator(int min, int max)
Constructs an integer number range iterator with the increment value equal to one.- Parameters:
min
- the lower bound.max
- the upper bound.
-
IntRangeIterator
public IntRangeIterator(int max)
Constructs an integer number range iterator with the lower bound equal to zero and the increment value equal to one.- Parameters:
max
- the upper bound.
-
IntRangeIterator
protected IntRangeIterator(IntRangeIterator other)
Constructs a copy of the iterator.- Parameters:
other
- the iterator to be copied.
-
-
Method Detail
-
setValue
public void setValue(int value)
Sets the current value.- Parameters:
value
- the value to set.
-
init
public void init()
Description copied from interface:Iterator
Initializes the iterator.
-
hasValue
public boolean hasValue()
Description copied from interface:Iterator
Checks if the iterator is not exhausted (a value is available).
-
value
public java.lang.Integer value()
Description copied from interface:Iterator
Returns the current value of the iterator.
-
next
public void next()
Description copied from interface:Iterator
Makes an iteration.
-
stop
public void stop()
Description copied from interface:Iterator
Stops the iterator.
-
size
public int size()
Description copied from interface:BoundedIterator
Returns the size of the collection of the iterated items.- Specified by:
size
in interfaceBoundedIterator<java.lang.Integer>
- Returns:
- the number of items being iterated.
-
clone
public IntRangeIterator clone()
Description copied from interface:Iterator
Creates a copy of the iterator.
-
-