001package org.clafer.collection;
002
003import gnu.trove.iterator.TIntIterator;
004
005/**
006 * An iterator over an interval in increasing order.
007 * 
008 * @author jimmy
009 */
010public class BoundIntIterator implements TIntIterator {
011
012    private int index;
013    private final int high;
014
015    /**
016     * Iterate in increasing order starting from low (inclusive) and ending in
017     * high (inclusive).
018     * 
019     * @param low the lowest value
020     * @param high the highest value
021     */
022    public BoundIntIterator(int low, int high) {
023        this.index = low;
024        this.high = high;
025    }
026
027    /** {@inheritDoc} */
028    @Override
029    public boolean hasNext() {
030        return index <= high;
031    }
032
033    /** {@inheritDoc} */
034    @Override
035    public int next() {
036        return index++;
037    }
038
039    /**
040     * Not supported.
041     * 
042     * @throws UnsupportedOperationException if invoked
043     */
044    @Override
045    public void remove() {
046        throw new UnsupportedOperationException();
047    }
048}