Hi All:
I have a large number of elements to be stored into vector or basic string(delimited by \n). I need to search for an element and I would like to know what is faster:
A:
B:
I'm only interested in search time, I don't need to access any of the elements for reading, modifying or removing.
Thanks a lot,
Petry
I have a large number of elements to be stored into vector or basic string(delimited by \n). I need to search for an element and I would like to know what is faster:
A:
Code:
std::string str = "\nElement1\nElement2...element10000\n"
str.find("\nElement3\n");
B:
Code:
std::vector<string> v;
v.push_back("Element1"); v.push_back("Element2"); ....
std::find(v.begin(), v.end(), "Element3") != v.end() )
I'm only interested in search time, I don't need to access any of the elements for reading, modifying or removing.
Thanks a lot,
Petry