$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
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 = 
MyContainer.get<Key2>().begin(),
       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