
On Wed, 22 Jul 2015 15:31:00 +0200, Paolo Bolzoni
Dear list,
I needed a data structure such that: - a list of POD structs (with an Id and other fields) stays in contiguous memory. This is required because I need to pass this block of memory to a C function. - the order of this POD structs is irrelevant. - I need to access to each element from the Id quickly. [...]It works fine, but a colleague mentioned that boost multiindex can do a similar job. I checked the documentation, but I am not sure I can build an index on a vector. Is that possible? Thanks.
If you need to store the same elements in multiple containers, Boost.Multiindex is worth a look. However I'm afraid Boost.Multiindex doesn't meet your requirement of contiguous memory. While the random access index comes closest to a vector, the documentation states: "Random access indices do not provide memory contiguity" (see http://www.boost.org/doc/libs/1_58_0/libs/multi_index/doc/reference/rnd_indi...). Boris