-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvQue.cpp
More file actions
62 lines (51 loc) · 827 Bytes
/
Copy pathEvQue.cpp
File metadata and controls
62 lines (51 loc) · 827 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* EvQue.cpp
*
* Created on: Jul 9, 2015
* Author: OS1
*/
#include <stdlib.h>
#include "EvQue.h"
class KernelEv;
EvQue:: EvQue() {
head=NULL;
}
EvQue:: ~EvQue() {
Elem* prev;
while (head) {
prev=head;
head=head->next;
delete prev;
}
}
void EvQue:: put(KernelEv* kerev) {
if(head==0) {
head= new Elem(kerev);
return;
}
Elem* cur=head;
Elem* prev=0;
while (cur) {
if (cur->kerev==kerev)
return;
prev=cur;
cur=cur->next;
}
prev->next= new Elem(kerev);
}
void EvQue:: remove(KernelEv* kernev) {
if(head==0) return;
Elem* prev=0;
Elem* cur=head;
while (cur) {
if(cur->kerev==kernev) break;
prev=cur;
cur=cur->next;
}
if(cur==0) return;
if(prev==0)
head=0;
else
prev->next=cur->next;
delete cur;
}