An index iterator scans the inverted list of an indexed term. Each integer returned by {@link DocumentIterator#nextDocument() nextDocument()} is the index of a document containing the term. If the index contains counts, they can be obtained after each call to {@link #nextDocument()} using {@link #count()}. Then, if the index contains positions they can be obtained as an array using {@link #positionArray()}, as an iterator using {@link #positions()}, or stored into an array using {@link #positions(int[])}.
Note that this interface extends {@link it.unimi.dsi.mg4j.search.DocumentIterator}. The intervals returned for a document are exactly length-one intervals corresponding to the positions returned by {@link #positions()}. If the index to which an instance of this class refers does not contain positions, an {@link UnsupportedOperationException}will be thrown.
Additionally, this interface strengthens {@link DocumentIterator#weight(double)} so thatit {@linkplain #weight(double) returns an index iterator}.
Example: Replace array with its square:
IndexIterator iter = A.getIndexIterator(); while (iter.hasNext()) { double val = iter.getDoubleNext(); iter.setDoubleCurrent( val * val); }Note that canonical order may not be physical order. @author caron
|
|