Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2006-06-08 09:21:59


Prashant Thakre ha escrito:

> Hi,
>
> > OK, here, instead of a composite_key instantiation,
> > you can take advantage directly of std::vector comparison
> > semantics (you don't really need tuple_element):
> >
> > typedef multi_index_container<
> > element,
> > indexed_by<
> > hashed_unique<
> > member<element,std::vector<const std::string>,&element::tp>
> > >
> > // other indices, maybe
> > >
> > > element_collection;
> >
>
> Is this equivalent to having a member std::string tp which is constructed at
> run-time from all the elements of std::vector< const std::string > ?

Depends on how you construct that string: if you just concatenate
the vector elements, then no, it's not equivalent. For instance, the following
two vectors

{"mast","err","apparent"}
{"master","rap","parent"}

both map to "masterrapparent".

> Also, how does the hash function generate the key ?

Boost.Hash combines the vector element's hash values as described at

http://boost.org/doc/html/id2490467.html

B.MI also lets you specify your own hashing mechanism if you need it:

http://boost.org/libs/multi_index/doc/advanced_topics.html#hash_spec

> Thanks a lot.
>
> regards,
> Prashant Thakre

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


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