關於map vector 多層嵌套,最後內存的釋放方式

if (m_pMapVectorSymbol != NULL)
	{
		for (TMapVectorSymbol::TMapIterator iter = m_pMapVectorSymbol->m_pMapParameter->begin(); iter != m_pMapVectorSymbol->m_pMapParameter->end(); ++iter)
		{
			TVectorSymbol *pVectorSymbol = iter->second;
			if (pVectorSymbol != NULL)
			{
				for (TVectorSymbol::iterator iter1 = pVectorSymbol->begin(); iter1 != pVectorSymbol->end(); ++iter1)
				{
					CMapSingleParameter *pMapSingleParameter = *iter1;
					SAFE_DELETE(pMapSingleParameter);
				}
				SAFE_DELETE(pVectorSymbol);
			}
		}
		SAFE_DELETE(m_pMapVectorSymbol);
	}
	if (m_pLatelyVectorSymbol != NULL)
	{
		for (TVectorSymbol::iterator iter = m_pLatelyVectorSymbol->begin(); iter != m_pLatelyVectorSymbol->end(); ++iter)
		{
			CMapSingleParameter *pMapSingleParameter = *iter;
			SAFE_DELETE(pMapSingleParameter);
		}
		SAFE_DELETE(m_pLatelyVectorSymbol);
	}

其中
m_pMapVectorSymbol  的原型是:TMapVectorSymbol *m_pMapVectorSymbol;
typedef vector<CMapSingleParameter*> TVectorSymbol;
typedef MapParameter<xstring, TVectorSymbol*> TMapVectorSymbol;

<pre name="code" class="cpp">m_pLatelyVectorSymbol 的原型是:TVectorSymbol *m_pLatelyVectorSymbol;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章