E
- The element type for this iterator.@Status(stage=PRODUCTION, unitTests=COMPLETE) public class RandomElementIterator<E> extends Object implements Iterator<E>
Constructor and Description |
---|
RandomElementIterator(List<E> elements)
Creates this RandomElementIterator using the supplied elements.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Determines whether more elements exist.
|
E |
next()
Gets the next element.
|
void |
remove()
Throws an UnsupportedOperationException.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public RandomElementIterator(List<E> elements)
elements
- The list of elements to return randomly.IllegalArgumentException
- When the supplied list of elements is
empty.NullPointerException
- When the supplied list of elements is null.public boolean hasNext()
public E next()
next
in interface Iterator<E>
NoSuchElementException
- When this method is called when there are no more elements.public void remove()
remove
in interface Iterator<E>
UnsupportedOperationException
- Always.Copyright © 2008–2018. All rights reserved.