|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.mg4j.util.ScoredDocumentBoundedSizeQueue
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 removing those that are first w.r.t. the secondary comparator. In particular, using the constructor with implicit comparators will give a queue that remembers just the documents with highest score.
Note that the accessible arrays document
and score
contain the document and scores corresponding to
the indices returned by DoubleHeapSesquiIndirectDoublePriorityQueue.dequeue()
.
Field Summary | |
int[] |
document
An array containing documents. |
double[] |
score
An array containing document scores. |
Constructor Summary | |
ScoredDocumentBoundedSizeQueue(int capacity)
Creates a new empty bounded-size queue with a given capacity and natural order as primary comparator. |
|
ScoredDocumentBoundedSizeQueue(int capacity,
DoubleComparator c)
Creates a new empty bounded-size queue with a given capacity. |
Method Summary | |
int |
dequeue()
Dequeues an index from the queue. |
void |
enqueue(int d,
double s)
Enqueues a document with given score. |
boolean |
isEmpty()
|
int |
size()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public final double[] score
public final int[] document
Constructor Detail |
public ScoredDocumentBoundedSizeQueue(int capacity)
This constructor uses as secondary comparator the opposite of the natural order.
capacity
- the initial capacity of this queue.public ScoredDocumentBoundedSizeQueue(int capacity, DoubleComparator c)
capacity
- the initial capacity of this queue.c
- the comparator used in this queue, or null
for the natural order.Method Detail |
public void enqueue(int d, double s)
d
- the document to enqueue.s
- its score.public boolean isEmpty()
public int size()
public int dequeue()
document
and score
using the index returned by this method.
Documents are dequeued in inverse score order.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |