-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventq.h
63 lines (49 loc) · 1.3 KB
/
eventq.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*==========================================================================
eventq.h CSC 790 Project 2, E. W. Fulp 10/10/2017
Event queue, models calendar of events.
============================================================================*/
#ifndef EVENTQUEUE
#define EVENTQUEUE
#include <queue>
#include <cassert>
#include "event.h"
using namespace std;
class EventQueue
{
public:
//-null constructor-------------------------------------
EventQueue():length_(0)
{ }
//-isEmpty----------------------------------------------
int isEmpty()
{ return (length_ == 0); }
//-length-----------------------------------------------
long int length() const
{ return length_; }
//-insert-----------------------------------------------
void insert(const EventType& e)
{
length_++;
queue_.push(e);
}
//-remove-----------------------------------------------
EventType remove()
{
assert(length_);
EventType temp = queue_.top();
length_--;
queue_.pop();
return temp;
}
//-nextEvent--------------------------------------------
EventType nextEvent()
{
assert(length_);
return queue_.top();
}
//-data members-----------------------------------------
private:
priority_queue<EventType, vector<EventType>, eventComparison> queue_;
long int length_;
};
#endif