David-
Thanks.
Upon reading my poorly phrased email I realized this:
I want unique keys so that if the data looks like this:
key value
3 1
1 2
1 4
4 3
5 5
5 9
So, what I would like to do is to a print each value for a particular
key in such a way:
key: value:
1----
|------2
|------4
3----
|------1
4----
|------3
5----
|------5
|------9
Or, for example, if I had a list of directories as keys and and files
are their values then for each directory I could print out the file.
Right now, I do this:
for (multimap
Chris Goller
writes: I'm just getting into boost and I really like it.
I would like to iterate over keys of a multimap.
so it would look like this:
std::multimap
::key_iterator i = map.beginkey(); i != map.endkey(); i++ at each i++ it would move to the next key. -or-
for_each(map.beginkey(), map.endkey(), whatever);
Is this possible with the boost iterators?
You can't use that syntax, because there's no way to inject a key_iterator member into std::multimap. You could use a transform_iterator over the multimap's native iterator with select1st, defined as:
struct select1st { template
T& operator()(std::pair & p) const { return p.first } template
T const& operator()(std::pair const& p) const { return p.first } }; HTH,