-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCursorList.cpp
More file actions
48 lines (38 loc) · 1.28 KB
/
TestCursorList.cpp
File metadata and controls
48 lines (38 loc) · 1.28 KB
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
#include <iostream.h>
#include "CursorList.h"
// Simple print method
template <class Object>
void printList( const List<Object> & theList )
{
if( theList.isEmpty( ) )
cout << "Empty list" << endl;
else
{
ListItr<Object> itr = theList.first( );
for( ; !itr.isPastEnd( ); itr.advance( ) )
cout << itr.retrieve( ) << " ";
}
cout << endl;
}
vector<List<int>::CursorNode> List<int>::cursorSpace;
int main( )
{
List<int> theList;
ListItr<int> theItr = theList.zeroth( );
int i;
printList( theList );
for( i = 0; i < 10; i++ )
{
theList.insert( i, theItr );
printList( theList );
theItr.advance( );
}
for( i = 0; i < 10; i += 2 )
theList.remove( i );
for( i = 0; i < 10; i++ )
if( ( i % 2 == 0 ) != ( theList.find( i ).isPastEnd( ) ) )
cout << "Find fails!" << endl;
cout << "Finished deletions" << endl;
printList( theList );
return 0;
}