Questions tagged [boost-multi-index]

A C++ library which enables the construction of containers maintaining one or more indices with different sorting and access semantics.

248 questions
21
votes
3 answers

how boost multi_index is implemented

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 >, …
user152508
  • 3,053
  • 8
  • 38
  • 58
8
votes
3 answers

Boost multi-index container vs a multi-level mapping container based on std::unordered_map (map of maps)

I recently found boost::multi_index_container and I'm curious about his performance compared to my own implementation of a similar container based on multi-level mapping and defined as: typedef int Data; typedef uint64_t MainKey; typedef…
Flaviu
  • 931
  • 11
  • 16
7
votes
1 answer

Boost.MultiIndex: searching elements using multiple fields

I'm using a Boost multi_index container to store objects according to 2 integer keys K1 and K2. I can easily retrieve an iterator over all elements satisfying "K1 == X", for instance, by taking the first index and using the find() function (idem for…
sunmat
  • 6,976
  • 3
  • 28
  • 44
7
votes
1 answer

Are boost multi_index extracted keys cached?

I am using boost::multi_index with a data type I'd like to index based on its size. However, the size() member function of this data type is expensive to execute. Does multi_index cache the values it gets from its key extractors? For example, if I…
vsekhar
  • 5,090
  • 5
  • 22
  • 23
7
votes
3 answers

Fast search via index with keeping insertion order in C++

I need a container which has ability to search over 1 million items pretty fast and keep the insertion order. So first I thought about std::map but it doesn’t care about the insertion order it orders the data according to the key. An I found…
user2955554
  • 309
  • 3
  • 14
6
votes
2 answers

Get numeric index from Boost multi-index iterator

I'm storing a bunch of the following struct Article { std::string title; unsigned db_id; // id field in MediaWiki database dump }; in a Boost.MultiIndex container, defined as typedef boost::multi_index_container< Article, …
Fred Foo
  • 355,277
  • 75
  • 744
  • 836
6
votes
1 answer

How can I preserve sequenced order with an ordered_non_unique index?

I have a boost::multi_index_container indexed by an ordered_non_unique key as well as sequenced. When I iterate over the non-unique index, the entries come out in the order they were added to the container rather than their position in the…
Cogwheel
  • 22,781
  • 4
  • 49
  • 67
6
votes
2 answers

Consistency when removing items from boost multi-index using an iterator

I know that the following code is not correct, for std::vectors and more generally all STL containers: std::vector::iterator it = array.begin(); for(; it != array.end(); it++) { ... array.erase(it); ... } because the iterator…
sunmat
  • 6,976
  • 3
  • 28
  • 44
6
votes
2 answers

Is using a map where value is std::shared_ptr a good design choice for having multi-indexed lists of classes?

problem is simple: We have a class that has members a,b,c,d... We want to be able to quickly search(key being value of one member) and update class list with new value by providing current value for a or b or c ... I thought about having a bunch…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
5
votes
1 answer

boost multi index container of template-dependent struct in template-class

I want a multi-index-container in a class, that depends on a template-dependent class in the class. Sounds complicated, here is the code: #include #include #include…
veio
  • 507
  • 4
  • 16
4
votes
4 answers

Having a composite key for hash map in c++

I have a data structure which has, , , and Since Book title or Author can be duplicated, I'd like to build a composite key. (let's say I cannot make extra unique key, such as ID) Since data is pretty huge, I'm using GCC…
devEvan
  • 361
  • 4
  • 16
4
votes
1 answer

template parameter to boost multi index container

I need to create a generic class containing multiindex container as a storage. when I compile, it gives error as below where I have defined nth index view. error: non-template ‘nth_index’ used as template /** * connection manager */ template <…
rjoshi
  • 1,645
  • 1
  • 20
  • 31
4
votes
1 answer

How to make the equal_range iterator sorted by a different index in Boost Multi-index?

I have a boost multi-index container on the employee class (taken from boost official documentation): typedef multi_index_container< employee, indexed_by< ordered_unique< tag, …
motam79
  • 3,542
  • 5
  • 34
  • 60
4
votes
2 answers

Boost multi_index: retrieve unique values of a non-unique key

I have a boost::multi_index_container whose elements are structs like this: struct Elem { A a; B b; C c; }; The main key (in a database sense) is a composite_key of a and b. Other keys exist to perform various types of queries. I now…
UncleZeiv
  • 18,272
  • 7
  • 49
  • 77
4
votes
2 answers

Move element from boost multi_index array

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…
Slava
  • 43,454
  • 1
  • 47
  • 90
1
2 3
16 17