Hey guys,
You can use the "find()" function to find if a value exists inside of a vector as such:
How does one perform this search in a two-dimensional vector but only on one of the dimensions?
For instance: if I had
such that vec[i][j] existed, how could one strictly search through the 'i' values and not the 'j's? In other words, if I had a 4x2 (4 rows, 2 columns) vector, how could I only search through the first column using "find()"?
I'm wanting to store page reference strings in one of the columns and a timestamp in the other. However, when searching for a value I only want to check the page references not the timestamps.
You can use the "find()" function to find if a value exists inside of a vector as such:
(find(vector.begin(), vector.end(), valueToBeFound) != vector.end());
How does one perform this search in a two-dimensional vector but only on one of the dimensions?
For instance: if I had
vector< vector<int> > vec(i, vector<int>(j))
such that vec[i][j] existed, how could one strictly search through the 'i' values and not the 'j's? In other words, if I had a 4x2 (4 rows, 2 columns) vector, how could I only search through the first column using "find()"?
I'm wanting to store page reference strings in one of the columns and a timestamp in the other. However, when searching for a value I only want to check the page references not the timestamps.