Boost Multi-Index Composite Key for Multiple-Column Indexes

倖福魔咒の 提交于 2019-12-11 01:50:11

问题


I have some records, pattern is (id, length, width);

I want to search like "length in [10,20) and width in (20,30]";

If I use relational database, I could create a Multiple-Column Indexes on length and width.

I need to do that job in memory. I see Boost Multi-Index support Composite Key; But I found it seems only support to equal_range search,that like "length == 20 and width ==20".

Dose the the boost Multi-Index support query like [10,20) and width in (20,30] ?

It seem multimap< length, multimap< width, id> > could support my requirement, but it's a little complex for coding.


回答1:


I'm afraid Boost.MultiIndex is not good for this; take into account that each index (with or without a composite key) induces a linear order on the elements, whereas you want a 2D arrangement here. I suggest to take a look at Boost.Geometry's R-trees.



来源:https://stackoverflow.com/questions/35778119/boost-multi-index-composite-key-for-multiple-column-indexes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!