From 8c2c728ce5aa1c1941426d0f8e9ab27762ef6754 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 5 Jun 2007 18:46:01 +0000 Subject: Added a basic ringbuffer, it should be nice and quick, but may be bad to use with objects at the moment, still contemplating that one... --- src/tests/ringbuffer.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/tests/ringbuffer.cpp (limited to 'src/tests/ringbuffer.cpp') diff --git a/src/tests/ringbuffer.cpp b/src/tests/ringbuffer.cpp new file mode 100644 index 0000000..259ec1f --- /dev/null +++ b/src/tests/ringbuffer.cpp @@ -0,0 +1,29 @@ +#include "bu/ringbuffer.h" +#include + +int main() +{ + Bu::RingBuffer 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() ); + } + } +} + -- cgit v1.2.3