small text    normal text    large text
EVE-Online - New Universe, New Rules
NO2ID - Stop ID cards and the database state

You are here: home > resources > circularbuffer

Circular Buffer

[download] [support]

description

A C++ template class that implements a circular buffer of any data type. A circular buffer consists of a fixed buffer that has two independent pointers, one for reading data from the buffer, the other for writing data to the buffer. It can be thought of as a queue, in that data that is first written into the buffer is first read out, albeit with a fixed size.

declaration

template< class TYPE, DWORD MAX_ITEMS, bool COPYEACH = false >
class CCircularBuffer

usage

#include "CircularBuffer.h"

To declare a circular buffer, use something like:

CCircularBuffer< double, 100 > buffer;

The third, optional, parameter (COPYEACH) is used to control the method used when copying items to and from the buffer. If false (the default) is specified, then items are copied using the C runtime memcpy function. It is important to note that this will not work for classes and structures that have a copy constructor to duplicate data, for example character strings where using memcpy will simply copy the pointer without duplicating the actual string. If this is not intended, then setting the third parameter to true will copy each item in turn without performing a memcpy. Obviously this has performance implications and should only be used whenever necessary.

compatibility

Developed using Microsoft Visual C++ 6.0; ANSI-compatible.

licence

The source code contains the following statement: "This source code may be used, modified, compiled, duplicated, and/or distributed without restriction provided this copyright notice remains intact. Cyotec Systems Limited and/or its employees cannot be held responsible for any direct or indirect damage or loss of any kind that may result from using this code, and provides no warranty, guarantee, or support." By downloading the source code you automatically agree to these licence terms.

current release

Version 1.0.2 - 7th October 2004

download

Download the CircularBuffer source code here (4 KB)

MD5 hash: 25A010117CBBB295D37B2377576CDA79
SHA1 hash: 3F8550FCD8D768F23F17A1AA2743466832990827

Copyright © Cyotec Systems, 2003-2008. All rights reserved.