|
Boost : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2001-12-05 09:45:03
David Abrahams wrote:
> > > > third), but do they fit in the collection? (I think so). They are:
> > > > 1. domain : returns the set of map keys
> > > > 2. range : returns the set of mapped values
> > >
> > > Wouldn't those two be done best using a projection iterator adaptor
> > > with select1st/select2nd?
> >
> > Do you mean implementation or interface? Can you show an example usage?
> > (I don't follow iterators adapters closely). Wouldn't it be overly
> > verbose?
>
> boost::make_projection_iterator(some_map.begin(), std::select1st())
>
> or:
>
> boost::make_projection_iterator<std::select1st>(some_map.begin())
>
> or:
>
>
> boost::projection_iterator_generator<std::select1st,my_map_t::iterator>::ty
>p e
> i(some_map.begin());
>
> The advantage is that you can iterate over keys without causing them to be
> copied.
This is what I expected: more verbose, more efficient. I refrain from making
any statement on whether this algorithms are usefull -- after all the third
one (map reversing) is much more important, and the question of putting it in
algorithm library remains.
- Volodya
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk