Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Two Dimensional Vectors (and the 'find()' function);

$
0
0
Hey guys,

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.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>