it.unimi.dsi.mg4j.search
Interface IntervalIterator

All Superinterfaces:
Iterator
All Known Implementing Classes:
IntervalIterators.EmptyIntervalIterator, IntervalIterators.FakeIterator

public interface IntervalIterator
extends Iterator

An interface that allows one to iterate over intervals. Apart for the usual methods of a (type-specific) iterator, it has a special (optional) reset() method that allows one to reset the iterator: the exact meaning of this operation is decided by the implementing classes. Typically, after a reset(), one can iterate over a new sequence.

This interface also specifies a method extent() returning a positive integer that is supposed to approximate the minimum possible length of an interval returned by this iterator. This method returns -1 if this extent cannot be computed.


Method Summary
 int extent()
          Returns an approximation of a lower bound for the length of an interval returned by this iterator.
 Interval nextInterval()
          Returns the next interval in the sequence.
 void reset()
          Resets the internal state of this iterator for a new document.
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Method Detail

nextInterval

public Interval nextInterval()
Returns the next interval in the sequence.

A call to this method is equivalent to (Interval)next().

Returns:
the next interval in the sequence.
Throws:
UnsupportedOperationException - if this iterator has multiple indices.

reset

public void reset()
Resets the internal state of this iterator for a new document.

To reduce object creation, interval iterators are usually created in a lazy fashion by document iterator when they are needed. However, this implies that every time the document iterator is moved, some internal state of the interval iterator must be reset (e.g., because on the new document some of the component interval iterators are now IntervalIterators.TRUE).


extent

public int extent()
Returns an approximation of a lower bound for the length of an interval returned by this iterator.

Returns:
an approximation of a lower bound for the length of an interval.