Boost logo

Boost Users :

Subject: Re: [Boost-users] Can Boot MultiIndex help me?
From: Boris Schäling (boris_at_[hidden])
Date: 2015-07-22 15:29:30


On Wed, 22 Jul 2015 15:31:00 +0200, Paolo Bolzoni
<paolo.bolzoni.brown_at_[hidden]> wrote:

> 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_indices.html#rnd_indices>).

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