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):| Modifier and Type | Class and Description |
|---|---|
static class |
RandomArrayIterator.Factory<E> |
| Constructor and Description |
|---|
RandomArrayIterator(E[] array,
int count) |
| Modifier and Type | Method and Description |
|---|---|
int |
abort()
Aborts the random iteration and returns the iteration count this
RandomArrayIterator
has produced until now. |
RandomArrayIterator<E> |
decrementCount(int amount) |
int |
getCount() |
int |
getIterationCount()
Returns the iteration count this
RandomArrayIterator 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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic RandomArrayIterator(E[] array, int count)
public static <E> RandomArrayIterator.Factory<E> random(int count, E[] array)
public int getCount()
public RandomArrayIterator<E> setCount(int count)
public RandomArrayIterator<E> incrementCount(int amount)
public RandomArrayIterator<E> decrementCount(int amount)
public int abort()
RandomArrayIterator
has produced until now.getIterationCount()public int getIterationCount()
RandomArrayIterator has produced until now.abort()public boolean hasNext()
hasNext in interface Iterator<E>Iterator.hasNext()public E next()
next in interface Iterator<E>Iterator.next()public void remove()
throws UnsupportedOperationException
remove in interface Iterator<E>UnsupportedOperationException - because this operation is not supportedIterator.remove()Copyright © 2022 MicroStream Software. All rights reserved.