Jump to content
  • Advertisement
Sign in to follow this  
the_cyberlord

Eh, problem is too hard to explain in a title...

This topic is 5125 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is my problem: I'm making an .obj file reader, and I finished the vertex, texture, and normal coordinates reading and displaying. Next step is materials: there is a seperate file containing the material definitions, but the problem is: the are not numbered, but only have a name. And in the main object file, those names are used to refer to them... How can I point to the materials in the material file without too much slow-down? (I could place everything in a vector and then search the vector everytime for the right name, but that is a bit slow for me...) Greets Adriaan

Share this post


Link to post
Share on other sites
Advertisement
A hash table is a data structure that maps keys to array elements using a hash function. The hash function is a function that takes an object of the type of a key and yields an integral value, called a hash value, that is then used to index the array, usually after a modulus.

Some programming languages have standard library or direct language support for hash tables. For example, Java has the HashMap class in java.util.

For more information you might want to consult any basic book on data structure and algorithms or the NIST entry on hashtables or even the Wikipedia Hash Table entry.

Share this post


Link to post
Share on other sites
Don't really understand... now that I think again... I think the system in my first post will do. Normally there aren't that much materials, and I only need to read everything once. (I use a display list if you know what that is)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes, just use std::map.

Instead of accessing the element with a number like a vector, you access it with anything of your choice (a std::string, a 'Player' object... anything). Just look online for the list of functions. Maps are extremely easy.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!