|
Boost Users : |
From: Matias Capeletto (matias.capeletto_at_[hidden])
Date: 2007-08-21 17:39:33
On 8/21/07, Oliver Kania <kania.oliver_at_[hidden]> wrote:
> Hello,
Hi Oliver,
> what I basically want to do is using multi-index like a hashmap.
> I want to use vector<long> as key. However, all the examples I found
> are using member-fields of the values or the values themselves as key.
> Is it not possible to use multi-index like a hash_map<value,key> where the
> key is independent of the value type ?
> If yes, could someone please provide an example ?
You need Boost.Bimap. Online docs here: http://tinyurl.com/22sja5
Look at "Unconstrained sets" section.
It will be included in Boost 1.35, you can check out of svn head now.
An example of what you are asking:
typedef
bimap
<
vector_of< long >,
unconstrained_set_of< something >
>
bm_type;
bm_type bm;
assign::push_back( bm ) ( 1, a ) ( 2, b ) ( 3, c );
BOOST_FOREACH( bm_type::left_reference p, bm.left )
{
cout << p.first << "-->" << p.second;
}
King regards
Matias
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