Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
Public Member Functions | List of all members
Lucene.Net.Search.HitQueue Class Reference

Inherits PriorityQueue< ScoreDoc >.

Public Member Functions

 HitQueue (int size, bool prePopulate)
 Creates a new instance with size elements. If prePopulate is set to true, the queue will pre-populate itself with sentinel objects and set its PriorityQueue{T}.Size() to size. In that case, you should not rely on PriorityQueue{T}.Size() to get the number of actual elements that were added to the queue, but keep track yourself.
NOTE: in case prePopulate is true, you should pop elements from the queue using the following code example:
 
override bool LessThan (ScoreDoc hitA, ScoreDoc hitB)
 

Detailed Description

Definition at line 24 of file HitQueue.cs.

Constructor & Destructor Documentation

Lucene.Net.Search.HitQueue.HitQueue ( int  size,
bool  prePopulate 
)

Creates a new instance with size elements. If prePopulate is set to true, the queue will pre-populate itself with sentinel objects and set its PriorityQueue{T}.Size() to size. In that case, you should not rely on PriorityQueue{T}.Size() to get the number of actual elements that were added to the queue, but keep track yourself.
NOTE: in case prePopulate is true, you should pop elements from the queue using the following code example:

PriorityQueue pq = new HitQueue(10, true); // pre-populate. ScoreDoc top = pq.top();

// Add/Update one element. top.score = 1.0f; top.doc = 0; top = (ScoreDoc) pq.updateTop(); int totalHits = 1;

// Now pop only the elements that were truly inserted. // First, pop all the sentinel elements (there are pq.size() - totalHits). for (int i = pq.size() - totalHits; i > 0; i–) pq.pop();

// Now pop the truly added elements. ScoreDoc[] results = new ScoreDoc[totalHits]; for (int i = totalHits - 1; i >= 0; i–) { results[i] = (ScoreDoc) pq.pop(); }

NOTE: This class pre-allocate a full array of length size.

Parameters
sizethe requested size of this queue.
prePopulatespecifies whether to pre-populate the queue with sentinel values.
See Also
SentinelObject

Definition at line 68 of file HitQueue.cs.

Member Function Documentation

override bool Lucene.Net.Search.HitQueue.LessThan ( ScoreDoc  hitA,
ScoreDoc  hitB 
)

Definition at line 87 of file HitQueue.cs.


The documentation for this class was generated from the following file: