[multi_index] A multi_index where one index is a subset of the whole collection
Hi, I've asked this question [1] two days ago on stackoverflow.com but haven't gotten any answer on it, yet. So I'll try it here. [1] http://stackoverflow.com/questions/10217601/a-multi-index-where-one-index-is... If this is not possible out of the box, can I write my own indices for multi_index that would allow such functionality? Cheers, Philipp Moeller GeometryFactory
Philipp Moeller
Hi,
I've asked this question [1] two days ago on stackoverflow.com but haven't gotten any answer on it, yet. So I'll try it here.
[1]
http://stackoverflow.com/questions/10217601/a-multi-index-where-one-index-is...
If this is not possible out of the box, can I write my own indices for multi_index that would allow such functionality?
Hi Philipp, No, unfortunately this is not possible, and the design of Boost.MultiIndex makes it very difficult to implement coherently: for one, how should iterator projection (http://tinyurl.com/7yyc9yr ) work when an element is not part of every index? As a possible workaround, you can do as follows: * Each time you "delete" an element from idx1, move it to the back of the index. Keep an iterator idx1_end to the first element in such a state, so that the range of "active" elements of idx1 is [idx1.begin(),idx1_end). * When you delete an element for good, check first if it is *idx1_end that you're deleting; if so, increment idx1_end before deletion. Hope this helps, Joaquín M López Muñoz Telefónica Digital
participants (2)
-
Joaquin M Lopez Munoz
-
Philipp Moeller