|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectit.unimi.dsi.fastutil.ints.AbstractIntIterator
it.unimi.dsi.mg4j.search.AbstractDocumentIterator
public abstract class AbstractDocumentIterator
An abstract iterator on documents that implements hasNext()
and nextInt() using nextDocument(),
and provides support for the DocumentIterator.weight()/DocumentIterator.weight(double) methods.
As explained elsewhere, since MG4J 1.2 the iteration logic has been made fully lazy,
and the standard IntIterator methods are available as a commodity, but their use
in performance-sensitive environments is strongly discouraged. The fully lazy
implementation needs some bridging to be accessible using java.util's semi-lazy
iterators, and this class provides the necessary code.
Instances of this class keep track of the next document
to be returned, if it has been already peeked at by hasNext(), and of the
last document returned by nextInt() or
nextDocument(). Concrete subclasses must implement
nextDocument() so that after it has been called last is
equal to the returned document (possibly -1) and next is -1 (of course,
if next has already been set nextDocument() must behave exactly
like the implementation of nextInt() found in this class). Methods performing
actions depending on the last document returned should throw an IllegalStateException
if called when last is -1.
| Nested Class Summary | |
|---|---|
protected static class |
AbstractDocumentIterator.AbstractIntervalIterator
|
| Field Summary | |
|---|---|
protected int |
last
The last document returned by this iterator, or -1 if the iterator has never be advanced or if its state has been modified since the last call to nextInt()
or nextDocument() because of a call to hasNext(). |
protected int |
next
The next document to be returned, if it has already been peeked at by hasNext(),
or -1. |
protected double |
weight
The weight of this iterator. |
| Constructor Summary | |
|---|---|
AbstractDocumentIterator()
|
|
| Method Summary | |
|---|---|
int |
document()
Returns last, if it is not -1; otherwise, throws an IllegalStateException. |
boolean |
hasNext()
Checks whether next has been already set; if not, peeks at the document returned by nextDocument(). |
IntervalIterator |
iterator()
Invokes DocumentIterator.intervalIterator() |
int |
nextInt()
Deprecated. |
double |
weight()
Returns the weight associated to this iterator. |
DocumentIterator |
weight(double weight)
Sets the weight of this index iterator. |
| Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntIterator |
|---|
next, remove, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface it.unimi.dsi.mg4j.search.DocumentIterator |
|---|
accept, acceptOnTruePaths, dispose, indices, intervalIterator, intervalIterator, intervalIterators, nextDocument, skipTo |
| Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterator |
|---|
skip |
| Methods inherited from interface java.util.Iterator |
|---|
next, remove |
| Field Detail |
|---|
protected int last
nextInt()
or nextDocument() because of a call to hasNext().
protected int next
hasNext(),
or -1.
protected double weight
| Constructor Detail |
|---|
public AbstractDocumentIterator()
| Method Detail |
|---|
public double weight()
DocumentIteratorThe number returned by this method has no fixed semantics: different scorers might choose different interpretations, or even ignore it.
weight in interface DocumentIteratorpublic DocumentIterator weight(double weight)
DocumentIterator
weight in interface DocumentIteratorweight - the weight of this index iterator.
public IntervalIterator iterator()
DocumentIterator.intervalIterator()
iterator in interface DocumentIteratoriterator in interface Iterable<Interval>DocumentIterator.intervalIterator().public boolean hasNext()
next has been already set; if not, peeks at the document returned by nextDocument().
hasNext in interface Iterator<Integer>next is not -1 or if nextDocument() has returned a valid document pointer.@Deprecated public int nextInt()
last to next,
next to -1, and returns last.
nextInt in interface IntIteratornextInt in interface DocumentIteratornextInt in class AbstractIntIteratorhasNext().DocumentIterator.nextDocument()public int document()
last, if it is not -1; otherwise, throws an IllegalStateException.
document in interface DocumentIteratorlast, if it is not -1.
IllegalStateException - if last is -1.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||