I am looking for an efficient way of converting a C++ array to a map according to the array index enumeration.
For example, if I have an array with
arr=[2,4,5,3,6]
I want to get a map like
[<0,2>, <1,4>, <2,5>, <3,3>, <4,6>]
My current implementation is like this:
std::map<int, int> mapping;
for (int i = 0; i < len; i++)
mapping.insert(pair<int, int>(i, arr[i]));