FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
FIFE::PriorityQueue< index_type, priority_type > Class Template Reference

#include <priorityqueue.h>

Inheritance diagram for FIFE::PriorityQueue< index_type, priority_type >:
Inheritance graph
Collaboration diagram for FIFE::PriorityQueue< index_type, priority_type >:
Collaboration graph

Public Types

enum  Ordering { Ascending, Descending }
 

Public Member Functions

 PriorityQueue (void)
 
 PriorityQueue (const Ordering ordering)
 
void pushElement (const value_type &element)
 
void popElement (void)
 
bool changeElementPriority (const index_type &index, const priority_type &newPriority)
 
void clear (void)
 
const value_type getPriorityElement (void) const
 
bool empty (void) const
 
size_t size (void) const
 

Detailed Description

template<typename index_type, typename priority_type>
class FIFE::PriorityQueue< index_type, priority_type >

A pq which stores index-value pairs for elements.

This acts as a normal PQ but stores some extra information about the elements that it's storing, namely a special unique index.

Definition at line 36 of file priorityqueue.h.

Member Enumeration Documentation

template<typename index_type, typename priority_type>
enum FIFE::PriorityQueue::Ordering

Used for element ordering.

Enumerator
Ascending 

lowest priority first.

Descending 

highest priority first.

Definition at line 41 of file priorityqueue.h.

Constructor & Destructor Documentation

template<typename index_type, typename priority_type>
FIFE::PriorityQueue< index_type, priority_type >::PriorityQueue ( void  )
inline

Constructor

Definition at line 51 of file priorityqueue.h.

template<typename index_type, typename priority_type>
FIFE::PriorityQueue< index_type, priority_type >::PriorityQueue ( const Ordering  ordering)
inline

Constructor

Parameters
orderingThe ordering the priority queue should use.

Definition at line 58 of file priorityqueue.h.

Member Function Documentation

template<typename index_type, typename priority_type>
bool FIFE::PriorityQueue< index_type, priority_type >::changeElementPriority ( const index_type &  index,
const priority_type &  newPriority 
)

Changes the priority of an element.

Locates the element with the given index and changes it's priority to the given priority, it then re-orders the priority queue to take account of this new information.

Parameters
indexThe index of the element to change the priority of.
newPriorityThe new priority of the element.
Returns
True if the element could be found, false otherwise.

Definition at line 197 of file priorityqueue.h.

template<typename index_type , typename priority_type >
void FIFE::PriorityQueue< index_type, priority_type >::clear ( void  )

Removes all elements from the priority queue.

Definition at line 220 of file priorityqueue.h.

template<typename index_type, typename priority_type>
bool FIFE::PriorityQueue< index_type, priority_type >::empty ( void  ) const
inline

Determines whether the queue is currently empty.

Returns
true if it is empty, false otherwise.

Definition at line 111 of file priorityqueue.h.

Referenced by FIFE::PriorityQueue< int32_t, double >::getPriorityElement().

Here is the caller graph for this function:

template<typename index_type, typename priority_type>
const value_type FIFE::PriorityQueue< index_type, priority_type >::getPriorityElement ( void  ) const
inline

Retrieves the element with the highest priority.

This function will generate an assertion error if the pq is empty.

Returns
A const reference to the highest priority element.

Definition at line 99 of file priorityqueue.h.

template<typename index_type , typename priority_type >
void FIFE::PriorityQueue< index_type, priority_type >::popElement ( void  )

Pops the element with the highest priority from the queue.

Removes and deletes the highest priority element.

Definition at line 188 of file priorityqueue.h.

template<typename index_type , typename priority_type >
void FIFE::PriorityQueue< index_type, priority_type >::pushElement ( const value_type &  element)

Pushes a new element onto the queue.

The element is pushed onto the queue and then moved up the queue until it's in the correct position by priority.

Parameters
elementOf type value_type which contains both the index and the priority of the element.

Definition at line 178 of file priorityqueue.h.

template<typename index_type, typename priority_type>
size_t FIFE::PriorityQueue< index_type, priority_type >::size ( void  ) const
inline

Returns the current size of the queue.

Definition at line 118 of file priorityqueue.h.


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