-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPriorityQueue.h
More file actions
51 lines (41 loc) · 1.52 KB
/
PriorityQueue.h
File metadata and controls
51 lines (41 loc) · 1.52 KB
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
49
50
51
#ifndef PRIORITYQUEUE_H
#define PRIORITYQUEUE_H
#include <iostream>
#include "Share.h"
using namespace std;
class PriorityQueue
{
public:
private:
// Sequential representation of the priority queue.
Share* heap_;
// Total number of elements that the priority queue can store.
unsigned int capacity_;
// Current number of elements in the priority queue.
unsigned int size_;
// Override copy constructor and assignment operator in private so we can't
// use them.
PriorityQueue(const PriorityQueue& other) {}
PriorityQueue& operator=(const PriorityQueue& other) {}
public:
// Constructor initializes heap_ to an array of (capacity_ + 1) size, so
// that there are at most capacity_ elements in the priority queue.
PriorityQueue(unsigned int capacity);
// Destructor of the class PriorityQueue. It deallocates the memory space
// allocated for the priority queue.
~PriorityQueue();
// Returns the number of elements in the priority queue.
unsigned int size() const;
// Returns true if the priority queue is empty, and false otherwise.
bool empty() const;
// Returns true if the priority queue is full, and false otherwise.
bool full() const;
// Returns the max element of the priority queue, but does not remove it.
Share max() const;
// Inserts value into the priority queue.
void enqueue(Share val);
// Removes the top element with the maximum value (priority) and rearranges
// the resulting heap.
void dequeue();
};
#endif