Samuel Charron
On Fri, Dec 4, 2009 at 9:58 PM, Joaquin M Lopez Munoz
wrote: Samuel Charron
writes: I'd want to have a multi_index storing containers, and have one index based on all the contained elements. For example: two vectors [1 2 3] and [3 4] would be indexed as 1 -> [1 2 3] 2 -> [1 2 3] 3 -> [1 2 3] [3 4] 4 -> [3 4]
How would you do that ?
If I'm understanding your question well, you can do like this: [...]
With your solution, my containers are sorted using all their values, it's not what I meant.
My problem is that from any element from the container, I want to be able to retrieve the whole container.
My index type would be the element contained, and the type of element contained in the multi_index would be the container type. The indices inserted would be all elements from my container, and the element would be one occurence of the container.
Ok, now I got it. The short ansewer is that Boost.MultiIndex
does not provide any off-the-shelf way to do what you want,
basically because each element (each vector in your case)
appears exactly once in any given index.
Long answer: you can approach your scenario by storing
"container positions" rather than containers and manually
inserting for each new conainer as many different positions
as elements has the container. Kind of as sketched in the
following program:
#include
multi_t;
template