Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

ios

iphone

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:

  • Performance (memory and cpu wise)
  • Portability

Any ideas or suggestions are welcome.

like image 791
Goles Avatar asked Jul 04 '11 17:07

Goles


People also ask

Which is faster std::map or std :: unordered_map?

The performance difference are not so dramatic in the case of the GCC compiler. Therefore, the optimized access with std::map is about 20% faster, but the access time of std::unordered_map about 6 times faster.

Is unordered map better than map?

When it comes to efficiency, there is a huge difference between maps and unordered maps. We must know the internal working of both to decide which one is to be used. You need ordered data. You would have to print/access the data (in sorted order).

Is unordered_map same as HashMap?

Yes, HashMap in java and unordered_map in c++ stl are more or less the same… you can store pointers in java too(Don't forget, in java, everything you deal with is a reference)… hence, HashMap also serves your purpose.

What is std :: unordered_map?

std::unordered_map is an associative container that contains key-value pairs with unique keys. 1. Search, insertion, and removal have average constant-time complexity. 2. Internally, the elements are organized into buckets.


1 Answers

http://attractivechaos.wordpress.com/2008/10/07/another-look-at-my-old-benchmark/

http://attractivechaos.wordpress.com/2008/08/28/comparison-of-hash-table-libraries/

like image 92
Rolf Kristensen Avatar answered Oct 19 '22 01:10

Rolf Kristensen