-
Notifications
You must be signed in to change notification settings - Fork 0
/
SkipList.h
64 lines (46 loc) · 2.23 KB
/
SkipList.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
63
64
#ifndef SKIP_LIST_H_
#define SKIP_LIST_H_
#include <iostream>
#include <string>
#include <stdlib.h>
#include <time.h>
#include "Date.h"
#include "CitizenList.h"
#define MAX_HEIGHT 10
typedef struct SkipNode{
int citizenID;
struct CitizenNode* citNode;
struct SkipNode** next;
}SkipNode;
class SkipList{
private:
struct SkipNode* listHead;
int maxHeight; /* max depth of the skip list */
public:
/* Accessors */
int getMaxHeight() const{ return maxHeight;}
SkipNode* getSkipListHead() const{ return listHead;}
SkipList(int maxLevel); /* Skip List Constructor */
~SkipList(); /* Skip List Destructor */
/* Insert an element in the Skip List */
SkipNode* SkipListInsert(int id, CitizenNode* head);
/* Return 1 if the element is in the list or 0 if it's not */
int SkipListSearch(int key, CitizenNode** cit = NULL);
/* Delete the node with citizenId == "key", if it exists in the skip list */
int SkipListRemove(int key);
/* Returns a random level to insert the element from index [0 - (MAX_HEIGHT - 1)] */
int getRandomLevel();
/* Print all the nodes on a specific level in the skip list */
void SkipLevelPrint(int level = 0);
/* Count the elements of a specific level in the skip list */
int SkipListCount(int level = 0);
/* Get a 50 - 50 chanche (heads or tails) */
int CoinFlip();
/* Used for command 4 */
void SkipPopulationStatus(Date date1, Date date2, int countriesNum, struct VirusNode* vn, CitizenNode* head); /* if there is no argument country given */
void SkipPopulationStatus(Date date1, Date date2, struct VirusNode* vn, string country, CitizenNode* head); /* With argument country given */
/* Used for command 5 */
void SkipPopStatusByAge(Date date1, Date date2, int countriesNum, struct VirusNode* vn, CitizenNode* head); /* if there is no argument country given */
void SkipPopStatusByAge(Date date1, Date date2, struct VirusNode* vn, string country, CitizenNode* head); /* With argument country given */
};
#endif /* SKIP_LIST_H_ */