本文整理汇总了C++中TArray::GetCount方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::GetCount方法的具体用法?C++ TArray::GetCount怎么用?C++ TArray::GetCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::GetCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeAverages
void ComputeAverages (const TArray<int> &Records, int *retiMax, int *retiAverage, int *retiMin)
{
int i;
if (Records.GetCount() == 0)
{
*retiMax = 0;
*retiAverage = 0;
*retiMin = 0;
return;
}
int iMax = Records[0];
int iMin = Records[0];
int iTotal = Records[0];
for (i = 1; i < Records.GetCount(); i++)
{
if (Records[i] < iMin)
iMin = Records[i];
else if (Records[i] > iMax)
iMax = Records[i];
iTotal += Records[i];
}
*retiMax = iMax;
*retiAverage = iTotal / Records.GetCount();
*retiMin = iMin;
}
示例2: MsgHousekeeping
void CAeonEngine::MsgHousekeeping (const SArchonMessage &Msg, const CHexeSecurityCtx *pSecurityCtx)
// MsgHousekeeping
//
// Arc.housekeeping
{
int i;
ASSERT(pSecurityCtx == NULL);
// Get the list of all tables (in a semaphore)
TArray<CAeonTable *> AllTables;
GetTables(&AllTables);
if (AllTables.GetCount() == 0)
return;
// Compute how much memory data we want each table to keep in memory
// before it flushes to disk. (x2 because most tables won't use the
// maximum.
DWORD dwMemoryPerTable = 2 * m_dwMaxMemoryUse / AllTables.GetCount();
// Loop over all tables and let them do some housekeeping tasks (such as
// saving updated rows and compacting segments).
for (i = 0; i < AllTables.GetCount(); i++)
AllTables[i]->Housekeeping(dwMemoryPerTable);
}
示例3: CreateFromAttributeList
bool CDatum::CreateFromAttributeList (const CAttributeList &Attribs, CDatum *retdDatum)
// CreateFromAttributeList
//
// Creates a datum from an attribute list
{
int i;
TArray<CString> AllAttribs;
Attribs.GetAll(&AllAttribs);
if (AllAttribs.GetCount() == 0)
{
*retdDatum = CDatum();
return true;
}
CComplexArray *pArray = new CComplexArray;
for (i = 0; i < AllAttribs.GetCount(); i++)
pArray->Insert(AllAttribs[i]);
*retdDatum = CDatum(pArray);
return true;
}
示例4: AddLabelExpansion
void CSystemCreateStats::AddLabelExpansion (const CString &sAttributes, const CString &sPrefix)
// AddLabelExpansion
//
// Expands and adds the given attributes to the label counter
{
int i;
TArray<CString> Attribs;
ParseAttributes(sAttributes, &Attribs);
// Add each of the attributes alone (and make a list of permutations)
TArray<CString> Permutable;
for (i = 0; i < Attribs.GetCount(); i++)
{
if (m_PermuteAttribs.Find(Attribs[i]))
Permutable.Insert(Attribs[i]);
else
AddEntry(Attribs[i]);
}
// Now add all permutations
if (Permutable.GetCount() >= 1)
AddEntryPermutations(NULL_STR, Permutable, 0);
}
示例5: GetAverageValue
CurrencyValue CLevelTableOfItemGenerators::GetAverageValue (int iLevel)
// GetAverageValue
//
// Returns the average value.
{
int i;
// Compute the table for this level.
Metric rTotal = 0.0;
int iTotalChance = 0;
for (i = 0; i < m_Table.GetCount(); i++)
{
int iChance = GetFrequencyByLevel(m_Table[i].sLevelFrequency, iLevel);
iTotalChance += iChance;
}
for (i = 0; i < m_Table.GetCount(); i++)
{
int iChance = GetFrequencyByLevel(m_Table[i].sLevelFrequency, iLevel);
if (iChance > 0)
rTotal += (m_Table[i].Count.GetAveValueFloat() * (Metric)m_Table[i].pEntry->GetAverageValue(iLevel) * (Metric)iChance / (Metric)iTotalChance);
}
return (CurrencyValue)(rTotal + 0.5);
}
示例6: GetCountAdj
Metric CGroupOfGenerators::GetCountAdj (int iLevel)
// GetCountAdj
//
// Returns the count adjusment for the given level.
{
int i;
if (iLevel >= 0 && iLevel < m_CountAdj.GetCount())
{
Metric rCountAdj = m_CountAdj[iLevel];
if (rCountAdj < 0.0)
{
// Loop over all our children and compute the average value.
Metric rTotal = 0.0;
for (i = 0; i < m_Table.GetCount(); i++)
rTotal += (Metric)m_Table[i].pItem->GetAverageValue(iLevel);
// Compute the factor that we have to multiply the total to get to
// the desired value.
rCountAdj = (rTotal > 0.0 ? (Metric)m_AverageValue[iLevel] / rTotal : 0.0);
// Remember so we don't have to compute it again.
m_CountAdj[iLevel] = rCountAdj;
}
return rCountAdj;
}
else
return 0.0;
}
示例7: LoadFromXML
ALERROR CGroupOfGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)
// LoadFromXML
//
// Load from XML
{
int i;
ALERROR error;
// Load content elements
m_Table.InsertEmpty(pDesc->GetContentElementCount());
for (i = 0; i < m_Table.GetCount(); i++)
{
CXMLElement *pEntry = pDesc->GetContentElement(i);
m_Table[i].iChance = pEntry->GetAttributeInteger(CHANCE_ATTRIB);
if (m_Table[i].iChance == 0)
m_Table[i].iChance = 100;
CString sCount = pEntry->GetAttribute(COUNT_ATTRIB);
if (sCount.IsBlank())
m_Table[i].Count = DiceRange(0, 0, 1);
else
m_Table[i].Count.LoadFromXML(sCount);
if (error = IItemGenerator::CreateFromXML(Ctx, pEntry, &m_Table[i].pItem))
return error;
}
// See if we force an average value
CString sAttrib;
if (pDesc->FindAttribute(LEVEL_VALUE_ATTRIB, &sAttrib))
{
TArray<int> Values;
ParseIntegerList(sAttrib, 0, &Values);
m_AverageValue.InsertEmpty(MAX_ITEM_LEVEL + 1);
m_AverageValue[0] = 0;
for (i = 0; i < Values.GetCount(); i++)
m_AverageValue[i + 1] = Values[i];
for (i = Values.GetCount() + 1; i <= MAX_ITEM_LEVEL; i++)
m_AverageValue[i] = 0;
}
else if (pDesc->FindAttribute(VALUE_ATTRIB, &sAttrib))
{
int iValue = strToInt(sAttrib, 0);
m_AverageValue.InsertEmpty(MAX_ITEM_LEVEL + 1);
m_AverageValue[0] = 0;
for (i = 1; i <= MAX_ITEM_LEVEL; i++)
m_AverageValue[i] = iValue;
}
return NOERROR;
}
示例8: GetKeyEventStat
CString CPlayerGameStats::GetKeyEventStat (const CString &sStat, const CString &sNodeID, const CDesignTypeCriteria &Crit) const
// GetKeyEventStat
//
// Returns the given key event stat
{
int i;
// Get the list of stats
TArray<SKeyEventStatsResult> List;
if (!GetMatchingKeyEvents(sNodeID, Crit, &List))
return NIL_VALUE;
if (strEquals(sStat, OBJS_DESTROYED_STAT))
{
// Mark the events that we're interested in
for (i = 0; i < List.GetCount(); i++)
List[i].bMarked = ((List[i].pStats->iType == eventEnemyDestroyedByPlayer)
|| (List[i].pStats->iType == eventFriendDestroyedByPlayer)
|| (List[i].pStats->iType == eventMajorDestroyed));
// Done
return GenerateKeyEventStat(List);
}
else if (strEquals(sStat, ENEMY_OBJS_DESTROYED_STAT))
{
// Mark the events that we're interested in
for (i = 0; i < List.GetCount(); i++)
List[i].bMarked = (List[i].pStats->iType == eventEnemyDestroyedByPlayer);
// Done
return GenerateKeyEventStat(List);
}
else if (strEquals(sStat, FRIENDLY_OBJS_DESTROYED_STAT))
{
// Mark the events that we're interested in
for (i = 0; i < List.GetCount(); i++)
List[i].bMarked = (List[i].pStats->iType == eventFriendDestroyedByPlayer);
// Done
return GenerateKeyEventStat(List);
}
else
return NULL_STR;
}
示例9: Lock
CMultiverseNewsEntry *CMultiverseModel::GetNextNewsEntry (void)
// GetNextNewsEntry
//
// Returns the next news entry to display.
//
// NOTE: We return a copy which the callers are responsible for freeing.
{
CSmartLock Lock(m_cs);
int i;
// First make a list of all available news entries
TArray<CMultiverseNewsEntry *> Available;
for (i = 0; i < m_News.GetCount(); i++)
{
CMultiverseNewsEntry *pEntry = m_News.GetEntry(i);
// If we've already shown this entry, skip it.
if (pEntry->IsShown())
continue;
// If this entry does not match the collection criteria, then skip it.
if (m_Collection.HasAnyUNID(pEntry->GetExcludedUNIDs()))
continue;
if (!m_Collection.HasAllUNIDs(pEntry->GetRequiredUNIDs()))
continue;
Available.Insert(pEntry);
}
// If none available, nothing
if (Available.GetCount() == 0)
return NULL;
// Pick a random entry
CMultiverseNewsEntry *pEntry = Available[mathRandom(0, Available.GetCount() - 1)];
// Mark the entry as having been shown
m_News.ShowNews(pEntry);
// return this entry
return new CMultiverseNewsEntry(*pEntry);
}
示例10: OutputByAttribute
void OutputByAttribute (SItemTableCtx &Ctx, const SItemTypeList &ItemList)
{
int i, j;
// Make a categorized list by attribute
SByAttributeTypeList ByAttributeTable;
for (i = 0; i < ItemList.GetCount(); i++)
{
const CString &sKey = ItemList.GetKey(i);
CItemType *pType = ItemList[i];
// Loop over all attributes
TArray<CString> Attribs;
ParseAttributes(pType->GetAttributes(), &Attribs);
for (j = 0; j < Attribs.GetCount(); j++)
{
bool bNew;
SAttributeEntry *pEntry = ByAttributeTable.SetAt(Attribs[j], &bNew);
if (bNew)
pEntry->sAttribute = Attribs[j];
pEntry->ItemTable.Insert(sKey, pType);
}
// If no attribute
if (Attribs.GetCount() == 0)
{
bool bNew;
SAttributeEntry *pEntry = ByAttributeTable.SetAt(CONSTLIT("(none)"), &bNew);
if (bNew)
pEntry->sAttribute = CONSTLIT("(none)");
pEntry->ItemTable.Insert(sKey, pType);
}
}
// Now loop over all attributes
for (i = 0; i < ByAttributeTable.GetCount(); i++)
{
const SAttributeEntry &Entry = ByAttributeTable[i];
printf("%s\n\n", Entry.sAttribute.GetASCIIZPointer());
OutputHeader(Ctx);
OutputTable(Ctx, Entry.ItemTable);
printf("\n");
}
}
示例11: FlushTableRows
bool CAeonEngine::FlushTableRows (void)
// FlushTableRows
//
// Save all in-memory rows to disk
{
int i;
// Get a list of all tables
TArray<CAeonTable *> AllTables;
GetTables(&AllTables);
// Loop over each table
bool bAllSucceeded = true;
for (i = 0; i < AllTables.GetCount(); i++)
{
CString sError;
if (!AllTables[i]->Save(&sError))
{
Log(MSG_LOG_ERROR, strPattern("Unable to save table %s: %s", AllTables[i]->GetName(), sError));
bAllSucceeded = false;
// Continue saving other tables
}
}
// Done
return bAllSucceeded;
}
示例12: AddDevices
void CTableOfDeviceGenerators::AddDevices (SDeviceGenerateCtx &Ctx)
// AddDevices
//
// Add devices
{
int i, j;
int iCount = m_Count.Roll();
for (j = 0; j < iCount; j++)
{
int iRoll = mathRandom(1, m_iTotalChance);
for (i = 0; i < m_Table.GetCount(); i++)
{
iRoll -= m_Table[i].iChance;
if (iRoll <= 0)
{
m_Table[i].pDevice->AddDevices(Ctx);
break;
}
}
}
}
示例13: CreateDataFieldFromItemList
CString CreateDataFieldFromItemList (const TArray<CItem> &List)
// CreateDataFieldFromItemList
//
// Creates a data field string from a list of items
{
int i;
CCodeChain &CC = g_pUniverse->GetCC();
CMemoryWriteStream Output(10000);
if (Output.Create() != NOERROR)
return NULL_STR;
Output.Write("='(", 3);
for (i = 0; i < List.GetCount(); i++)
{
ICCItem *pItem = List[i].WriteToCCItem(CC);
if (pItem->IsError())
{
pItem->Discard(&CC);
return NULL_STR;
}
CString sItem = pItem->Print(&CC);
Output.Write(sItem.GetASCIIZPointer(), sItem.GetLength());
Output.Write(" ", 1);
pItem->Discard(&CC);
}
Output.Write(")", 1);
Output.Close();
return CString(Output.GetPointer(), Output.GetLength());
}
示例14: CalcNodeWeight
int CConquerNodesProc::CalcNodeWeight (CTopologyNode *pNode, TArray<SNodeWeight> &Weights, int *retiSuccessChance)
// CalcNodeWeight
//
// Calculates the weight of the given node
{
int i;
CTopologyNode::SCriteriaCtx Ctx;
Ctx.pTopology = NULL;
for (i = 0; i < Weights.GetCount(); i++)
{
if (pNode->MatchesCriteria(Ctx, Weights[i].Criteria))
{
if (retiSuccessChance)
*retiSuccessChance = Weights[i].iSuccessChance;
return Weights[i].iWeight;
}
}
if (retiSuccessChance)
*retiSuccessChance = 0;
return 0;
}
示例15: JoystickImageImpl
JoystickImageImpl(float sensitivity) :
m_sensitivity(sensitivity),
m_bJoystickEnabled(false),
m_bButtonsEnabled(false),
m_bJustEnabled(false)
{
//Imago 7/10
for (int index = 0; index < m_ppboolButton.GetCount(); index++) {
m_ppnumber[index] = new ModifiableNumber(false);
}
for (int index = 0; index < m_ppboolButton.GetCount(); index++) {
m_ppboolButton[index] = new ModifiableBoolean(false);
}
}