ma.vi.base.collections.ArrayIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.vikmad.base Show documentation
Show all versions of com.vikmad.base Show documentation
Base algos, data structures and utilities
The newest version!
package ma.vi.base.collections;
import java.util.Iterator;
/**
* An iterator over arrays.
*
* @param The component type of the array to iterate over
* @author Vikash Madhow ([email protected])
*/
public class ArrayIterator implements Iterator {
/**
* Creates an iterator that will iterate over the provided items
*/
public ArrayIterator(E... items) {
this.items = items;
}
@Override
public synchronized boolean hasNext() {
return position < items.length;
}
@Override
public synchronized E next() {
return items[position++];
}
/**
* Array to iterate over
*/
private final E[] items;
/**
* Current position of iterator which is the position of the item that
* will be returned by {@link #next()}.
*/
private int position = 0;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy