aboutsummaryrefslogtreecommitdiff
path: root/src/tests/ringbuffer.cpp
blob: 9489b304a9d2b443f5263aab5f2b107ee1814549 (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
/*
 * Copyright (C) 2007-2008 Xagasoft, All rights reserved.
 *
 * This file is part of the libbu++ library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#include "bu/ringbuffer.h"
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

int main()
{
	Bu::RingBuffer<uint32_t> ibuf( 10 );

	for( int k = 0; k < 2; k++ )
	{
		int j = 1;
		for(; j < 7; j++ )
		{
			ibuf.enqueue( j );
		}

		for(; j < 20; j++ )
		{
			ibuf.enqueue( j );
			printf("- %d\n", ibuf.dequeue() );
		}

		for(;;)
		{
			if( ibuf.isEmpty() ) break;
			printf(". %d\n", ibuf.dequeue() );
		}
	}
}