map

Published

1.CSPMapStringToPtr map;

G:\stock\TskingVS2019\src\Client\StkLib\Src\SelfDB.cpp

//从文件中加载财务数据  2019/06/08 by freeman
int CSelfDB::LoadBasetable(CStockContainer& container)
{
	container.Lock();

	CSPMapStringToPtr	map;
	map.InitHashTable(container.GetSize() + container.GetSize() + 100);

	for (int i=0; i<container.GetSize(); i++)
	{
		CStockInfo	& info	= container.ElementAt(i);
		map.SetAt(info.GetStockCode(), (void *)i);
		info.m_basedata.RemoveAll();
	}
	
	CSPString	sFileName	= GetRootPath();
	sFileName	+= self_chna_basetbl;
	CSPFile	file;
	if (file.Open(sFileName, CSPFile::modeRead | CSPFile::shareDenyNone))
	{
		BASEDATA	block;
		while(sizeof(block) == file.Read(&block, sizeof(block)))
		{
			void * pArrayID	= NULL;
			if (map.Lookup(block.m_szCode, pArrayID))
			{
				int	nIndex	= ((int)pArrayID);
				if (nIndex >= 0 && nIndex < container.GetSize())
				{
					container.ElementAt(nIndex).m_basedata.InsertBaseDataSort(block);
				}
			}
		}
		file.Close();
	}

	container.UnLock();
	return container.GetSize();
}