Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi-index] Key extractor for 1:n relationship?
From: Boris Schaeling (boris_at_[hidden])
Date: 2009-07-17 08:15:16


On Fri, 17 Jul 2009 07:12:00 +0200, plarroy <plarroy_at_[hidden]> wrote:

> Boris Schaeling wrote:
>> All the key extractors in the documentation of Boost.MultiIndex return
>> one value for an element in a container. Is it somehow possible to use
>> a 1:n relationship between element and value?
>>
>> The documentation uses this container definition (among others):
>>
>> typedef multi_index_container<
>> employee,
>> indexed_by<
>> hashed_unique<
>> const_mem_fun<employee, std::string, &employee::name>
>> >
>> >
>>> employee_set;
>>
>> Let's assume an employee can have more than one name (std::string
>> becomes std::vector<std::string>). Now if someone searches for Tom or
>> John the same employee should be returned by the container. Is this
>> possible?
>>
>
> A vector of strings is still an object, and hashed_unique indexes are
> unique.

Either you misunderstand me or I misunderstand you. :) The hash value
would be created for the entire vector? I want to use a string in the
vector as a key, not the entire vector itself. If an employee has the
names Tom and John I want to find the employee also if I only search for
Tom. There would be one employee object in the container but two hash
values would need to be generated. Not sure if this is possible at all?

Boris


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