user3529280
user3529280

Reputation: 43

Boost Multi-Index Composite Key for Multiple-Column Indexes

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.

Upvotes: 2

Views: 248

Answers (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.

Upvotes: 1

Related Questions