Maps are one of the most useful datastructures in C++ and there is no excuse for not knowing it. Here is a basic example that shows how you can use it: See also C++ Reference: general information and example Map is ordered collection (source)
Posts Tagged ‘STL’
Minimal Example Output: Vector initialization Nested Vectors Output: Initialize nested vectors Output with the script above: You could also do it this way: Some more Reverse the order With reverse (source): See also C++ Reference: General information and example Iterating over 2-dimensional STL vector C++
As find is logarithmic in size() (source: C++ Reference), the membership test is also in . Sets of structs If you want to create a set of structs, you have to create a comperator: See also C++ Reference: general information and example How to check that an element is in a std::set?