-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyb_example.p
65 lines (53 loc) · 959 Bytes
/
pyb_example.p
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
import list
typedef struct list list
typedef struct listNode listNode
// 构造一个具体的listNode
listNode * makeNode(int val)
{
listNode * node = createListNode()
node->value = malloc(sizeof(int))
*(int *(node->value)) = val // 大小一致,直接转换
return node
}
list makeList()
{
int compare(void * a, void * b)
{
int av = *(int *(a))
int bv = *(int *(b))
if (av < bv) return -1
if (av > bv) return 1
return 0
}
struct list l = createList()
l.match = compare
return l
}
void example()
{
list l = makeList()
int i = 100
void opera(list * l,listNode * node){}
opera = insertSortedList
opera(&l,makeNode(-1))
opera(&l,makeNode(1))
opera(&l,makeNode(-20))
opera(&l,makeNode(100))
listNode * cur = l.head->next
while(cur != NULL)
{
write *(cur->value)
cur = cur->next
}
l.self__removeList2(&i)
cur = l.head->next
while(cur != NULL)
{
write *(cur->value)
cur = cur->next
}
}
void main()
{
example()
}