All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aima.core.util.ArrayIterator Maven / Gradle / Ivy

Go to download

AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.

The newest version!
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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy