Package one.microstream.util.iterables
Class RandomArrayIterator<E>
java.lang.Object
one.microstream.util.iterables.RandomArrayIterator<E>
- All Implemented Interfaces:
Iterator<E>
public final class RandomArrayIterator<E> extends Object implements Iterator<E>
Iterator
implementation of a random array element retrieval generator.
Usage example:
for(final Integer i : random(10, array(1,3,5,7,9)))
{
System.out.println(i);
}
prints (for example):7
3
1
3
3
3
9
7
1
7
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RandomArrayIterator.Factory<E>
-
Constructor Summary
Constructors Constructor Description RandomArrayIterator(E[] array, int count)
-
Method Summary
Modifier and Type Method Description int
abort()
Aborts the random iteration and returns the iteration count thisRandomArrayIterator
has produced until now.RandomArrayIterator<E>
decrementCount(int amount)
int
getCount()
int
getIterationCount()
Returns the iteration count thisRandomArrayIterator
has produced until now.boolean
hasNext()
RandomArrayIterator<E>
incrementCount(int amount)
E
next()
static <E> RandomArrayIterator.Factory<E>
random(int count, E[] array)
void
remove()
RandomArrayIterator<E>
setCount(int count)
-
Constructor Details
-
Method Details
-
random
-
getCount
public int getCount() -
setCount
-
incrementCount
-
decrementCount
-
abort
public int abort()Aborts the random iteration and returns the iteration count thisRandomArrayIterator
has produced until now.- Returns:
- the current iteration count.
- See Also:
getIterationCount()
-
getIterationCount
public int getIterationCount()Returns the iteration count thisRandomArrayIterator
has produced until now.- Returns:
- the current iteration count.
- See Also:
abort()
-
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceIterator<E>
- See Also:
Iterator.hasNext()
-
next
- Specified by:
next
in interfaceIterator<E>
- See Also:
Iterator.next()
-
remove
- Specified by:
remove
in interfaceIterator<E>
- Throws:
UnsupportedOperationException
- because this operation is not supported- See Also:
Iterator.remove()
-