Map of Vectors in C++ STL with Examples
Map in STL Maps are associative containers that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have same key values.
Vector in STL Vector is same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators.
Map of Vectors in STL: Map of Vectors can be very efficient in designing complex data structures.
map<key, vector<datatype>> map_of_vector; OR map<vector<datatype>, key> map_of_vector;
For example: Consider a simple problem where we have to check if a vector is visited or not.