本文整理汇总了C++中TArray::DeleteAll方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::DeleteAll方法的具体用法?C++ TArray::DeleteAll怎么用?C++ TArray::DeleteAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::DeleteAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetList
void CEnergyFieldList::GetList (TArray<CEnergyField *> &List)
// GetList
//
// Returns all the fields in an array
{
List.DeleteAll();
CEnergyField *pField = m_pFirst;
while (pField)
{
if (!pField->IsDestroyed())
List.Insert(pField);
pField = pField->GetNext();
}
}
示例2: Format
void CTextBlock::Format (const SBlockFormatDesc &BlockFormat)
// Format
//
// Format the text for the given width
{
int i;
m_Formatted.DeleteAll();
// Keep looping until we've formatted all spans.
STextSpan *pSpan = (m_Text.GetCount() > 0 ? &m_Text[0] : NULL);
STextSpan *pSpanEnd = (pSpan ? pSpan + m_Text.GetCount() : NULL);
TArray<STextSpan> Line;
STextSpan LeftOver;
int y = 0;
while (pSpan)
{
// Add what we've got to the line
if (!pSpan->sText.IsBlank())
Line.Insert(*pSpan);
// If we've hit the end of the line, then we output everything we've
// got in the line to the formatted buffer.
if (pSpan->bEoP || (pSpan + 1) == pSpanEnd)
{
// Compute metrics for each span and the line as a whole.
int cyLineAscent = 0;
int cxLine = 0;
int cyLine = 0;
for (i = 0; i < Line.GetCount(); i++)
{
// Compute the max ascent of the line.
int cyAscent = Line[i].Format.pFont->GetAscent();
if (cyAscent > cyLineAscent)
cyLineAscent = cyAscent;
// Compute the width of each span, the total width of the line
// and the max height of the line.
int cyHeight;
Line[i].cx = Line[i].Format.pFont->MeasureText(Line[i].sText, &cyHeight);
cxLine += Line[i].cx;
if (cyHeight > cyLine)
cyLine = cyHeight;
}
// Compute to horz position of the line (based on block alignment)
int x;
if (BlockFormat.iHorzAlign == alignRight && BlockFormat.cxWidth != -1)
x = BlockFormat.cxWidth - cxLine;
else if (BlockFormat.iHorzAlign == alignCenter && BlockFormat.cxWidth != -1)
x = (BlockFormat.cxWidth - cxLine) / 2;
else
x = 0;
// Format all the spans for this line
for (i = 0; i < Line.GetCount(); i++)
{
SFormattedTextSpan *pFormatted = m_Formatted.Insert();
pFormatted->sText = Line[i].sText;
pFormatted->Format = Line[i].Format;
pFormatted->x = x;
pFormatted->y = y + (cyLineAscent - Line[i].Format.pFont->GetAscent());
pFormatted->cx = Line[i].cx;
pFormatted->cy = Line[i].Format.pFont->GetHeight();
// Advance the line width
x += Line[i].cx;
}
// Advance the line
y += cyLine;
Line.DeleteAll();
}
// Next
pSpan++;
if (pSpan >= pSpanEnd)
pSpan = NULL;
}
}
示例3: GenerateRandomConnections
void CIntGraph::GenerateRandomConnections (DWORD dwStartNode, int iMinConnections, int iMaxConnections)
// GenerateRandomConnections
//
// Generate random connection across all nodes.
{
int i, j;
// We start by making sure every node is connected with one other node.
// We keep track of the nodes that are connected and those that are not.
TArray<int> Connected;
TArray<int> NotConnected;
// All the nodes are part of the not-connected group
// (except for the start node)
for (i = 0; i < m_Nodes.GetCount(); i++)
if (i != dwStartNode && !NodeIsFree(GetNode(i)))
NotConnected.Insert(i);
Connected.Insert((int)dwStartNode);
// Loop until all nodes are connected
while (NotConnected.GetCount() > 0)
{
// Look for the shortest, non-overlapping distance
// between a node in the connected list and a node in the
// not-connected list.
int iBestDist2 = MAX_DIST2;
int iBestFrom = -1;
int iBestTo = -1;
for (i = 0; i < Connected.GetCount(); i++)
{
int iFrom = i;
SNode *pFrom = GetNode(Connected[iFrom]);
for (j = 0; j < NotConnected.GetCount(); j++)
{
int iTo = j;
SNode *pTo = GetNode(NotConnected[iTo]);
int xDist = pTo->x - pFrom->x;
int yDist = pTo->y - pFrom->y;
int iDist2 = xDist * xDist + yDist * yDist;
if (iDist2 < iBestDist2
&& !IsCrossingConnection(Connected[iFrom], NotConnected[iTo]))
{
iBestDist2 = iDist2;
iBestFrom = iFrom;
iBestTo = iTo;
}
}
}
// If we found a best distance, connect the two nodes
if (iBestFrom != -1)
{
Connect(Connected[iBestFrom], NotConnected[iBestTo]);
Connected.Insert(NotConnected[iBestTo]);
NotConnected.Delete(iBestTo);
}
// If we did not find the best distance, then it means that we could not
// connect without overlapping. In that case, just connect all the unconnected
else
{
for (i = 0; i < NotConnected.GetCount(); i++)
Connect(Connected[0], NotConnected[i]);
NotConnected.DeleteAll();
}
}
}
示例4: CreateCreditsAnimation
void CTranscendenceWnd::CreateCreditsAnimation (IAnimatron **retpAnimatron)
// CreateCreditsAnimation
//
// Creates full end credits
{
int i;
CAniSequencer *pSeq = new CAniSequencer;
int iTime = 0;
// Figure out the position
int xMidCenter = m_rcIntroMain.left + RectWidth(m_rcIntroMain) / 2;
int yMidCenter = m_rcIntroMain.bottom - RectHeight(m_rcIntroMain) / 3;
IAnimatron *pAnimation;
// Create credits
TArray<CString> Names;
Names.Insert(CONSTLIT("George Moromisato"));
m_UIRes.CreateMediumCredit(CONSTLIT("designed & created by"),
Names,
xMidCenter,
yMidCenter,
150,
&pAnimation);
pSeq->AddTrack(pAnimation, iTime);
iTime += 150;
Names.DeleteAll();
Names.Insert(CONSTLIT("Michael Tangent"));
m_UIRes.CreateMediumCredit(CONSTLIT("music by"),
Names,
xMidCenter,
yMidCenter,
150,
&pAnimation);
pSeq->AddTrack(pAnimation, iTime);
iTime += 150;
// More programming
Names.DeleteAll();
for (i = 0; i < ADDITIONAL_PROGRAMMING_COUNT; i++)
Names.Insert(CString(ADDITIONAL_PROGRAMMING[i]));
m_UIRes.CreateMediumCredit(CONSTLIT("additional programming by"),
Names,
xMidCenter,
yMidCenter,
150,
&pAnimation);
pSeq->AddTrack(pAnimation, iTime);
iTime += ADDITIONAL_PROGRAMMING_COUNT * 150;
// Special thanks
Names.DeleteAll();
for (i = 0; i < SPECIAL_THANKS_COUNT; i++)
Names.Insert(CString(SPECIAL_THANKS[i]));
m_UIRes.CreateMediumCredit(CONSTLIT("special thanks to"),
Names,
xMidCenter,
yMidCenter,
150,
&pAnimation);
pSeq->AddTrack(pAnimation, iTime);
iTime += SPECIAL_THANKS_COUNT * 150;
// Thanks to
int yStart = m_rcIntroMain.top;
int yEnd = m_rcIntroMain.bottom - m_Fonts.Header.GetHeight();
CreateLongCreditsAnimation(xMidCenter + RectWidth(m_rcIntroMain) / 6,
yStart,
yEnd - yStart,
&pAnimation);
pSeq->AddTrack(pAnimation, iTime);
iTime += pAnimation->GetDuration();
// Done
*retpAnimatron = pSeq;
}
示例5: ParseRow
bool CCSVParser::ParseRow (TArray<CString> &Row, CString *retsError)
// ParseRow
//
// Parses a row
{
enum EStates
{
stateStart,
stateSingleQuote,
stateDoubleQuote,
stateInPlainValue,
stateEndOfValue,
stateCR,
stateLF,
};
Row.DeleteAll();
// Parse the BOM, if any
if (m_iFormat == formatUnknown)
m_iFormat = ParseBOM();
// Keep reading until we hit the end of the line.
EStates iState = stateStart;
CBuffer Value;
while (true)
{
switch (iState)
{
case stateStart:
{
switch (GetCurChar())
{
case '\0':
return true;
case ' ':
case '\t':
break;
case ',':
Row.Insert(NULL_STR);
break;
case '\r':
iState = stateCR;
break;
case '\n':
iState = stateLF;
break;
case '\'':
iState = stateSingleQuote;
break;
case '\"':
iState = stateDoubleQuote;
break;
default:
Value.WriteChar(GetCurChar());
iState = stateInPlainValue;
break;
}
break;
}
case stateSingleQuote:
{
switch (GetCurChar())
{
case '\0':
Row.Insert(CString(Value.GetPointer(), Value.GetLength()));
return true;
case '\'':
Row.Insert(CString(Value.GetPointer(), Value.GetLength()));
Value.SetLength(0);
iState = stateEndOfValue;
break;
default:
Value.WriteChar(GetCurChar());
break;
}
break;
}
case stateDoubleQuote:
{
switch (GetCurChar())
{
case '\0':
Row.Insert(CString(Value.GetPointer(), Value.GetLength()));
return true;
//.........这里部分代码省略.........