Class PriorityQueue<T>
A PriorityQueue<T> maintains a partial ordering of its elements such that the element with least priority can always be found in constant time. Put()'s and Pop()'s require log(size) time.
NOTE: this class will pre-allocate a full array of
length maxSize+1
if instantiated via the
PriorityQueue(Int32, Boolean) constructor with
prepopulate
set to true
. That maximum
size can grow as we insert elements over the time.
@lucene.internal
Inheritance
Assembly: DistributedLucene.Net.dll
Syntax
public abstract class PriorityQueue<T> : object
Type Parameters
Name | Description |
---|---|
T |
Constructors
Name | Description |
---|---|
PriorityQueue(Int32) | |
PriorityQueue(Int32, Boolean) |
Properties
Name | Description |
---|---|
Count | Returns the number of elements currently stored in the PriorityQueue<T>. NOTE: This was size() in Lucene. |
HeapArray | This method returns the internal heap array as T[]. @lucene.internal |
Top | Returns the least element of the PriorityQueue<T> in constant time.
Returns |
Methods
Name | Description |
---|---|
Add(T) | Adds an Object to a PriorityQueue<T> in log(size) time. If one tries to add
more objects than Lucene.Net.Util.PriorityQueue`1.maxSize from initialize and it is not possible to resize
the heap, an |
Clear() | Removes all entries from the PriorityQueue<T>. |
GetSentinelObject() | This method can be overridden by extending classes to return a sentinel object which will be used by the PriorityQueue(Int32, Boolean) constructor to fill the queue, so that the code which uses that queue can always assume it's full and only change the top without attempting to insert any new object. Those sentinel values should always compare worse than any non-sentinel value (i.e., LessThan(T, T) should always favor the non-sentinel values).
By default, this method returns If this method is extended to return a non-null value, then the following usage pattern is recommended:
NOTE: if this method returns a non- |
InsertWithOverflow(T) | Adds an Object to a PriorityQueue<T> in log(size) time.
It returns the object (if any) that was
dropped off the heap because it was full. This can be
the given parameter (in case it is smaller than the
full heap's minimum, and couldn't be added), or another
object that was previously the smallest value in the
heap and now has been replaced by a larger one, or |
LessThan(T, T) | Determines the ordering of objects in this priority queue. Subclasses must define this one method. |
Pop() | Removes and returns the least element of the PriorityQueue<T> in log(size) time. |
UpdateTop() | Should be called when the Object at top changes values. Still log(n) worst case, but it's at least twice as fast to
instead of
|