
Uthpal Urubail escribió:
Hi
I am looking for a composite key container.
Though I found multi_index_container for composite key is the best I have few doubts in its use case:
*Question:01*
class Book
{
public:
size_t mID;
*size_t node[3];*
};
How to add the below into multi_index_container?
typedef multi_index_container<
Book,
indexed_by<
ordered_unique<
composite_key<
Book,
member
, member
, member
>
>,
ordered_unique<
member
>
>
beambook;
member
beambook;
*Question:02*
My requirement is straight forward. I need to get the id by providing 3 nodes.
Should I always need to create a data structure? [class Book]
No, in fact you don't need to create a Book object. Suppose bb is a beambook and you want to retrieve the mID of an element in bb with nodes n0, n1 and n2. You only have to do the following: size_t mID=bb.find(boost::make_tuple(n0,n1,n2))->mID; As you can see, you simply pass a tuple with the values for the composite key, not a whole Book object. Hope this helps, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo