0

I have delared two multimaps such as;

multimap<int,vector<int>> allpathsmap;            
multimap<int,vector<int>>:: iterator itapm; 
typedef pair<int,vector<int>> pairapm;

multimap<int,vector<int>> graphtextmap;           
multimap<int,vector<int>>:: iterator itgtm; 
typedef pair<int,vector<int>> pairgtm;

And I wrote the following code to traverse the values of multimaps to print the key;

for(itgtm=graphtextmap.begin(); itgtm!=graphtextmap.end(); ++itgtm)
{
    for(itapm=allpathsmap.begin(); itapm!=allpathsmap.end(); ++itapm)
    {
        cout << endl << itapm->first <<" => ";
        for(size_t m=0 ; m<(*itgtm).second.size(); ++m )
        {
            for(size_t n=0; n<(*itapm).second.size(); ++n)
            {       
                if((itgtm->second[n]==itapm->second[m])&&(itgtm->second[n+1]==itapm->second[m+1]))
                {
                    cout<<itgtm->first;           
                }
            }
        }
    }
}

From the code I get debug assertion failed as "vector subscript out of range".
Can ony one please fix the problem?

2
Contributors
1
Reply
8
Views
3 Years
Discussion Span
Last Post by nullptr
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.