Creates a new instance with elements. If
is set to true, the queue will pre-populate itself
with sentinel objects and set its {@link #Size()} to . In
that case, you should not rely on {@link #Size()} to get the number of
actual elements that were added to the queue, but keep track yourself.
NOTE: in case is true, you should pop
elements from the queue using the following code example:
.
Namespace: Lucene.Net.SearchCopyC#
size
CopyC#
prePopulate
CopyC#
size
NOTE: in case
CopyC#
prePopulate
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
CopyC#
size
Assembly: Lucene.Net (in Lucene.Net.dll) Version: 2.9.4.1
Syntax
C# |
---|
public HitQueue( int size, bool prePopulate ) |
Visual Basic |
---|
Public Sub New ( _ size As Integer, _ prePopulate As Boolean _ ) |
Visual C++ |
---|
public: HitQueue( int size, bool prePopulate ) |
Parameters
- size
- Type: System..::..Int32
the requested size of this queue.
- prePopulate
- Type: System..::..Boolean
specifies whether to pre-populate the queue with sentinel values.