【C++】map容器的使用方法


#include <map>
#include <utility>
	map<int, int> mapTest;
	//添加元素
	mapTest.insert(make_pair(1, 1));
	//查找元素
	map<int, int>::iterator iterMap2;

	iterMap2 = mapTest.find(1);
	iterMap2->first;
	iterMap2->second
	map<int,IplImage*>::iterator iterMap2;
		iterMap2=m_oShowBDManager.oImageIndex.find(nSegFrame);  //如果不存在时  返回末端迭代器
		if (iterMap2==m_oShowBDManager.oImageIndex.end())
		{
			m_oShowBDManager.oImageIndex.insert(make_pair(nSegFrame,pImage));
		}

	map<int,IplImage*>::iterator iterMap;
	for (iterMap=m_oShowBDManager.oImageIndex.begin();iterMap!=m_oShowBDManager.oImageIndex.end();)
	{
		if (iterMap->first==m_nCurrentFrame)
		{
			iterMap=m_oShowBDManager.oImageIndex.erase(iterMap);
		}
		else
			iterMap++;
	}

	map<int,IplImage*>::iterator iterMap;
	for (iterMap=m_oShowBDManager.oImageIndex.begin();iterMap!=m_oShowBDManager.oImageIndex.end();iterMap++)
	{
		vtkConstIpl.push_back(iterMap->second);
	}


你可能感兴趣的:(【C++】map容器的使用方法)