CMapStringToString map;
CString key,value;
map.SetAt("kye1","value1");
map["key2"] = "value2"; map.RemoveKey("key1");
//map.RemoveAll();/* POSITION pos = map.GetStartPosition();
while( NULL != pos)
{
map.GetNextAssoc(pos,key,value);
MessageBox(key+"\t"+value); }
#ifdef _DEBUG
afxDump.SetDepth( 1 );
afxDump << "RemoveKey example: " << &map << "\n";
#endif
*/
设置断点调试或ctrl+f10运行到光标处可以看到afxDump的内容.
lookpu好像也有问题
CString key,value;
map.SetAt("kye1","value1");
map["key2"] = "value2"; map.RemoveKey("key1");
//map.RemoveAll();/* POSITION pos = map.GetStartPosition();
while( NULL != pos)
{
map.GetNextAssoc(pos,key,value);
MessageBox(key+"\t"+value); }
#ifdef _DEBUG
afxDump.SetDepth( 1 );
afxDump << "RemoveKey example: " << &map << "\n";
#endif
*/
设置断点调试或ctrl+f10运行到光标处可以看到afxDump的内容.
lookpu好像也有问题
CMapStringToString map;
int nHashLen = .....;
map.InitHashTable( nHashLen );
........
nHashLen是哈希表的大小,MSDN建议设为映射中的元素个数的120%(元素个数可以大致估计一下,保守一点比较好)