-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode.cpp
62 lines (51 loc) · 926 Bytes
/
node.cpp
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
/**
One single Node in the Skip list and its properties
*/
#include "node.h"
/**
Constructors
*/
Node::Node(){
}
Node::Node(int key, int level){
key_value_pair = KeyValuePair(key, "");
next.resize(level + 1);
for (size_t i = 0; i < next.size(); i++){
next[i] = NULL;
}
top_level = level;
}
Node::Node(int key, string value, int level){
key_value_pair = KeyValuePair(key, value);
next.resize(level + 1);
for (size_t i = 0; i < next.size(); i++){
next[i] = NULL;
}
top_level = level;
}
/**
Returns the key in the node
*/
int Node::get_key(){
return key_value_pair.get_key();
}
/**
Returns the value in the node
*/
string Node::get_value(){
return key_value_pair.get_value();
}
/**
Locks the node
*/
void Node::lock(){
node_lock.lock();
}
/**
Unlocks the node
*/
void Node::unlock(){
node_lock.unlock();
}
Node::~Node(){
}