All pastes #396144 Raw Edit

Mine

public text v1 · immutable
·published 2007-03-15 15:06 UTC
rendered paste body
package oving7;

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

public abstract class IndexIterator<T> implements Iterator<T>{
	protected T lastElementReturned;
	protected int index;
	private int endIndex;
	private int step;
	
	protected IndexIterator(int index, int endIndex, int step){
		this.index = index;
		this.endIndex = endIndex;
		this.step = step;
	}
	
	public int getStep(){
		return step;
	}
	
	protected abstract int getSize();
	protected abstract T getElement(int index);
	
	public boolean hasNext(){
		if(index < endIndex)
			return true;
		return false;
	}
	
	public final T next(){
		index += step;
		if(hasNext())
			return getElement(index);
		else
			throw new NoSuchElementException();
	}
	
	
}