Newer
Older
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
#ifndef EECS281_PQ_H
#define EECS281_PQ_H
#include <functional>
#include <iterator>
#include <vector>
//A simple interface that implements a generic priority_queue.
//Runtime specifications assume constant time comparison and copying.
template<typename TYPE, typename COMP_FUNCTOR = std::less<TYPE>>
class Eecs281PQ {
public:
typedef unsigned size_type;
virtual ~Eecs281PQ() {}
//Description: Add a new element to the priority_queue.
virtual void push(const TYPE& val) = 0;
//Description: Remove the most extreme (defined by 'compare') element from
// the priority_queue.
//Note: We will not run tests on your code that would require it to pop an
//element when the priority_queue is empty. Though you are welcome to if you are
//familiar with them, you do not need to use exceptions in this project.
virtual void pop() = 0;
//Description: Return the most extreme (defined by 'compare') element of
// the priority_queue.
virtual const TYPE& top() const = 0;
//Description: Get the number of elements in the priority_queue.
virtual size_type size() const = 0;
//Description: Return true if the priority_queue is empty.
virtual bool empty() const = 0;
protected:
//Note: These data members *must* be used in all of your priority_queue
// implementations.
//You can use this in the derived classes with:
//this->compare(Thing1, Thing2)
//With the default compare function (std::less), this will
//tell you if Thing1 is less than Thing2.
COMP_FUNCTOR compare;
};
#endif