本文整理汇总了C++中Array::GetCapacity方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::GetCapacity方法的具体用法?C++ Array::GetCapacity怎么用?C++ Array::GetCapacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::GetCapacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetInputFiles
// GetInputFiles
//------------------------------------------------------------------------------
void ObjectListNode::GetInputFiles( Array< AString > & files ) const
{
// only valid to call on ObjectListNode (not LibraryNode)
ASSERT( GetType() == Node::OBJECT_LIST_NODE );
files.SetCapacity( files.GetCapacity() + m_DynamicDependencies.GetSize() );
for ( Dependencies::Iter i = m_DynamicDependencies.Begin();
i != m_DynamicDependencies.End();
i++ )
{
const Node * n = i->GetNode();
files.Append( n->GetName() );
}
}
示例2: Tokenize
// Tokenize
//------------------------------------------------------------------------------
void AString::Tokenize( Array< AString > & tokens, char splitChar ) const
{
Array< const char * > tokenStarts;
Array< const char * > tokenEnds;
const char * pos = Get();
const char * end = GetEnd();
bool lookingForStart = true;
char quoteChar = 0;
while ( pos < end )
{
if ( lookingForStart )
{
if ( *pos == splitChar )
{
++pos;
continue;
}
// found the start of a new token
tokenStarts.Append( pos );
lookingForStart = false;
}
// hit a quote?
char c = *pos;
if ( ( c == '"' ) || ( c == '\'' ) )
{
if ( quoteChar == 0 )
{
// opening quote
quoteChar = c;
}
else if ( quoteChar == c )
{
// closing quote
quoteChar = 0;
}
else
{
// quote of the 'other' type - consider as part of token
}
}
else if ( c == splitChar )
{
if ( quoteChar == 0 )
{
tokenEnds.Append( pos );
lookingForStart = true;
}
else
{
// space inside quoted token - consider as part of token
}
}
else
{
// normal character part of token
}
++pos;
}
ASSERT( ( tokenStarts.GetSize() == tokenEnds.GetSize() ) ||
( tokenStarts.GetSize() == ( tokenEnds.GetSize() + 1 ) ) );
if ( tokenStarts.GetSize() > tokenEnds.GetSize() )
{
tokenEnds.Append( pos );
}
ASSERT( tokenStarts.GetSize() == tokenEnds.GetSize() );
// pre-size output to avoid reallocations
tokens.Clear();
const size_t numTokens( tokenStarts.GetSize() );
if ( tokens.GetCapacity() < numTokens )
{
tokens.SetCapacity( numTokens );
}
tokens.SetSize( numTokens );
// copy tokens
for ( size_t i=0; i<numTokens; ++i )
{
tokens[ i ].Assign( tokenStarts[ i ], tokenEnds[ i ] );
}
}