Sign in to follow this  

waht is this ?? mapuint32, CEntity Entities

Recommended Posts

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this