I would appreciate some advice related to manipulating data in vectors.
I have written code that results in two sets of vectors: strings (labels/names) and doubles (data). The order of the labels in the string vector may be different for each calculation I do.
Here’s what I would like to do. Let’s say that one element (label) in the vector is: Tom. I would like to know if it is possible to search the string/label vector for “Tom” and return the index of Tom’s location in the vector.
Is this something that sounds possible in C++? I would appreciate any tips. Thanks.
Use
std::findA better solution would be to pick a more suitable container, such as the mentioned
std::map