-
Notifications
You must be signed in to change notification settings - Fork 4
/
testlist.c
52 lines (42 loc) · 857 Bytes
/
testlist.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
#include <stdio.h>
#include "list.h"
void
PrintList( const List L )
{
Position P = Header( L );
if( IsEmpty( L ) )
printf( "Empty list\n" );
else
{
do
{
P = Advance( P );
printf( "%d ", Retrieve( P ) );
} while( !IsLast( P, L ) );
printf( "\n" );
}
}
main( )
{
List L;
Position P;
int i;
L = MakeEmpty( NULL );
P = Header( L );
PrintList( L );
for( i = 0; i < 10; i++ )
{
Insert( i, L, P );
PrintList( L );
P = Advance( P );
}
for( i = 0; i < 10; i+= 2 )
Delete( i, L );
for( i = 0; i < 10; i++ )
if( ( i % 2 == 0 ) == ( Find( i, L ) != NULL ) )
printf( "Find fails\n" );
printf( "Finished deletions\n" );
PrintList( L );
DeleteList( L );
return 0;
}