Boost logo

Boost :

From: Jan Gaspar (jga_at_[hidden])
Date: 2003-07-21 07:54:21


Dave Gomboc wrote:

> > > 3. cb_iterator: is the m_end value needed?
> > >
> > > It can be computed using 'm_it == m_buff->m_last' in
> > > those few (~2) places it is needed and if eliminated,
> > > iterator will get smaller (by 30%) and simpler.
> >
> > Yes, the m_end member is needed. Suppose the circular_buffer is full.
> > Then m_buff->m_first == m_buff->m_last. If there is no m_end variable
> > how would you recognize that the iterator points to the beginning or
> > end?
>
> 30% is a lot. Would it make sense to always allocate one extra element,
> so that this equality can never occur?

1) This is is not true. The members of the iterator are:
const Buff* m_buff;
pointer m_it;
bool m_end;

At Windows based systems sizeof(m_buff) == 4, sizeof(m_it) == 4 and sizeof(m_end)
== 1. It is not 30%.

2) Suppose you are storing elements of size 1000 bytes. By allocating one more
extra element ...

Regards,

Jan

>
>
> Dave
>
> _______________________________________________
> 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-0735 | 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