CLucene - a full-featured, c++ search engine
API Documentation


lucene::util::PriorityQueue< _type, _valueDeletor > Class Template Reference

#include <PriorityQueue.h>

Inheritance diagram for lucene::util::PriorityQueue< _type, _valueDeletor >:
lucene::debug::LuceneBase

List of all members.

Public Member Functions

virtual ~PriorityQueue ()
void put (_type element)
 Adds an Object to a PriorityQueue in log(size) time.
bool insert (_type element)
 Adds element to the PriorityQueue in log(size) time if either the PriorityQueue is not full, or not lessThan(element, top()).
_type top ()
 Returns the least element of the PriorityQueue in constant time.
_type pop ()
 Removes and returns the least element of the PriorityQueue in log(size) time.
void adjustTop ()
 Should be called when the object at top changes values.
size_t size ()
 Returns the number of elements currently stored in the PriorityQueue.
void clear ()
 Removes all entries from the PriorityQueue.

Protected Member Functions

 PriorityQueue ()
virtual bool lessThan (_type a, _type b)=0
void initialize (const int32_t maxSize, bool deleteOnClear)

template<class _type, typename _valueDeletor>
class lucene::util::PriorityQueue< _type, _valueDeletor >


Constructor & Destructor Documentation

template<class _type, typename _valueDeletor>
lucene::util::PriorityQueue< _type, _valueDeletor >::PriorityQueue (  )  [inline, protected]
template<class _type, typename _valueDeletor>
virtual lucene::util::PriorityQueue< _type, _valueDeletor >::~PriorityQueue (  )  [inline, virtual]

Member Function Documentation

template<class _type, typename _valueDeletor>
void lucene::util::PriorityQueue< _type, _valueDeletor >::adjustTop (  )  [inline]

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.adjustTop(); }
		   

instead of

		    { o = pq.pop(); o.change(); pq.push(o); }
		   
template<class _type, typename _valueDeletor>
void lucene::util::PriorityQueue< _type, _valueDeletor >::clear (  )  [inline]

Removes all entries from the PriorityQueue.

template<class _type, typename _valueDeletor>
void lucene::util::PriorityQueue< _type, _valueDeletor >::initialize ( const int32_t  maxSize,
bool  deleteOnClear 
) [inline, protected]
template<class _type, typename _valueDeletor>
bool lucene::util::PriorityQueue< _type, _valueDeletor >::insert ( _type  element  )  [inline]

Adds element to the PriorityQueue in log(size) time if either the PriorityQueue is not full, or not lessThan(element, top()).

Parameters:
element 
Returns:
true if element is added, false otherwise.
template<class _type, typename _valueDeletor>
virtual bool lucene::util::PriorityQueue< _type, _valueDeletor >::lessThan ( _type  a,
_type  b 
) [protected, pure virtual]
template<class _type, typename _valueDeletor>
_type lucene::util::PriorityQueue< _type, _valueDeletor >::pop (  )  [inline]

Removes and returns the least element of the PriorityQueue in log(size) time.

template<class _type, typename _valueDeletor>
void lucene::util::PriorityQueue< _type, _valueDeletor >::put ( _type  element  )  [inline]

Adds an Object to a PriorityQueue in log(size) time.

If one tries to add more objects than maxSize from initialize a RuntimeException (ArrayIndexOutOfBound) is thrown.

template<class _type, typename _valueDeletor>
size_t lucene::util::PriorityQueue< _type, _valueDeletor >::size (  )  [inline]

Returns the number of elements currently stored in the PriorityQueue.

template<class _type, typename _valueDeletor>
_type lucene::util::PriorityQueue< _type, _valueDeletor >::top (  )  [inline]

Returns the least element of the PriorityQueue in constant time.


The documentation for this class was generated from the following file:

clucene.sourceforge.net