FIFE
2008.0
|
#include <priorityqueue.h>
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 |
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.
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.
|
inline |
Constructor
Definition at line 51 of file priorityqueue.h.
|
inline |
Constructor
ordering | The ordering the priority queue should use. |
Definition at line 58 of file priorityqueue.h.
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.
index | The index of the element to change the priority of. |
newPriority | The new priority of the element. |
Definition at line 197 of file priorityqueue.h.
void FIFE::PriorityQueue< index_type, priority_type >::clear | ( | void | ) |
Removes all elements from the priority queue.
Definition at line 220 of file priorityqueue.h.
|
inline |
Determines whether the queue is currently empty.
Definition at line 111 of file priorityqueue.h.
Referenced by FIFE::PriorityQueue< int32_t, double >::getPriorityElement().
|
inline |
Retrieves the element with the highest priority.
This function will generate an assertion error if the pq is empty.
Definition at line 99 of file priorityqueue.h.
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.
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.
element | Of type value_type which contains both the index and the priority of the element. |
Definition at line 178 of file priorityqueue.h.
|
inline |
Returns the current size of the queue.
Definition at line 118 of file priorityqueue.h.