This method can be overridden by extending classes to return a sentinel object which will be used by {@link #Initialize(int)} 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., {@link #LessThan(Object, Object)} should always favor the non-sentinel values).
By default, this method returns false, which means the queue will not be filled with sentinel values. Otherwise, the value returned will be used to pre-populate the queue. Adds sentinel values to the queue.
If this method is extended to return a non-null value, then the following usage pattern is recommended:
            // extends getSentinelObject() to return a non-null value.
            PriorityQueue pq = new MyQueue(numHits);
            // save the 'top' element, which is guaranteed to not be null.
            MyObject pqTop = (MyObject) pq.top();
            <...>
            // now in order to add a new element, which is 'better' than top (after 
            // you've verified it is better), it is as simple as:
            pqTop.change().
            pqTop = pq.updateTop();
            
NOTE: if this method returns a non-null value, it will be called by {@link #Initialize(int)} {@link #Size()} times, relying on a new object to be returned and will not check if it's null again. Therefore you should ensure any call to this method creates a new instance and behaves consistently, e.g., it cannot return null if it previously returned non-null.

Namespace: Lucene.Net.Util
Assembly: Lucene.Net (in Lucene.Net.dll) Version: 2.9.4.1

Syntax

C#
protected internal virtual Object GetSentinelObject()
Visual Basic
Protected Friend Overridable Function GetSentinelObject As Object
Visual C++
protected public:
virtual Object^ GetSentinelObject()

Return Value

the sentinel object to use to pre-populate the queue, or null if sentinel objects are not supported.

See Also