-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpriority_queue.h
More file actions
47 lines (35 loc) · 794 Bytes
/
priority_queue.h
File metadata and controls
47 lines (35 loc) · 794 Bytes
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
//
// Created by codercat on 19-6-14.
//
#ifndef CPP_ALGORITHMS_PRIORITY_QUEUE_H
#define CPP_ALGORITHMS_PRIORITY_QUEUE_H
#include "binary_heap.h"
template<typename E>
class PriorityQueue {
private:
BinaryHeap<E> *maxHeap;
public:
PriorityQueue(unsigned capacity) {
assert(capacity > 0);
this->maxHeap = new BinaryHeap<E>(capacity);
}
void enqueue(E e) {
return maxHeap->insert(e);
}
E dequeue() {
return maxHeap->extract();
}
bool isEmpty() {
return maxHeap->isEmpty();
}
bool isFull() {
return maxHeap->isFull();
}
E getFront() {
return maxHeap->getRoot();
}
unsigned int getSize() {
return maxHeap->getSize();
}
};
#endif //CPP_ALGORITHMS_PRIORITY_QUEUE_H