-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalendar.cpp
More file actions
63 lines (57 loc) · 973 Bytes
/
calendar.cpp
File metadata and controls
63 lines (57 loc) · 973 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
/* -*- C++ -*- */
/*******************************************************
CALENDAR C
*******************************************************/
#include "global.h"
#include "calendar.h"
event* calendar::get(){
if(head==NULL)
return NULL;
event* ev;
if(head==last){
ev=head;
head=NULL;
last=NULL;
return ev;
}
ev=head;
head=head->next;
last->next=head;
return ev;
}
void calendar::put(event* New){
event* temp=head;
if(head==NULL){
head=New;
head->next=New;
last=New;
}
else if (New->time<head->time){
New->next=head;
head=New;
last->next=head;
}
else if (last==head){
if(New->time<head->time){
head=New;
head->next=last;
last->next=head;
}
else {
last=New;
head->next=last;
last->next=head;
}
}
else if (last->time<New->time){
last->next=New;
last=New;
last->next=head;
}
else {
while(temp->next->time < New->time)
temp=temp->next;
New->next=temp->next;
temp->next=New;
}
}