-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_tools.c
80 lines (69 loc) · 1.72 KB
/
test_tools.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
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
70
71
72
73
74
75
76
77
78
79
80
//
// Created by tong on 19-4-4.
//
#include <stdio.h>
#include <malloc.h>
#include "wco_tools.h"
int main(){
// 测试WcoQueue
WcoQueue *q = WcoQueueCreate();
WcoQueuePush(q, 0);
WcoQueuePush(q, 1);
WcoQueuePush(q, 2);
printf("%ld\n", (long)WcoQueuePop(q));
printf("%ld\n", (long)WcoQueuePop(q));
WcoQueuePush(q, 3);
WcoQueuePush(q, 4);
while(!WcoQueueEmpty(q)){
printf("%ld\n", (long)WcoQueuePop(q));
}
WcoQueueDestroy(q);
printf("\n");
// 测试
WcoHeapNode *n;
n = malloc(sizeof(WcoHeapNode));
WcoBigRootHeap *h = WcoHeapCreate();
n = malloc(sizeof(WcoHeapNode));
n->time = 4;
WcoHeapPush(h, n);
n = malloc(sizeof(WcoHeapNode));
n->time = 3;
WcoHeapPush(h, n);
n = malloc(sizeof(WcoHeapNode));
n->time = 9;
WcoHeapPush(h, n);
n = malloc(sizeof(WcoHeapNode));
n->time = 6;
WcoHeapPush(h, n);
printf("%ld\n", WcoHeapTop(h)->time);
WcoHeapPop(h);
printf("%ld\n", WcoHeapTop(h)->time);
WcoHeapPop(h);
printf("%ld\n", WcoHeapTop(h)->time);
WcoHeapPop(h);
printf("%ld\n", WcoHeapTop(h)->time);
n = malloc(sizeof(WcoHeapNode));
n->time = 3;
WcoHeapPush(h, n);
n = malloc(sizeof(WcoHeapNode));
n->time = 8;
WcoHeapPush(h, n);
n = malloc(sizeof(WcoHeapNode));
n->time = 7;
WcoHeapPush(h, n);
while(!WcoHeapEmpty(h)){
printf("%ld\n", WcoHeapTop(h)->time);
WcoHeapPop(h);
}
for(int i=0; i<100; i++){
n = malloc(sizeof(WcoHeapNode));
n->time = i;
WcoHeapPush(h, n);
}
while(!WcoHeapEmpty(h)){
printf("%ld\n", WcoHeapTop(h)->time);
WcoHeapPop(h);
}
WcoHeapDestroy(h);
return 0;
}