Questions tagged [boost-unordered]

Boost.Unordered is a C++ library implementing containers intended to mimic C++11's unordered associative containers

Boost.Unordered is a C++ library implementing containers intended to mimic C++11's unordered associative containers.

(Note that some deviations from the standard are necessary in order to work with non-C++11 compilers and libraries.)

31 questions
9
votes
2 answers

Does an iterator iterate through boost::unordered_set or boost::unordered_map in the same order as long as the set's unchanged?

Does an iterator iterate through boost::unordered_set or boost::unordered_map in the same order as long as the set or the map is unchanged?
Tianyang Li
  • 1,755
  • 5
  • 26
  • 42
7
votes
3 answers

C++ some questions on boost::unordered_map & boost::hash

I've only recently started dwelling into boost and it's containers, and I read a few articles on the web and on stackoverflow that a boost::unordered_map is the fastest performing container for big collections. So, I have this class State, which…
Ælex
  • 14,432
  • 20
  • 88
  • 129
5
votes
1 answer

unordered_map with gregorian dates

I would like to store boost::gregorian::date as key of a boost::unordered_map but I cannot compile the code as it is missing a proper hash function for this class. An easy solution would be converting to std::string and store it. I possibly would…
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173
4
votes
1 answer

Maps of maps allocated in shared memory

Inside a boost::interprocess::managed_shared_memory, I am trying to create boost::unordered_map inside another boost::unordered_map as value, having key as std::string for both maps. This Map in Map inside a shared memory segment gets accessed by…
DragonX
  • 371
  • 2
  • 6
  • 18
4
votes
1 answer

Boost interprocess unordered_map compilation

I'm using boost 1.53 and GCC 4.1.2. I've tried to use boost unordered_map in some tests (documentation says, that it should work with shared memory), but i'm unable to compile my code. With interprocess::map instead of unordered everything is…
4
votes
1 answer

how to implement TryGetValue in boost::unordered_map?

In C# i like TryGetValue method of Dictionary because it allows me in one call determine if dictionary contains key and receive value if so: Instrument instrument; if (isinId2Instrument.TryGetValue(isin_id, out instrument)) { // key exist,…
Oleg Vazhnev
  • 23,239
  • 54
  • 171
  • 305
3
votes
3 answers

insert to boost unordered map

Hi I'm trying to insert a record into a boost::unordered_map Map is defined as boost::unordered_map input_l1_map; where Input is the class class Input { int id; std::string name; std::string desc; …
Jishnu U Nair
  • 512
  • 5
  • 12
  • 29
2
votes
3 answers

Threading with shared variables

I tried to use multiple threads to insert into a boost::bimap. I have some shared variable between the threads, which I need to pass by reference and some of them are modified by each thread execution. However, I get the error: Segmentation fault…
AwaitedOne
  • 992
  • 3
  • 19
  • 42
2
votes
2 answers

Do we need to define bucket count number when construct unordered_map?

In the constructor of unordered_map, we can define the allocated bucket count. I had thought I can use to reduce rehashing times. However, this could also hurt performance at some case. The rehash happens at insert when Rehashing occurs only if the…
Joe C
  • 2,757
  • 2
  • 26
  • 46
2
votes
0 answers

What is the size difference in housekeeping and extra memory due to it between std::map and boost::unordered_map?

I am primarily asking this question because I am not sure how I can calculate the size difference between the two since I store pointers to my class objects stored based on std::string as keys. I know the extra space is primarily because of house…
codeworks
  • 149
  • 1
  • 15
2
votes
2 answers

C++: no match for operator< when trying to iterate through boost::unordered_map

I have the following code: boost::unordered_map map; map["hello"]++; map["world"]++; for(boost::unordered_map::iterator it = map.begin(); it < map.end(); it++){ cout << map[it->first]; } and when I try to…
Aly
  • 15,865
  • 47
  • 119
  • 191
2
votes
1 answer

Efficient hashing of `std::bitset` or `boost::dynamic_bitset<>` for Boost's unordered containers

I'm wondering if there's some efficient way to hash std::bitset or boost::dynamic_bitset<> for Boost's unordered containers? I'm currently converting std::bitset or boost::dynamic_bitset<> to std::string first before hashing them, but it seems this…
Tianyang Li
  • 1,755
  • 5
  • 26
  • 42
2
votes
2 answers

Thread safety in boost::unordered_map of std::string and std::list, while making changes to list

I am using a boost::unordered_map > in a performance critical multi-threaded environment. I understand that writing to STL containers isn't thread safe and the same goes for boost::unordered_map.…
bisarch
  • 1,388
  • 15
  • 31
2
votes
1 answer

boost::unordered_map missing reserve() like std::unordered_map

For my next task I need to use a very big hash; since I have an old compiler I cannot use C++0x std::unordered_map. Ideally I need is a call to reserve to make room in advance for a large number of items. I cannot find this method in…
Abruzzo Forte e Gentile
  • 14,423
  • 28
  • 99
  • 173
1
vote
1 answer

Boost Unordered Flat Map and not copyable / not movable types

Following code compile (MSVC C++ latest) using std::unordered_map but not with the new boost:unordered_flat_map: #include "boost/unordered/unordered_flat_map.hpp" #include class Foo { public: Foo() = default; …
qwark
  • 493
  • 1
  • 4
  • 15
1
2 3