net.ericaro.neoitertools.generators.GenericArrayGenerator Maven / Gradle / Ivy
The newest version!
package net.ericaro.neoitertools.generators;
import java.util.NoSuchElementException;
import net.ericaro.neoitertools.Generator;
/** A {@link Generator} based on any Object Type array.
*
* @author eric
*
* @see GenericArrayGenerator's wiki page
* @see neoitertools site
*/
public class GenericArrayGenerator implements Generator {
private T[] values;
private int i;
public GenericArrayGenerator(T... values) {
super();
this.values = values;
i = 0;
}
public T next() throws NoSuchElementException {
if (i>= values.length) throw new NoSuchElementException();
return values[i++];
}
}