|
Boost Users : |
From: Igor R (boost.lists_at_[hidden])
Date: 2008-06-12 07:15:00
Hi,
I'm trying to replace few data structures and types defined in my
application in terms of std containers, with the
mutli_index_container. Some of those types look like this:
struct Entry
{
int someForeignKey;
int data1;
std::string data2;
//....
};
typedef std::deque<Entry> Entries;
typedef std::map<int, Entries> EntriesByForeignKey;
I'd like to rewrite the above map as follows:
typedef mi::multi_index_container
<
Entry,
mi::indexed_by
<
mi::hashed_non_unique<mi::tag<foreignKey>, mi::member<Entry, int,
&Entry::someForeignKey> >
>
> Entries;
typedef Entries::index<foreignKey>::type EntriesByForeignKey;
Now, I'd like to iterate through the *keys* of this index, and for
each key - iterate through all its values. IIUC, the second part can
be accomplished like this:
{
Entries entries;
EntriesByForeignKey::iterator begin =
entries.get<foreignKey>().find(theKey), end =
entries.get<foreignKey>().end();
for_each (begin, end, ....);
}
...but how can I iterate through all the keys of this index? Or should
I define another index for this purpose (sequenced one?) ?
Thank you,
Igor'.
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