Goles
Goles

Reputation: 11799

google::dense_hash_map vs std::tr1::unordered_map?

I'm working on a Mobile Game for several platforms ( Android, iOS, and some maybe even some kind of console in the future ).

I'm trying to decide whether to use tr1::unordered_map or google::dense_hash_map to retrieve Textures from a Resource Manager (for later binding using OpenGL). Usually this can happen quite a few times per second (N per frame, where my Game is running at ~60 fps)

Considerations are:

Any ideas or suggestions are welcome.

Upvotes: 9

Views: 6606

Answers (3)

big_gie
big_gie

Reputation: 3017

In a C++ project I developed, I was wondering something similar: which one was best, tr1:unordered_map, boost::unordered_map or std::map? I ended up declaring a typedef, controllable at compilation:

#ifdef UnorderedMapBoost
typedef boost::unordered_map<cell_key, Cell> cell_map;
#else
#ifdef UnorderedMapTR1
typedef std::tr1::unordered_map<cell_key, Cell> cell_map;
#else
typedef std::map<cell_key, Cell>  cell_map;
#endif // #ifdef UnorderedMapTR1
#endif // #ifdef UnorderedMapBoost

I could then control at compile-time which one to use, and profiled it. In my case, the portability ended up being more important, so I normally use std::map.

Upvotes: 0

Mike Lyons
Mike Lyons

Reputation: 26018

go with the STL for standard containers. They have predictable behavior, and can be used seamlessly in STL algos/iterators. You're also given some performance guarantees by the STL.

This should also guarantee portability. Most compilers have the new standard implemented.

Upvotes: 1

Related Questions