0

当我使用 map.equal_range() 时,我在迭代地图时遇到问题 ..我的编译器说 's_it = Krange.std::pair<> 中的 'operator=' 不匹配,'operator !=' 不匹配?? 我很困惑,无法弄清楚为什么以下是我的代码

void Pdb2Cluster_test
(
    multimap <string, unsigned> & pigAccmap,
    multimap <unsigned, proteininfo> & map2
)
{
    // CArgs args = GetArgs();
    //AnsiString v = diff_b;
    multimap<string , unsigned>::iterator imp;

    multimap<string,proteininfo>::iterator s_it;
    multimap<string, pdbbinfo>::iterator ip;
    // set<string>::iterator idp;
    unsigned pig_b;
    int start, stop;
    // int mststar, mstto;
    unsigned cluster, domgi;
    string pdb_ele;


    pdb_ele = "3ST9A";

    imp = pigAccmap.find(pdb_ele);
    if (imp != pigAccmap.end())
    {    pig_b = imp->second;

        std::pair<multimap<unsigned, proteininfo>::iterator, multimap<unsigned,proteininfo>::iterator> Krange;
        Krange  = map2.equal_range(pig_b);
        for (s_it = Krange.first; s_it != Krange.second; s_it++)
        {
            domgi= s_it->second.domgi;
            start= s_it->second.seqstar;
            stop= s_it->second.seqstop;
            cout<<"\t"<<cluster<<"\t"<<pdb_ele<<"\t" <<pig_b<<"\t"<<domgi<<"\t"<<start<<"\t"<<stop<<endl;
            //   myfile<<cluster<<"\t"<<pdb_ele<<"\t" <<domgi<<"\t"<<start<<"\t"<<stop<<endl;

        }
        imp++;
    }
}

我只需要迭代第二个多图,所以忽略我提到的第一个循环的 map.find() http://www.cplusplus.com/reference/map/multimap/equal_range/ ....

4

1 回答 1

1

的类型map2std::multimap<unsigned, proteininfo>

的类型s_itstd::multimap<std::string, proteininfo>::iterator

这些不匹配。

你可以通过使用一些 typedef 来节省一些麻烦,比如

typedef std::multimap<std::string, proteininfo> protein_map_type;
于 2013-01-18T18:55:02.673 回答