|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.di.mg4j.search.score.ScoredDocumentBoundedSizeQueue<T>
public class ScoredDocumentBoundedSizeQueue<T>
A queue of scored documents with fixed maximum capacity.
Instances of this class contain a queue in which it possible to enqueue a document with given score.
The capacity of the queue is fixed at creation time: once the queue is filled, new elements are enqueued
by dequeueing those in the queue or discarded, depending on their score; the return
value of enqueue(int, double, Object)
can be used to check whether the argument
has been actually enqueued or not. In particular, using the
standard constructor will
give a queue that remembers just the documents with highest score. As a commodity, document can be
enqueued together with additional information that can
be retrieved later.
The standard constructor orders document by score first, and then by document index. This trick guarantees that the queue is stable (because the order is an actual order, not a preorder), and makes it possible to consistently retrieve documents from the k-th to the (k+j)-th using a queue of capacity k+j from which j elements are extracted.
Warning: documents are dequeued in score order, which means documents with smaller score are dequeued first.
The queue returns its results as instances of DocumentScoreInfo
.
Constructor Summary | |
---|---|
ScoredDocumentBoundedSizeQueue(int capacity)
Creates a new empty bounded-size queue with a given capacity and natural order as comparator. |
Method Summary | |
---|---|
DocumentScoreInfo<T> |
dequeue()
Dequeues a document from the queue, returning an instance of DocumentScoreInfo . |
boolean |
enqueue(int d,
double s)
Enqueues a document with given score. |
boolean |
enqueue(int d,
double s,
T i)
Enqueues a document with given score and info. |
boolean |
isEmpty()
|
int |
size()
|
boolean |
wouldEnqueue(int d,
double s)
Checks whether a document with given score would be enqueued. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScoredDocumentBoundedSizeQueue(int capacity)
Documents with equal scores will be compared using their document index.
capacity
- the initial capacity of this queue.Method Detail |
---|
public boolean wouldEnqueue(int d, double s)
If this methods returns true, an immediately following call to
enqueue(int, double, Object)
with the same score would
case the document to be enqueued.
d
- the document to test.s
- its score.
enqueue(int, double, Object)
.public boolean enqueue(int d, double s, T i)
d
- the document to enqueue.s
- its score.i
- additional information about this document.
public boolean enqueue(int d, double s)
d
- the document to enqueue.s
- its score.
public boolean isEmpty()
public int size()
public DocumentScoreInfo<T> dequeue()
DocumentScoreInfo
.
Documents are dequeued in inverse score order.
DocumentScoreInfo
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |