Jump to content
  • Advertisement
Sign in to follow this  
tBoai

waht is this ?? mapuint32, CEntity Entities

This topic is 4398 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

map<uint32, CEntity> Entities; why had a couple <> behind map? what is map mean? and what is the <> mean? and where it came from?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by tBoai
map<uint32, CEntity> Entities; why had a couple <> behind map? what is map mean? and what is the <> mean? and where it came from?
Based on what you posted I would suggest looking into:

1. C++ templates
2. Data structures
3. The C++ standard library

Just to get you started, in C++, templates allow you to generate multiple classes (or functions) from a single class (or function) template.

A map is an associative data structure that associates one piece of information (the 'key') with another (the 'data'). std::map is the C++ standard library's specification for a class that represents this data structure.

The bit of code you posted declares a std::map which associates objects of type uint32 (the key) with objects of type CEntity (the data). This is one of many containers that can be used for storing objects; others are vector, list, and stack. Each has its own particular characteristics, strengths, and weaknesses.

'Hope that helps get you started.

Share this post


Link to post
Share on other sites
map is a class template, a parameterized type. map implements an associative array. The first type listed, uint32 is the the type of the keys used to index the map, while the second, CEntity is the type of the values stored. Simply stated, map<uint32, CEntity> is a "map from int32 to CEntity".

Templates are a way to write code that will work with different types. So, for example, instead of having to write list_of_int, list_of_double, list_of_CEntity classes, you would just write a list class template (the C++ standard library already has one), then let the compiler generate the code for list<int>, list<double> or list<CEntity>.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!