首页 > 代码库 > multimap遍历与查找

multimap遍历与查找

 
    std::multimap<int, std::string> m; 	m.insert(std::make_pair(0, "w0"));	m.insert(std::make_pair(1, "w1"));	m.insert(std::make_pair(1, "w11"));	m.insert(std::make_pair(2, "w2")); 	for (std::multimap<int, std::string>::iterator it = m.begin(); it != m.end(); it++)	{		printf("%d - %s\n", it->first, it->second.c_str());	} 	std::multimap<int, std::string>::iterator fit = m.find(1); //just first one that key = 1	 	std::pair<std::multimap<int, std::string>::iterator, std::multimap<int, std::string>::iterator> pr = m.equal_range(1); //all that key = 1	std::multimap<int, std::string>::iterator pit = pr.first;	while (pit != pr.second)	{		printf("%d - %s\n", pit->first, pit->second.c_str());		pit++;	}