001package org.clafer.collection;
002
003import gnu.trove.iterator.TIntIterator;
004import java.util.NoSuchElementException;
005
006/**
007 * Iterate over a single value.
008 * 
009 * @author jimmy
010 */
011public class SingleIntIterator implements TIntIterator {
012
013    private final int value;
014    private boolean hasNext = true;
015
016    /**
017     * Iterate over a single value.
018     * 
019     * @param value the single value
020     */
021    public SingleIntIterator(int value) {
022        this.value = value;
023    }
024
025    /** {@inheritDoc} */
026    @Override
027    public boolean hasNext() {
028        return hasNext;
029    }
030
031    /** {@inheritDoc} */
032    @Override
033    public int next() {
034        if (hasNext) {
035            hasNext = false;
036            return value;
037        }
038        throw new NoSuchElementException();
039    }
040
041    /**
042     * Not supported.
043     * 
044     * @throws UnsupportedOperationException if invoked
045     */
046    @Override
047    public void remove() {
048        throw new UnsupportedOperationException();
049    }
050}