/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.collection;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 * taki spliterator trochę
 */
public abstract class VirtualIterator<T> implements Iterator<T> {
    
    private T hit = null;
            
    protected abstract T get();

    @Override
    public boolean hasNext() {
        return null != (hit = get());
    }

    @Override
    public T next() {
        if(hit == null) {
            throw new NoSuchElementException();
        }
        return hit;
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("Not supported.");
    }
}
