哈希表实现数据库id与name的绑定.txt
来自「图像处理学习的一些心得」· 文本 代码 · 共 47 行
TXT
47 行
需要初始化地哈希表//初始化要比数据内容大20%
CMap<int,int,CPoint,CPoint> myMap;
int i;
myMap.InitHashTable( 257 );
// Add 10 elements to the map.
for (i=0;i < 200;i++)
myMap[i] = CPoint(i, i);
// Remove the elements with even key values.
CPoint pt;
for (i=0; myMap.Lookup( i, pt ) ;i+=2)
{
myMap.RemoveKey( i );
}
使用SetAt函数则不需要初始化哈希表
CMap<int,int,CPoint,CPoint> myMap;
// Add 10 elements to the map.
for (int i=0;i < 10;i++)
myMap.SetAt( i, CPoint(i, i) );
// Remove the elements with even key values.
POSITION pos = myMap.GetStartPosition();
int nKey;
CPoint pt;
while (pos != NULL)
{
myMap.GetNextAssoc( pos, nKey, pt );
if ((nKey%2) == 0)
myMap.RemoveKey( nKey );
}
//技术储备
CMap<int,int,CString,CString> myMap;
......//该部分完成从数据库取出结构集,比如为Hospital_ID与HospitalName,其值分别赋值给:
int i=Hospital_ID;CString text=HospitalName
执行循环
myMap.SetAt( i, text);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?