common
Class AbstractTupleIterator

java.lang.Object
  extended by common.AbstractTupleIterator
All Implemented Interfaces:
java.util.Iterator

public abstract class AbstractTupleIterator
extends java.lang.Object
implements java.util.Iterator

An iterator over the set of tuples (x1, ..., xk) such that x1 is in S1, x2 is in S2(x1), etc., and xk is in Sk(x1, ..., x(k-1)). This is a generalization of the standard TupleIterator, where Si does not depend on x1, ..., x(i-1). Subclasses should override the getIterator method.

The algorithm is depth-first search on a tree where edges are labeled with tuple elements. If a node is reached by the path x1, ..., x(i-1), then its children are labeled with the elements of Si(x1, ..., x(i-1)). A node at depth k corresponds to a complete tuple. If some of the sets Si are empty, then some nodes at depths less than k are dead ends with no children. The algorithm backtracks when it reaches one of these nodes.


Constructor Summary
AbstractTupleIterator(int k)
          Creates a new AbstractTupleIterator for tuples of length k.
 
Method Summary
protected  void doneWithIterator(java.util.Iterator iter)
          Method called whenever the AbstractTupleIterator is done with an iterator returned earlier by getIterator (i.e., that iterator's hasNext method has returned false).
protected abstract  java.util.Iterator getIterator(int indexInTuple, java.util.List tuple)
          Returns an iterator over the ith set given that x1, ..., x(i-1) have the values specified in the given tuple.
 boolean hasNext()
          Returns true if there are any more tuples to return.
 java.lang.Object next()
          Returns another tuple not returned previously.
 void remove()
          OPTIONAL METHOD -- NOT IMPLEMENTED.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTupleIterator

public AbstractTupleIterator(int k)
Creates a new AbstractTupleIterator for tuples of length k.

Method Detail

hasNext

public boolean hasNext()
Returns true if there are any more tuples to return.

Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
Returns another tuple not returned previously.

Specified by:
next in interface java.util.Iterator

remove

public void remove()
OPTIONAL METHOD -- NOT IMPLEMENTED.

Specified by:
remove in interface java.util.Iterator

getIterator

protected abstract java.util.Iterator getIterator(int indexInTuple,
                                                  java.util.List tuple)
Returns an iterator over the ith set given that x1, ..., x(i-1) have the values specified in the given tuple. The entries in the tuple from index i onwards should be ignored.

Parameters:
indexInTuple - the index i

doneWithIterator

protected void doneWithIterator(java.util.Iterator iter)
Method called whenever the AbstractTupleIterator is done with an iterator returned earlier by getIterator (i.e., that iterator's hasNext method has returned false). The default implementation does nothing, but subclasses can override it.