2017-10-02 6 views
2
vector<multimap<string, int> > allCount; 

地図のベクトルから最後のペアを取得したいと思います。マップのベクトルの最後のペア

int x = 0; 
for(iter = patternBase.begin(); iter != patternBase.end(); iter++) { 
    Tree t; 
    for(int j = 0; j < iter->second.size(); j++) { 
     for(int k = iter->second[j]->getPath().size() - 1; k >= 0 ; k--) 
      sets.push(iter->second[j]->getPath()[k]); 

     t.insertNode(sets, here I want to use last pair (value) of allCount[x] map); 
     cout << endl; 
    } 
    cout << endl; 
    x++; 
} 

答えて

1

あなたはこのようなイテレータを作成する必要があります。

multimap<string, int>::iterator it = allCount[x].end(); 

そして、最後の要素でそれ地点作ってそれをデクリメント:最後に

it--; 

t.insertNode(sets, it->second); 
関連する問題