Boost logo

Boost Users :

From: chun ping wang (cablepuff_at_[hidden])
Date: 2007-10-22 13:38:51


hmm it could be container of any type (set, multiset, list, vector, array,
deque).

It should act like ruby on rails, flatten.

http://www.ruby-doc.org/core/classes/Array.html#M002241

On 10/22/07, Vinzenz 'evilissimo' Feenstra <evilissimo_at_[hidden]> wrote:
>
> Oops, some typos here.
>
> Vinzenz 'evilissimo' Feenstra schrieb:
> > Hi,
> >
> > I am wondering how your example container looks like, since it seems to
> > contain several types.
> >
> > If container is a container containing containers with values, you could
> > do something like this:
>
> > [code]
> > vector<container::value_type::value_type> flattened;
> > for(container::iterator it = c.begin(), end = c.end();beg != end; ++it)
> > flattened(it->begin(), it->end(), std::back_inserter(flattened));
> > [/code]
> Should be:
> [code]
> std::vector<container::value_type::value_type> flattened;
> for(container::iterator it = c.begin(), end = c.end();beg != end; ++it)
> std::copy(it->begin(), it->end(), std::back_inserter(flattened));
> [/code]
>
> > Regards,
> > Vinzenz
> >
> > chun ping wang schrieb:
> >> Is their some kind of method to flatten a stl container...
> >>
> >> example [[1, 4], [a,b, c], [b, [e]] ] becomes [1, 4, a, b, c, b, e]
> >>
> >>
>
> Sorry for the mistake.
> Regards,
> Vinzenz
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>



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