0

I have issues to iterate map when i use map.equal_range() ..my compiler says there is no no match for 'operator=' in 's_it = Krange.std::pair<> and no match for 'operator != '?? I am confused and cannot figure out why following is piece of my code

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++;
    }
}

I only need to iterator the 2nd multimap so ignore the map.find() for the 1st loop I referred http://www.cplusplus.com/reference/map/multimap/equal_range/....

WhozCraig
  • 65,258
  • 11
  • 75
  • 141
user1830108
  • 195
  • 1
  • 15

1 Answers1

1

The type of map2 is std::multimap<unsigned, proteininfo>.

The type of s_it is std::multimap<std::string, proteininfo>::iterator.

These don't match up.

You might save some trouble by using some typedefs, like

typedef std::multimap<std::string, proteininfo> protein_map_type;
aschepler
  • 70,891
  • 9
  • 107
  • 161