boost-multi-index

boost::multi_index_container, operations on std::set inside container

[亡魂溺海] 提交于 2019-12-01 12:36:28
I've created a boost::multi_index_container ( containerSet ) over a container class and indexed the containerSet by std::string and std::set<int> . Is it possible to get the container, which store a specific int inside their set? Furthermore is it possible to get all container, which store at least one value between int1 and int2 within their set? #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/format.hpp> #include <boost/lambda/core.hpp> #include

std::unordered_map - how to “track” max/min key at any time

无人久伴 提交于 2019-12-01 12:02:12
问题 I have std::unordered_map<int, int> . I do not want to use other structures like tree or anything else cause latency requirements. But at any time I need to know current max key and min key. How can I do that? Distribution is NOT uniform, instead max and min are frequently removed and inserted. So I need something smarter than "just scan entire map for a new max/min when current max/min is removed". I do not want to use any other structures. I want to use std::unordered_map ! upd according to

Using boost multi index like relational DB

邮差的信 提交于 2019-11-29 12:47:30
Here is the situation that I am trying to simulate: COL1 Col2 Col3 CBT.151.5.T.FEED S1 t1 CBT.151.5.T.FEED s2 t2 CBT.151.5.T.FEED s3 t3 CBT.151.5.T.FEED s4 t4 CBT.151.5.T.FEED s5 t1 CBT.151.8.T.FEED s7 t1 CBT.151.5.Q.FEED s8 t3 COL1 - is the ID, for a given ID there can be several symbols. COL2 - symbols, they are unique COL3 - update time of a symbol, two different symbols might update at the same time hence they are not unique. My aim is to get the tickers which are most active, lets say symbols that have updated in the last 60 seconds. For this purpose I have used the boost multi index. The

how boost multi_index is implemented

五迷三道 提交于 2019-11-29 06:02:13
问题 I have some difficulties understanding how Boost.MultiIndex is implemented. Lets say I have the following: typedef multi_index_container< employee, indexed_by< ordered_unique<member<employee, std::string, &employee::name> >, ordered_unique<member<employee, int, &employee::age> > > > employee_set; I imagine that I have one array, Employee[] , which actually stores the employee objects, and two maps map<std::string, employee*> map<int, employee*> with name and age as keys. Each map has employee

Move element from boost multi_index array

◇◆丶佛笑我妖孽 提交于 2019-11-27 15:46:17
Let's say I have movable and not copyable object and I have boost multi-index array with random_access index. I need to move my object out of array front, but I cannot find any method, that would give me rvalue/lvalue reference in documentation . I can only see front() which gives me constant reference and pop_front() which erases element, but does not return anything. So is there a way to move element out of boost multi-index? Adding to @sehe's answer, the following shows how to modify the code in case your moveable type is not default constructible: Edited: changed code to properly deal with

Move element from boost multi_index array

大憨熊 提交于 2019-11-26 17:17:44
问题 Let's say I have movable and not copyable object and I have boost multi-index array with random_access index. I need to move my object out of array front, but I cannot find any method, that would give me rvalue/lvalue reference in documentation. I can only see front() which gives me constant reference and pop_front() which erases element, but does not return anything. So is there a way to move element out of boost multi-index? 回答1: Adding to @sehe's answer, the following shows how to modify