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 classRandomArrayIterator.Factory<E> -
Constructor Summary
Constructors Constructor Description RandomArrayIterator(E[] array, int count) -
Method Summary
Modifier and Type Method Description intabort()Aborts the random iteration and returns the iteration count thisRandomArrayIteratorhas produced until now.RandomArrayIterator<E>decrementCount(int amount)intgetCount()intgetIterationCount()Returns the iteration count thisRandomArrayIteratorhas produced until now.booleanhasNext()RandomArrayIterator<E>incrementCount(int amount)Enext()static <E> RandomArrayIterator.Factory<E>random(int count, E[] array)voidremove()RandomArrayIterator<E>setCount(int count)
-
Constructor Details
-
Method Details
-
random
-
getCount
public int getCount() -
setCount
- Parameters:
count- the count to set
-
incrementCount
- Parameters:
amount-
-
decrementCount
- Parameters:
amount-
-
abort
public int abort()Aborts the random iteration and returns the iteration count thisRandomArrayIteratorhas produced until now.- Returns:
- the current iteration count.
- See Also:
getIterationCount()
-
getIterationCount
public int getIterationCount()Returns the iteration count thisRandomArrayIteratorhas produced until now.- Returns:
- the current iteration count.
- See Also:
abort()
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<E>- See Also:
Iterator.hasNext()
-
next
- Specified by:
nextin interfaceIterator<E>- See Also:
Iterator.next()
-
remove
- Specified by:
removein interfaceIterator<E>- Throws:
UnsupportedOperationException- See Also:
Iterator.remove()
-