Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-04-10 09:30:26


I have used Thomas Witt's cyclic_array (files section) to show that Neal D.
Becker's statistics code works nicely with a cyclic buffer - as it should.

But the cyclic iterator and buffer code is somewhat unfinished. (I googled to
three Boost contributions from Gennadiy Rozental, Thomas Witt and Jan Gaspar but
expediently used Thomas Witt's). I believe that this experiment shows how
valuable it would be to have a cyclic buffer and iterator in the Boost toolkit.
How can I rekindle interest in this?

Paul

Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
Mobile mailto:pabristow_at_[hidden]
mailto:pbristow_at_[hidden]

Code fragment:

                cyclic_array<double, max_buffer_size> cb;// Container to hold a few test
values.
                Stat<double> D; // Statistics
                for (int i = 1; i < 9; i++)
                { // Simulate new measurements or data coming in.
                        cb.push_back(double(i)); // New measurements: 1., 2. .. 8.
                        cout << double(i) << '\t';
                        show_cb(cb, cout); // Current state of cyclic buffer.
                        D.Reset(); // Or Compute will add to previous count, sum etc, perhaps not
intended?
                        D.Compute(cb.begin(), cb.end()); // Iterate over all cyclic buffer.
                        // Function Compute triggers calculation of mean, sd etc.
                        cout << "Count = " << D.Count()<< ", mean = " << D.Mean()
                                << ", sd = " << D.StdDev() << endl;
                }

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Neal D. Becker
> Sent: Thursday, April 03, 2003 10:15 PM
> To: Boost mailing list
> Subject: Re: [boost] Statistics code example

> >
> > And it makes me wonder if one could use a container like a circular buffer.
> > I can think of applications where one would like new data to pour in
> > continuously and to look back for mean (weighted Kalmanesque?), perhaps
> > only a limited distance. Using a vector or valarray would imply it would
> > grow for ever and run out of space eventually. (I think someone else
> > suggested something of this sort?)
> > Is the STL queue suitable?
> >
>
> We have actually seen some nice code for circular buffer, about 6months to 1
> year back. I have brought the subject up here a couple of times.
>
> The most promising IMHO is cycle_iterator, which is an adaptor submitted by
> Gennadiy Rozental. I believe this is almost ready for a real boost
> submission. Last we left it, there were some questions of the semantics of
> the "distance" between iterators. In any case, the "distance" between
> iterators in a cyclic buffer is fuzzy.
>
> I think the semantics in cyclic_buffer are the ones I prefer. That is, the
> distance from A -> B is always interpreted as positive.


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