From: Nigel Stewart (nigels_at_[hidden])
Date: 2003-06-09 05:41:27
>> So the issue here seems to be whether a cyclic_buffer
>> should be circular-list-like or FIFO-like.
> I designed the cyclic_buffer mainly for adding the elements at the end of the
> container and automatic removal of elements from the beginning - it is just plain
> FIFO, nothing else.
(Please excuse the tone here if it sounds too officious,
just intending to be precise...)
Therefore, here is the case for extending the proposed
- Rename to circular_buffer
Relate the container more closely to the concept of
a circular list. The proposed cyclic_buffer appears
to support a subset of circular_buffer interface
- Add push_front() and pop_front()
For the purpose of generality, allow manipulation of
the container at both ends of the buffer, rather than
pushing to the back and popping from the front.
front() is already included in the interface.
This would allow use as a LIFO (last-in, last-out)
with fixed sized "event horizon". (As an example.)
- resize() to behave similarly to vector::resize()
Inserts or erases elements at the end such that
the size becomes n. (Applications not concerned
with underlying capacity management need not
explicitly reserve capacity for a particular
desired size: principle of "minimal surprise".)
Semantics of reducing the size of a circular_buffer:
follow std::vector and keep only first n items.
- change_capacity() becomes reserve()
For consistency with std::vector.
Otherwise, should cyclic_buffer be named cyclic_fifo ?
Cheers, and thanks for being open to input and review...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk