- Type Parameters:
T -
- All Implemented Interfaces:
- Iterator<List<T>>
public class StackCartesianProductIterator<T>
extends Object
implements Iterator<List<T>>
StackCartesianProductIterator it = new StackCartesianProductIterator(a, b,c);
Example loop on how to use the iterator for bailing out early:
while (it.hasNext()) {
List current = it.peek();
System.out.println("Path: " + current);
if(!isAccepted(current)) {
it.next();
continue;
}
if(!it.canDescend()) {
//System.out.println("got a candidate");
// We reached a leaf node - process it, and move on
it.next();
}
else {
// We have not yet reached a leaf, therefore descend
it.descend();
}
}
- Author:
- raven