Class Combinations.SingletonIterator
java.lang.Object
org.apache.commons.numbers.combinatorics.Combinations.SingletonIterator
- All Implemented Interfaces:
Iterator<int[]>
- Enclosing class:
Combinations
Iterator with just one element to handle degenerate cases (full array,
empty array) for combination iterator.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSingletonIterator
(int n) Create a singleton iterator providing the given array. -
Method Summary
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
-
Field Details
-
n
private final int nNumber of elements of the singleton array. -
more
private boolean moreTrue on initialization, false after first call to next.
-
-
Constructor Details
-
SingletonIterator
SingletonIterator(int n) Create a singleton iterator providing the given array.- Parameters:
n
- Size of the singleton array returned by the iterator.
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
public int[] next()- Specified by:
next
in interfaceIterator<int[]>
- Returns:
- the singleton at the first activation.
- Throws:
NoSuchElementException
- after the first activation.
-
remove
public void remove()Unsupported.- Specified by:
remove
in interfaceIterator<int[]>
- Throws:
UnsupportedOperationException
- Remove is not supported.
-