-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpqueue-vector.h
48 lines (38 loc) · 1.06 KB
/
pqueue-vector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**********************************************
* File: pqueue-vector.h
*
* A priority queue class backed by an unsorted
* vector.
*/
#ifndef PQueue_Vector_Included
#define PQueue_Vector_Included
#include <string>
#include "vector.h"
using namespace std;
/* A class representing a priority queue backed by an
* unsorted Vector.
*/
class VectorPriorityQueue {
public:
/* Constructs a new, empty priority queue backed by a vector. */
VectorPriorityQueue();
/* Cleans up all memory allocated by this priority queue. */
~VectorPriorityQueue();
/* Returns the number of elements in the priority queue. */
int size();
/* Returns whether or not the priority queue is empty. */
bool isEmpty();
/* Enqueues a new string into the priority queue. */
void enqueue(string value);
/* Returns, but does not remove, the lexicographically first string in the
* priority queue.
*/
string peek();
/* Returns and removes the lexicographically first string in the
* priority queue.
*/
string dequeueMin();
private:
Vector<string> priorityQueue;
};
#endif