-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMynode.h
41 lines (36 loc) · 1.22 KB
/
Mynode.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
//
// Created by LSC on 2020/3/18.
//
#include <cstdint>
#include <string>
#ifndef PROJECT1_KVSTORE_MYNODE_H
#define PROJECT1_KVSTORE_MYNODE_H
#define QuadlistnodeP Quadlistnode*
struct Entry{
uint64_t key; std::string value;
Entry(){key=0;value="";}
Entry(uint64_t k , std::string v ) :key(k), value(v){}
Entry(const Entry& e) :key(e.key), value(e.value){}
bool operator<(const Entry& e) { return key < e.key; }
bool operator>(const Entry& e) { return key > e.key; }
bool operator==(const Entry& e) { return key == e.key; }
bool operator!=(const Entry& e) { return key != e.key; }
};
struct Quadlistnode{
Entry entry;
bool del;
QuadlistnodeP pred;
QuadlistnodeP succ;
QuadlistnodeP above;
QuadlistnodeP below;
Quadlistnode(Entry e=Entry(),QuadlistnodeP p= nullptr,QuadlistnodeP s=NULL,QuadlistnodeP a=NULL,QuadlistnodeP b=NULL,bool d= false):entry(e),pred(p),succ(s),above(a),below(b),del(d){}
QuadlistnodeP insertAsSuccAbove(Entry const& e, QuadlistnodeP b=NULL,bool d= false)
{
QuadlistnodeP x=new Quadlistnode(e,this,succ,nullptr,b,d);
succ->pred = x;
succ =x;
if(b) b->above =x;
return x;
}
};
#endif //PROJECT1_KVSTORE_MYNODE_H