-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSkipList.hpp
More file actions
44 lines (35 loc) · 898 Bytes
/
SkipList.hpp
File metadata and controls
44 lines (35 loc) · 898 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
#ifndef SKIPLIST_H
#define SKIPLIST_H
#include <vector>
#include <string>
#include <random>
class Movie; // Forward declaration
class SkipListNode {
public:
Movie* movie;
std::vector<SkipListNode*> forward;
// Constructor
SkipListNode(Movie* movie, int level);
};
class SkipList {
private:
int maxLevel;
int count;
float probability;
SkipListNode* header;
std::mt19937 gen;
std::uniform_real_distribution<> dist;
// Helper methods
int randomLevel();
public:
// Constructor and Destructor
SkipList(int maxLevel, float probability);
~SkipList();
// SkipList operations
void insert(Movie* movie); //upone very insert count will be increased
Movie* search(const std::string& movieName);
void remove(const std::string& movieName);
int getsize();
std::vector<std::string>getAllNames();
};
#endif // SKIPLIST_H