Archived

This topic is now archived and is closed to further replies.

IFooBar

std::hash_map good enough for texture manager?

Recommended Posts

IFooBar    906
Well thats basically my question. Is using a hash_map good performance wise in a texture manager? or are there better ways?. I''ll be extracting pointers to the actual texture data many times each frame so retrieval has to be very quick. The nVidia sdk uses std::map and std::set in conjunction for managing resources, but the std::hash_map feels much more appropriate for the job. Im confused because since nvidia obviously know what they are doing when it comes to graphics maybe hash_map is not the way to go? thanks for advice

:::: [ Triple Buffer V2.0 ] ::::

Share this post


Link to post
Share on other sites
Zipster    2359
The biggest difference is that map maintains a strict ordering of the keys, so you can iterate them in order. hash_map doesn't enforce any particular order, and since it does use hashing over sorting you get greater efficiency for lookup, insertion, and removal.

quote:
Original post by MSDN
The main advantage of hashing over sorting is greater efficiency; a successful hashing performs insertions, deletions, and finds in constant average time as compared with a time proportional to the logarithm of the number of elements in the container for sorting techniques. The value of an element in a hash_map, but not its associated key value, may be changed directly. Instead, key values associated with old elements must be deleted and new key values associated with new elements inserted.


[edited by - Zipster on July 6, 2003 6:33:43 AM]

Share this post


Link to post
Share on other sites
ares32585    121
std::hash_map isn''t currently part of the stl, though is it? If it isn''t, how many compilers have an implementation of it? Originally, I was hoping to use a hash_map for something I was coding. However, when I discovered it wasn''t actually part of the standard, I used map instead, even though hash_map would be a better fit for what I wanted. What compilers do support hash_map?

Share this post


Link to post
Share on other sites
Neech    122
Hash_map is much more appropiate for the job. However it is not in the C++97 standard.

Every marjor ( and minor? ) stl implementation comes with a hash_map though. The implementation as slight differences between dinkumware and stlport type ones but they are minor. ( i think its in the allocators ).

Use them. Its set in stone that one of both implementation goes into the next C++0x standard

Share this post


Link to post
Share on other sites