-
Notifications
You must be signed in to change notification settings - Fork 2
/
t.c
32 lines (29 loc) · 835 Bytes
/
t.c
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
#include <stdio.h>
#include "skiplist.h"
int getNodeLevel(skiplistNode* forwards[]) {
return sizeof(forwards) / sizeof(forwards[0]);
}
void printSkipListNode(int value) {
printf("node value:%d\n", value);
}
int main(int argc, char** srgv) {
skiplist* l = skiplistCreate();
if (NULL == l) {
fprintf(stderr, "create skiplist error\n");
return -1;
}
skiplistNode* node = NULL;
int i;
for (i=0; i<20; i++) {
skiplistInsert(l, i, i*2);
}
printSkipListNode(skiplistSearch(l, 10));
printSkipListNode(skiplistSearch(l, 5));
printSkipListNode(skiplistSearch(l, 15));
printSkipListNode(skiplistSearch(l, 16));
printSkipListNode(skiplistSearch(l, 17));
skiplistDelete(l, 11);
printSkipListNode(skiplistSearch(l, 11));
skiplistFree(l);
return 0;
}