-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdll-1-0.c
44 lines (42 loc) · 1020 Bytes
/
dll-1-0.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
#include <stdio.h>
#include <stdlib.h>
#include "dll.h"
#include "integer.h"
extern void srandom(unsigned int);
extern long int random(void);
int
main(void)
{
srandom(1001);
DLL *p = newDLL(displayINTEGER,freeINTEGER);
insertDLL(p,0,newINTEGER(3));
insertDLL(p,sizeDLL(p),newINTEGER(2));
displayDLL(p,stdout);
printf("\n");
freeINTEGER(removeDLL(p,1));
displayDLL(p,stdout);
printf("\n");
freeINTEGER(removeDLL(p,0));
displayDLL(p,stdout);
printf("\n");
DLL *q = newDLL(displayINTEGER,freeINTEGER);
insertDLL(p,0,newINTEGER(6));
insertDLL(p,0,newINTEGER(7));
insertDLL(q,0,newINTEGER(4));
insertDLL(q,0,newINTEGER(5));
displayDLL(p,stdout);
printf("\n");
displayDLL(q,stdout);
printf("\n");
unionDLL(p,q);
displayDLL(p,stdout);
displayDLL(q,stdout);
printf("\n");
displayDLLdebug(p,stdout);
printf("\n");
displayDLLdebug(q,stdout);
printf("\n");
freeDLL(p);
freeDLL(q);
return 0;
}