aima.core.util.ArrayIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
package aima.core.util;
import java.util.Iterator;
/**
* Iterates efficiently through an array.
*
* @author Ruediger Lunde
*/
public class ArrayIterator implements Iterator {
T[] values;
int counter;
public ArrayIterator(T[] values) {
this.values = values;
counter = 0;
}
public boolean hasNext() {
return counter < values.length;
}
public T next() {
return values[counter++];
}
public void remove() {
throw new UnsupportedOperationException();
}
}