|
Boost : |
From: Jan Gaspar (jga_at_[hidden])
Date: 2003-06-09 07:12:26
Ok, ok, but what with insert? What element should be removed: the first or the last
one? And why the first approach or the latter.
Jan
Nigel Stewart wrote:
> >> 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
> cyclic_buffer:
>
> - 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
> and functionality.
>
> - 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...
>
> Nigel Stewart
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Jan Gaspar | jga_at_[hidden] Whitestein Technologies | www.whitestein.com Panenska 28 | SK-81103 Bratislava | Slovak Republic Tel +421(2)5930-0734 | Fax +421(2)5443-5512
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk