aboutsummaryrefslogtreecommitdiff
path: root/src/tests/list.cpp
blob: 12807a551fa590467a88b66e723129f6602d9a13 (plain)
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
#include "bu/list.h"
#include <list>

typedef struct Bob
{
	int nID;
} Bob;

int main()
{
	Bu::List<int> l;

	l.append( 0 );

	for( int j = 3; j <= 21; j += 3 )
	{
		l.append( j );
		l.prepend( -j );
	}

	for( Bu::List<int>::iterator i = l.begin(); i != l.end(); i++ )
	{
		printf("%d ", *i );
	}
	printf("\n");
	for( Bu::List<int>::iterator i = l.begin(); i != l.end(); i++ )
	{
		l.erase( i );
		if( i != l.end() )
			printf("%d ", *i );
	}

	printf("\n\n");

	Bu::List<Bob> lb;
	for( int j = 0; j < 10; j++ )
	{
		Bob b;
		b.nID = j;
		lb.append( b );
	}

	const Bu::List<Bob> rb = lb;

	for( Bu::List<Bob>::const_iterator i = rb.begin(); i != rb.end(); i++ )
	{
		//i->nID += 2;
		//(*i).nID = 4;
		printf("%d ", i->nID );
	}
	printf("\n\n");
}