|
Boost : |
From: Nigel Stewart (nigels_at_[hidden])
Date: 2003-07-22 11:27:44
Jan,
I have closely proof-read the HTML document
and intend to respond with a new draft shortly.
There is one point I would like to raise for
discussion:
> Inserting at the beginning or "close to the beginning"
> of the circular_buffer is another trap.
>
> boost::circular_buffer<int> cb(5, 1);
> cb.insert(cb.begin(), 2); // nothing will be inserted
By way of "the principle of least surprise" I think that
insert should _always_ succeed. Inserting to the front
should always overwrite the back, and vice versa. The
concept of "old" and "new" serves only to confuse the
issue IMHO - there is a front and back, (or left and right)
but the circular buffer should not assume that the
front-most are the oldest or newest. (The circular buffer
can be _used_ as a FIFO, but does not _enforce_ FIFO,
since it allows both push and pop from each end)
The following should be exactly equivalent:
cb.insert(cb.begin(), 2);
cb.push_front(2);
We may have discussed this already, I havn't checked the
archives, but it appears to me as hazardous.
As a proposed semantic:
Insertion to the front or back will always be
equivalent to a corresponding sequence of
push_front or push_back.
What are the semantics of inserting a huge sequence to
the middle of a circular buffer? What exactly gets kept?
Nigel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk