Iterate through index_name, for each value you traverse, now try to find
inside name_age by calling find on it. Now if it is found, put it temporary
map.

Now the iteration is over, clear index_name map. Put all the values from
temporary map into _name map.


On 9 May 2013 21:40, Nishant Pandey <nishant.bits.me...@gmail.com> wrote:

> This is my code snippet
> #include <iostream.h>
> #include <string>
> #include <set>
> #include <map>
> #include <vector>
> #include <sstream>
> #include <cctype>
> using namespace std;
>
> void work() {
> map<string, int> name_age;
> map<int,string> index_name;
> map<int,string> index_name_temp;
> std::map< int, string >::iterator it;
>
> name_age["abc"] = 12;
> name_age["pqr"] = 1;
> name_age["stu"] = 13;
>
> index_name[0] = "abc";
> index_name[1] = "pqr";
> index_name[2] = "stu";
>
> cout << name_age["abc"] << endl;
> cout << index_name[1];
> name_age.erase("abc");
>
> index_name_temp[0] = "abc';
>
> for ( it = index_name.begin(); it != index_name.end(); ++it )
>     {
>           cout<< (*it).second << " ";
>     }
>
> In this i have deleted key "abc" first from hash table name_age in the
> next hash table index_namei have "abc" as value i want to erase the "abc"
> entry from index_name table too,
> The idea is to first iterate on hash_map index_name when found "abc"
> delete the entry from index_name but how to compare "abc" in index_name map.
>
> as we cant do if (strcmp((*it).second, "abc") ==0 ) in this , how do i do
> the comparision please help
>
>
> }
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
>
>
>



-- 
regards,
soumya prasad ukil

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Reply via email to