Boost logo

Boost :

From: AlisdairM - BTInternet (AlisdairM_at_[hidden])
Date: 2001-02-27 14:12:58


I beleive that way my proposal a few months back. It didn't seem to raise
much interest, so I let it drop, however I could be persuaded to try again
:¬ )

The essence of this kind of circular buffer is to have a fixed container,
but smarter iterators. The idea of 'wrapping' gets pushed into the
iterator.

There are several possibilities for the storage itself, std::vector and a
classic array are both quite natural. A vector would allow the buffer size
to be determined at run-time, a static array could take an integer template
paramater to determine array-size and would probably the the most efficient.

It turned out on the project that was driving my interest that the
bottleneck in performance had little to do with the buffers, I can happily
copy whole vectors without impacting performance so I focused effort on the
parts of the code that mattered more. However, I still intend to return to
this buffer scheme. If nothing else, not continually reallocating should
reduce memory fragmentation, should you be running for extended periods of
time.

AlisdairM

> From: boost_at_[hidden] [mailto:boost_at_[hidden]]
> Sent: 27 February 2001 18:49
> To: boost_at_[hidden]
> Subject: [boost] Re: circular_buffer?

> Basically, (as a hobby) I am writing yet another shoot-em-up game. The
> tried and true technique for managing bullets, ship thrust, bullet
> holes etc. is to have a "ring buffer" or
> "circular buffer" with a fixed maximum size.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk