Hello all, is there simple way to check if a multimap contains a value, or am I going to have to loop through all pairs?
thanks

Is this what you're looking for?

#include <iostream>
#include <map>


int main(int argc, char *argv[])
{
	
	std::multimap <int, double> MyMap;
	
	//create a mapping from "testone" to 111
	MyMap.insert(std::pair<int, double>(1, 1.2));
	
	//create an iterator
	std::map<int, double>::iterator iter;

	iter = MyMap.find(1);
	
    if(iter == MyMap.end())
    {
      std::cout << "Not found." << std::endl;
    }
    else
    {
	std::cout << "Found: " << iter->second << std::endl;	
    }
    
	return 0;
}

Dave

commented: Just the info I needed +2

Yes, thank you, that is what I was looking for. It's strange, the documentation I was reading said that find looked for the value, but the example showed that it would search for the key, so I was slightly unsure.

solved, thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.