-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpriority_queue.h
More file actions
39 lines (32 loc) · 989 Bytes
/
Copy pathpriority_queue.h
File metadata and controls
39 lines (32 loc) · 989 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
#ifndef PRIORITY_QUEUE_H
#define PRIORITY_QUEUE_H
#include <iostream>
template <typename T>
class Priority_queue {
T* data = nullptr;
size_t _size = 0; // the number of elements
size_t _capacity = 0; // the number of elements that can be held in currently allocated storage
void resize(void);
void bottom_up_heapify(void);
void top_down_heapify(void);
size_t bigger_family_member(size_t parent_index);
public:
Priority_queue() = default;
~Priority_queue();
size_t size(void);
size_t capacity(void);
bool empty(void);
void clear(void);
void push(const T& elem);
T top(void);
T pop(void);
template <typename U>
friend std::ostream& operator<<(std::ostream& out, const Priority_queue<U>& v);
#ifdef TESTING
protected:
friend void test_bottom_up_heapify(void);
friend void test_top_down_heapify(void);
friend void test_bigger_family_member_method(void);
#endif // TESTING
};
#endif // PRIORITY_QUEUE_H