Boost多指数复合键的多列索引 [英] Boost Multi-Index Composite Key for Multiple-Column Indexes

查看:301
本文介绍了Boost多指数复合键的多列索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些记录,模式是(ID,长度,宽度);

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

我要像搜索长度[10,20)和宽度(20,30];

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.

我需要做的工作在内存中。我看到Boost多指数支持组合键;但我发现它似乎只支持到equal_range搜索,像长20 ==和宽度== 20。

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".

剂量,如升压多指标支持查询[10,20)和宽度(20,30]

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

这似乎多重映射<长度,多重映射<宽度,ID>>可以支持我的要求,但它是一个有点复杂的编码。

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

推荐答案

恐怕Boost.MultiIndex的不利于这一点;考虑到每个索引(有或没有一个复合关键字)诱导的元素的线性的顺序,而要在这里二维布置。我建议看看Boost.Geometry的 R树

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.

这篇关于Boost多指数复合键的多列索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆