Accessing value of map when it's a vector

I have the following map: myMap<string,vector<int>>. I now want to look through my map to see if a key exists and if it does, retrieve one of the int values from within that vector. What would be the best way to do this? Right now I have the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
What would be the best way to look for a key and get one of the int values from its vector value? Right now I'm doing something like this:

[code] 
map<string,vector<unsigned int>>::iterator it;
it = wordMap.find(someWord);

if(it == wordMap.end){
    cout << "No matching entry";
}
else{
    // this is where I'd want to access the value (the vector) of the map

}


Is there a better way to do this?
1
2
3
4
} else {
    vector<unsigned int> val = it->second;
    unsigned x = it->second[2];
}


NTW: at the line 7 it should be wordMap.end()
The solution to this was posted by JLBorges in a later post - another reason not to have multiple threads on the same subject.

http://www.cplusplus.com/forum/general/91237/#msg490444
Topic archived. No new replies allowed.