-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.h
62 lines (54 loc) · 799 Bytes
/
nodes.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
/*
* Node for Treap
* Contains integer data, two self references, priority
*/
class TreapNode
{
private:
TreapNode * left;
int data;
int priority;
TreapNode * right;
public:
TreapNode(int x, int p)
{
data = x;
priority = p;
left = right = nullptr;
}
friend class Treap;
};
/*
* Node for Queue
* Contains a reference to TreapNode, a self reference
*/
class QueueNode
{
private:
TreapNode * treapNode;
QueueNode * next;
public:
QueueNode(TreapNode * node)
{
treapNode = node;
next = nullptr;
}
friend class Queue;
};
/*
* Node for Stack
* Contains a reference to TreapNode, a self reference
*/
class StackNode
{
private:
TreapNode * treapNode;
StackNode * next;
public:
StackNode(TreapNode * node)
{
treapNode = node;
next = nullptr;
}
friend class Stack;
};