-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht_skiplists.cpp
69 lines (49 loc) · 1.21 KB
/
t_skiplists.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
63
64
65
66
67
68
69
#include <iostream>
#include "skiplists.hpp"
using namespace std;
int main(int argc, char* argv[])
{
SkipLists<int, int> skip_list;
cout << "insert (1,2)" << endl;
bool r = skip_list.insert(1,2);
if (!r) {
cout << "Insertion Failure!" << endl;
}
cout << "insert (3,4)" << endl;
r = skip_list.insert(3, 4);
if (!r) {
cout << "Insertion Failure!" << endl;
}
cout << "insert (5,6)" << endl;
r = skip_list.insert(5, 6);
if (!r) {
cout << "Insertion Failure!" << endl;
}
skip_list.print();
int v = -1;
r = skip_list.find(1, v);
assert(v == 2);
r = skip_list.find(3, v);
assert(v == 4);
r = skip_list.find(5, v);
assert(v == 6);
cout << "delete key:1" << endl;
r = skip_list.remove(1);
if (!r) {
cout << "Deletion failure.." << endl;
}
skip_list.print();
cout << "delete key:3" << endl;
r = skip_list.remove(3);
if (!r) {
cout << "Deletion failure.." << endl;
}
skip_list.print();
cout << "delete key:5" << endl;
r = skip_list.remove(5);
if (!r) {
cout << "Deletion failure.." << endl;
}
skip_list.print();
return 0;
}