package net.ranides.assira.observable;

import java.util.Iterator;

public abstract class ObservableIterator<T> implements Iterator<T> {

    private final Iterator<T> itr;

    private T last;

    public ObservableIterator(Iterator<T> itr) {
        this.itr = itr;
    }

    @Override
    public final boolean hasNext() {
        return itr.hasNext();
    }

    @Override
    public final T next() {
        return last = itr.next();
    }

    @Override
    public final void remove() {
        itr.remove();
        signalRemove(last);
    }

    protected abstract void signalRemove(T value);
}
