package com.jscape.util.collections;

/**
 * @author Alex Usun
 */
public class IntArrayIterator
        implements IntIterator {

    protected final int[] data;
    protected final int initialPosition;
    protected final int length;
    protected int position;

    public IntArrayIterator(int[] data, int offset, int length) {
        this.data = data;
        this.initialPosition = offset;
        this.length = length;
        this.position = this.initialPosition;
    }

    public IntArrayIterator(int[] data) {
        this(data, 0, data.length);
    }

    public boolean hasNext() {
        return this.position < (this.initialPosition + this.length);
    }

    public int next() {
        return this.data[this.position++];
    }

    public void reset() {
        this.position = this.initialPosition;
    }

}
