SimpleCxxLib
packageclass PriorityQueue<ValueType>
Constructor | |
Initializes a new priority queue, which is initially empty. | |
Methods | |
Returns the last value in the queue by reference. | |
Removes all elements from the priority queue. | |
Removes and returns the highest priority value. | |
Adds value to the queue with the specified priority. | |
Returns the first value in the queue by reference. | |
Returns true if the priority queue contains no elements. | |
Returns the value of highest priority in the queue, without removing it. | |
Returns the priority of the first element in the queue, without removing it. | |
Returns the number of values in the priority queue. | |
Converts the queue to a printable string representation. |
PriorityQueue();
Usage:
PriorityQueue<ValueType> pq;
int size() const;
Usage:
int n = pq.size();
bool isEmpty() const;
true
if the priority queue contains no elements.
Usage:
if (pq.isEmpty()) ...
void clear();
Usage:
pq.clear();
void enqueue(ValueType value, double priority);
value
to the queue with the specified priority.
Lower priority numbers correspond to higher priorities, which
means that all priority 1 elements are dequeued before any
priority 2 elements.
Usage:
pq.enqueue(value, priority);
ValueType dequeue();
Usage:
ValueType first = pq.dequeue();
ValueType peek() const;
Usage:
ValueType first = pq.peek();
double peekPriority() const;
Usage:
double priority = pq.peekPriority();
ValueType & front();
Usage:
ValueType first = pq.front();
ValueType & back();
Usage:
ValueType last = pq.back();
string toString();
Usage:
string str = pq.toString();