I need to implement my map with a vector. My map is layed out like:
map<strong,double> mapName;
I need to convert over to vector so that I can do a linear search through the elements.
Thanks in advance for the time.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can easily convert to a vector using vector’s range constructor like so:
However, if you only need to do a linear search, you don’t need to copy the elements. Just iterator over the items like so: