|
Boost : |
From: Joseph Gauterin (joseph.gauterin_at_[hidden])
Date: 2007-08-09 08:17:28
Would anyone be interested in having a couple of extra specialized
iterator adaptors in Boost.Iterator?
I'm thinking of 'key_iterator' and 'value_iterator' adaptors (along
with convenience 'make_key_iterator' and 'make_value_iterator'
functions) that allow any associative container (that follows standard
library idioms) to be accessed as either a range of keys or as a range
of values.
They'd be used like this:
std::map<std::string,int> m;
std::for_each(make_value_iterator(m.begin()),make_value_iterator(m.end()),func);
Where func() takes an int parameter rather than a std::pair<const
std::string,int>.
Using these adaptors is considerably easier than using boost.lambda
for this purpose and they can be implemented to incur no (or
negligable) runtime overhead when compared to iterating normally
through an associative container.
I find these useful - does anyone else?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk