(without iterating through the container)
I'm experimenting with replacing multiple std containers with a single boost::multi_index_container.
the boost::multi_index_container below has two indexes
using Boxes = boost::multi_index_container<
Box,
indexed_by<
sequenced<
tag<ordered_by_insertion>
>,
ordered_unique<
tag<ordered_by_id>,
const_mem_fun<Box, set_id_type_const_reference, &Box::id>
>
>
>;
The sequence in which elements are added to the container needs to be retained, so the first index is the insertion sequence (ordered_by_insertion).
Elements are uniquely identified by an id, so the second index is on the unique id (ordered_by_id).
How can I use use the unique id to efficiently retrieve the insertion order position of an element.
Is there a way to turn ordered_by_insertion into a bi-directional map from object to position? Or to create a third index from Box::id to position?