-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode.h
35 lines (28 loc) · 954 Bytes
/
node.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
#include <vector>
#include <mutex>
#include <thread>
#include <atomic>
#include "key_value_pair.h"
class Node{
public:
// Stores the key and value for the Node
KeyValuePair key_value_pair;
// Stores the reference of the next node until the top level for the node
vector<Node*> next;
// Lock to lock the node when modifing it
mutex node_lock;
// Atomic variable to be marked if this Node is being deleted
atomic<bool> marked = {false};
// Atomic variable to indicate the Node is completely linked to predecessors and successors
atomic<bool> fully_linked = {false};
// The Maximum level until which the node is available
int top_level;
Node();
Node(int key, int level);
Node(int key, string value, int level);
~Node();
int get_key();
string get_value();
void lock();
void unlock();
};