how boost multi_index is implemented

后端 未结 3 571
情话喂你
情话喂你 2020-12-30 01:55

I have some difficulties understanding how Boost.MultiIndex is implemented. Lets say I have the following:

typedef multi_index_container<
    employee,
           


        
3条回答
  •  粉色の甜心
    2020-12-30 02:41

    Conceptually, yes.

    From what I understand of Boost.MultiIndex (I've used it, but not seen the implementation), your example with two ordered_unique indices will indeed create two sorted associative containers (like std::map) which store pointers/references/indices into a common set of employees.

    In any case, every employee is stored only once in the multi-indexed container, whereas a combination of map and map would store every employee twice.

    It may very well be that there is indeed a (dynamic) array inside some multi-indexed containers, but there is no guarantee that this is true:

    [Random access indices] do not provide memory contiguity, a property of std::vectors by which elements are stored adjacent to one another in a single block of memory.

    Also, Boost.Bimap is based on Boost.MultiIndex and the former allows for different representations of its "backbone" structure.

提交回复
热议问题