com.browseengine.bobo.sort
Class DocIDPriorityQueue

java.lang.Object
  extended by com.browseengine.bobo.sort.DocIDPriorityQueue

public class DocIDPriorityQueue
extends Object


Field Summary
 int base
           
protected  org.apache.lucene.search.ScoreDoc[] heap
           
 int size
           
 
Constructor Summary
DocIDPriorityQueue(DocComparator comparator, int maxSize, int base)
           
 
Method Summary
 org.apache.lucene.search.ScoreDoc add(org.apache.lucene.search.ScoreDoc element)
          Adds an Object to a PriorityQueue in log(size) time.
 void clear()
          Removes all entries from the PriorityQueue.
 org.apache.lucene.search.ScoreDoc pop()
          Removes and returns the least element of the PriorityQueue in log(size) time.
 org.apache.lucene.search.ScoreDoc replace(org.apache.lucene.search.ScoreDoc element)
           
 org.apache.lucene.search.ScoreDoc replace(org.apache.lucene.search.ScoreDoc newEle, org.apache.lucene.search.ScoreDoc oldEle)
          Takes O(size) time.
 int size()
          Returns the number of elements currently stored in the PriorityQueue.
 Comparable<?> sortValue(org.apache.lucene.search.ScoreDoc doc)
           
 org.apache.lucene.search.ScoreDoc top()
          Returns the least element of the PriorityQueue in constant time.
 org.apache.lucene.search.ScoreDoc updateTop()
          Should be called when the Object at top changes values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

public int size

heap

protected final org.apache.lucene.search.ScoreDoc[] heap

base

public final int base
Constructor Detail

DocIDPriorityQueue

public DocIDPriorityQueue(DocComparator comparator,
                          int maxSize,
                          int base)
Method Detail

add

public final org.apache.lucene.search.ScoreDoc add(org.apache.lucene.search.ScoreDoc element)
Adds an Object to a PriorityQueue in log(size) time. If one tries to add more objects than maxSize from initialize an ArrayIndexOutOfBoundsException is thrown.

Returns:
the new 'bottom' element in the queue.

sortValue

public Comparable<?> sortValue(org.apache.lucene.search.ScoreDoc doc)

replace

public org.apache.lucene.search.ScoreDoc replace(org.apache.lucene.search.ScoreDoc element)

replace

public org.apache.lucene.search.ScoreDoc replace(org.apache.lucene.search.ScoreDoc newEle,
                                                 org.apache.lucene.search.ScoreDoc oldEle)
Takes O(size) time.

Returns:
the 'bottom' element in the queue.

top

public final org.apache.lucene.search.ScoreDoc top()
Returns the least element of the PriorityQueue in constant time.


pop

public final org.apache.lucene.search.ScoreDoc pop()
Removes and returns the least element of the PriorityQueue in log(size) time.


updateTop

public final org.apache.lucene.search.ScoreDoc 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
 pq.top().change();
 pq.updateTop();
 
instead of
 o = pq.pop();
 o.change();
 pq.push(o);
 

Returns:
the new 'top' element.

size

public final int size()
Returns the number of elements currently stored in the PriorityQueue.


clear

public final void clear()
Removes all entries from the PriorityQueue.



Copyright © 2011. All Rights Reserved.