std::map

TwitterFacebook
Get flash to fully experience Pearltrees
http://en.wikipedia.org/wiki/Associative_containers_(C%2B%2B) In computing, associative containers refer to a group of class templates in the standard library of the C++ programming language that implement ordered associative arrays . [ 1 ] Being templates , they can be used to store arbitrary elements, such as integers or custom classes. The following containers are defined in the current revision of the C++ standard: set , map , multiset , multimap . Each of these containers differ only on constraints placed on their elements. The associative containers are similar to the unordered associative containers in C++ standard library , the only difference is that the unordered associative containers, as their name implies, do not order their elements. [ edit ] Design

map (C++)

http://www.cprogramming.com/tutorial/stl/stlmap.html

STL Tutorial - Map Class

Suppose that you're working with some data that has values associated with strings -- for instance, you might have student usernames and you want to assign them grades. How would you go about storing this in C++? One option would be to write your own hash table . This will require writing a hash function and handling collisions, and lots of testing to make sure you got it right.