This method can be overridden by extending classes to return a sentinel
object which will be used by the
PriorityQueue#PriorityQueue(int,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 should always favor the
non-sentinel values).
By default, this method returns null, 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<MyObject> pq = new MyQueue<MyObject>(numHits);
// save the 'top' element, which is guaranteed to not be null.
MyObject pqTop = 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
the
PriorityQueue#PriorityQueue(int,boolean) constructor
#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.