/**
* in cases where we need a subset of a list (say when we need
* 500 elements at a time), we shall use this class.
* @author blmi1
*
*/
public class ListSplitter {
private List l;
private int chunksize;
private int index;
public ListSplitter(List l, int chunksize){
this.l = l;
this.chunksize = chunksize;
this.index = 0;
}
public boolean hasNext() {
return index < l.size();
}
public List next(){
int endIndex= (index+chunksize > l.size()?l.size(): (index+chunksize));
List ret= l.subList(index, endIndex);
index = endIndex;
return ret;
}
public int getIndex(){
return index;
}
public int getSize(){
return l.size();
}
}