本文整理汇总了C++中IdMap::find方法的典型用法代码示例。如果您正苦于以下问题:C++ IdMap::find方法的具体用法?C++ IdMap::find怎么用?C++ IdMap::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdMap
的用法示例。
在下文中一共展示了IdMap::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcMetrics
//
// CalcMetrics
// - Loop through the history and pre-calculate metrics used in the training
// - Also re-number the customer id's to fit in a fixed array
//
void Engine::CalcMetrics()
{
int i, cid;
IdItr itr;
wprintf(L"\nCalculating intermediate metrics\n");
// Process each row in the training set
for (i=0; i<m_nRatingCount; i++)
{
Data* rating = m_aRatings + i;
// Increment movie stats
m_aMovies[rating->MovieId].RatingCount++;
m_aMovies[rating->MovieId].RatingSum += rating->Rating;
// Add customers (using a map to re-number id's to array indexes)
itr = m_mCustIds.find(rating->CustId);
if (itr == m_mCustIds.end())
{
cid = 1 + (int)m_mCustIds.size();
// Reserve new id and add lookup
m_mCustIds[rating->CustId] = cid;
// Store off old sparse id for later
m_aCustomers[cid].CustomerId = rating->CustId;
// Init vars to zero
m_aCustomers[cid].RatingCount = 0;
m_aCustomers[cid].RatingSum = 0;
}
else
{
cid = itr->second;
}
// Swap sparse id for compact one
rating->CustId = cid;
m_aCustomers[cid].RatingCount++;
m_aCustomers[cid].RatingSum += rating->Rating;
}
// Do a follow-up loop to calc movie averages
for (i=0; i<MAX_MOVIES; i++)
{
Movie* movie = m_aMovies+i;
movie->RatingAvg = movie->RatingSum / (1.0 * movie->RatingCount);
movie->PseudoAvg = (3.23 * 25 + movie->RatingSum) / (25.0 + movie->RatingCount);
}
}