unordered-map

boost::unordered_map support by gcc

When unoreded_map support was added to gcc? I'm using gcc 4.1.1 shipped with RHEL 5.3. It looks like unoreded_map is missing. Is there a way to add it manually? ...

Using boost unordered map

Guys, I am using dynamic programming approach to solve a problem. Here is a brief overview of the approach Each value generated is identified using 25 unique keys. I use the boost::hash_combine to generate the seed for the hash table using these 25 keys. I store the values in a hash table declared as boost::unordered_map<Key_Object,...

How can I use boost::thread::id as key to an unordered_map?

According to the documentation, a boost::thread::id can be considered unique for each running thread and can be used in containers such as std::set and std::map (because the < operator is overridden for thread::id). My problem is that I'd like to use thread::id as a key to an boost::unordered_map, however it requires that the key is "ha...

C++: is the unordered_map really unordered?

I am very confused by the name 'unordered_map'. The name suggests that the keys are not ordered at all. But I always thought they are ordered by their hash value. Or is that wrong (because the name implies that they are not ordered)? Or to put it different: Is this typedef map<K, V, HashComp<K> > HashMap; with template<typename T> s...

unordered_map throws bad_alloc in VS10 but not in VS9, is this a bug?

While writing a post about project euler's 14th problem I ran into a difference in behaviour between VC9 and VC10. The following code runs OK in VC9 but in VC10 std::unordered_map throws a bad_alloc exception. The strange thing is that if I recover from the exception future allocations will succeed (the size of the container continues t...

Help understanding segfault with std::map/boost::unordered_map

Hello, I have some code to handle resource (images, fonts, mesh data, etc.) management using a template'd static class, allowing client code to do something like: ResourceManager<Texture>::init("data/textures"); ResourceManager<Font>::init("data/fonts"); // later ... boost::shared_ptr<const Texture> tex = ResourceManager<Texture>::getR...

Using string* as a key in an unordered_set

I would like to put use a string* as a key in an unordered_list. I do not want the hash the pointer itself but the string it points to. I understand I need to create a struct like this: struct myhash{ size_t operator()(const string * str){ return hash(*str); } } and send it as a a hasher to the map template, but i am ...

Will C++0x provide hashing functions for std::type_info?

Hello everyone :) I'm still working on a good solution to my One-Of-A-Type Container Problem -- and upon reflection I think it would be nice to be able to just use something like a std::map<std::type_info, boost::any>. Unfortunately, std::type_info does not define an operator<, and I think it'd be unreasonable for it to define one. How...

Building an unordered map with tuples as keys

In a C++ program with Boost, I am trying to build an unordered map whose keys are tuples of doubles: typedef boost::tuples::tuple<double, double, double, double> Edge; typedef boost::unordered_map< Edge, int > EdgeMap; Initializing the map completes OK, however, when I try to populate it with keys and values EdgeMap map; Edge key (0...

Multiple keys Hash Table (unordered_map)

I need to use multiple keys(int type) to store and retrieve a single value from a hash table. I would use multiple key to index a single item. I need fast insertion and look up for the hash table. By the way, I am not allowed to use the Boost library in the implementation. How could I do that? Thanks. ...

Unordered (hash) map from bitset to bitset on boost

Hello, I want to use a cache, implemented by boost's unordered_map, from a dynamic_bitset to a dynamic_bitset. The problem, of course, is that there is no default hash function from the bitset. It doesn't seem to be like a conceptual problem, but I don't know how to work out the technicalities. How should I do that? Thanks. ...

c++ unordered_map compiling issue with g++

i am using g++ in ubuntu g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. i have this code #include<unordered_map> using namespace std; bool ifuni...

how to use boost::unordered_map

hello, for my application, i need to use a hash map, so i have written a test program in which i store some instances of a baseclass in a boost::unordered_map. but i want to reach the instances by calling special functions which return a derived class of the base and i use those functions' parameters for hash key of unordered_map. if no...