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>
Iteratorimplementation of a random array element retrieval generator.Usage example:
prints (for example):for(final Integer i : random(10, array(1,3,5,7,9))) { System.out.println(i); }
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)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
RandomArrayIterator
public RandomArrayIterator(E[] array, int count)
-
-
Method Detail
-
random
public static <E> RandomArrayIterator.Factory<E> random(int count, E[] array)
-
getCount
public int getCount()
-
setCount
public RandomArrayIterator<E> setCount(int count)
- Parameters:
count- the count to set
-
incrementCount
public RandomArrayIterator<E> incrementCount(int amount)
- Parameters:
amount-
-
decrementCount
public RandomArrayIterator<E> decrementCount(int amount)
- 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
public E next()
- Specified by:
nextin interfaceIterator<E>- See Also:
Iterator.next()
-
remove
public void remove() throws UnsupportedOperationException- Specified by:
removein interfaceIterator<E>- Throws:
UnsupportedOperationException- See Also:
Iterator.remove()
-
-