void CStatCounterArray::GenerateGameStats (CGameStats &Stats) // GenerateGameStats // // Adds the list of stats to the target { // Loop over all sections CMapIterator i; m_Array.Reset(i); while (m_Array.HasMore(i)) { TMap<CString, SEntry> *pSection; CString sSection = m_Array.GetNext(i, &pSection); // Loop over all stats CMapIterator j; pSection->Reset(j); while (pSection->HasMore(j)) { SEntry *pEntry; CString sStat = pSection->GetNext(j, &pEntry); // Add it Stats.Insert(sStat, ::strFormatInteger(pEntry->iCount, -1, FORMAT_THOUSAND_SEPARATOR | FORMAT_UNSIGNED), sSection, pEntry->sSort); } } }
int CMarkovWordGenerator::GenerateUnique (int iCount, TArray<CString> *retArray) // GenerateUnique // // Generates an array of unique words { int i; TMap<CString, DWORD> Generated; for (i = 0; i < iCount; i++) { int iTriesLeft = 500; while (iTriesLeft > 0) { // Generate a random word CString sWord = Generate(); // Lookup the word in our map. If we found it, // try again. if (Generated.Find(sWord)) { iTriesLeft--; continue; } // If it is unique, add it Generated.Insert(sWord, 1); break; } // If we couldn't find a unique word, then quit if (iTriesLeft == 0) break; } // Add the entries that we generated to the output array CMapIterator j; Generated.Reset(j); int iGeneratedCount = 0; while (Generated.HasMore(j)) { DWORD *pDummy; CString sWord = Generated.GetNext(j, &pDummy); retArray->Insert(sWord); iGeneratedCount++; } return iGeneratedCount; }