Boost logo

Boost Users :

Subject: Re: [Boost-users] printing data sorted based on a specific key in boostmulti-index container
From: joaquin_at_[hidden]
Date: 2008-10-10 08:31:38

Ramesh escribió:
> Hi Joaquin,
> Supposing I have a container having three unique keys, Is there a way
> I can print data sorted by one of they keys?
> At the moment I tried a raw dump - it shows fields based on the first
> key (which is key1).

Hi Ramesh,

Just use the iterators provided by the second or third index. For
instance (not compiled, beware typos):

  for (MyMap::index_iterator<Key2>::type it =
       itend = MyContainer.get<Key2>().end();
       it != itend;++it) {
    cout << it->Key1;
    cout << it->Key2;
    cout << it->Key3;

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at