Boost logo

Boost Users :

Subject: Re: [Boost-users] Any "2D" iterator?
From: Michael Fawcett (michael.fawcett_at_[hidden])
Date: 2010-09-17 11:53:46


On Fri, Sep 17, 2010 at 11:15 AM, <lfrfly_at_[hidden]> wrote:
> I have on several occasions encountered situations in which it would be
> advantageous to view a container of containers as a flat sequence. It seems
> like there ought to be a natural way to do this using an iterator class. For
> instance, if you have
> vector<list<T>> v, you ought to be able to design an iterator which begins
> at v.begin()->begin() and runs until v.end(), over every element of every
> list.
>
> Does such a thing exist in Boost, or is it planned in the near future?

I'd be interested as well. Conversely, I just finished writing an
iterator that does the opposite. It takes a flat sequence like
vector<int> and allows one to iterate a "2d view" of it. So if
vector<int> represents a 2D array of size 6x6, you could iterate a 3x3
view of it. I think both iterators would make a good addition to
Boost.Iterators (or hopefully they already exist!)

--Michael Fawcett


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