I'm doing some homework, and we're giving a class that uses the iterator interface to go over some files, separate them line by line, and execute a method to modify the data in some way. In this case I'm using a list, but when I use my hasNext() is returns false every time although the list is not empty.
public class TransformToMany implements Iterator {
private final Function<InT, List<OutT>> f;
private final Iterator<InT> input;
private ArrayList<OutT> inputQ = new ArrayList<OutT>();
private int counter = 0;
public TransformToMany(Function<InT, List<OutT>> f, Iterator<InT> input) {
this.input = input;
this.f = f;
}
@Override
public boolean hasNext() {
return !inputQ.isEmpty();
}
Aucun commentaire:
Enregistrer un commentaire