Boost logo

Boost Users :

Subject: Re: [Boost-users] iterator: zipping and additional function
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-01-31 16:25:08


On Sun, Jan 29, 2012 at 6:16 AM, MM <finjulhich_at_[hidden]> wrote:

> Hello,
>
> I have a list of historical datas of this form:
>
> Histodata1 Histodata2 ... Histodatan
> 1 Jan 1980 Data1 25 Jan 1980 Data2 2 Jan 1980
> Datan
> 2 Jan 26 Jan 3 Jan 1980
> ...
> 31 Dec 2004 29 dec 2004 1 dec 2004
>
>
> This is implemented as
>
> class histodata {
> public:
> typedef std::vector<entry>::iterator iterator;
> private:
> std::vector<entry> data_;
> };
>
> I need to obtain the union of all this data without duplicating the
> individual datas, so I wrote a
>
> class hisodataset { // contains a unique set of histodatas
> /// this contains the n datas
> /// Define the iterator
>
> };
>
> The requirements of the iterator: bidirectional, but if RanAcc is possible,
> it would be good.
> . We want the union of datas, so that, if a date is present in at least 1,
> then the it should be present in the union. For those histodatas that don't
> have the date, it should simply duplicate the last available date for that
> histodata.
> . begin() on the set will return the earliest date available for all
> histodatas
> .end () will return the "one-after-last" last being the last date available
> in all histodatas.
>
> I'm not quite sure how to implement such an iterator.
> boost::zip_iterator over the underlying histodatas, but how to add to that
> the union part?
>
> only a const version of this union iterator is required, no writing needed.
>

It sounds like you do indeed want to "zip" the individual histodatas
together, but the "zip" in boost::zip_iterator has a different meaning than
what you're looking for, I'm guessing. Doesn't sounds like there's anything
in boost that will work out of the box. Perhaps it will help if you can
give a full example (without ellipses) of multiple concrete histodatas and
what the desired iteration over them should look like.

- Jeff



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net