E - type of elements returned by this iteratorpublic class RandomIterator<E> extends Object implements Iterator<E>
Provides random iteration over a list with the ability to stop iteration early when a condition is met. This can provide significant performance improvements over Collections.shuffle() when the iteration process may terminate before processing all elements.
Uses BitSet for tracking served items and I2P RandomSource for better randomness distribution. Includes Android compatibility workarounds and proper bounds checking to prevent infinite loops.
Performance characteristics:
Note: Not recommended for small lists or when iterating through a large portion of a collection. Use Collections.shuffle() for those cases instead.
| Constructor and Description |
|---|
RandomIterator(List<E> list) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext() |
E |
next() |
void |
remove() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemaining