当前位置: 首页>>代码示例>>C++>>正文


C++ Array::GetCapacity方法代码示例

本文整理汇总了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() );
    }
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:16,代码来源:ObjectListNode.cpp

示例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 ] );
	}
}
开发者ID:JeremieA,项目名称:fastbuild,代码行数:86,代码来源:AString.cpp


注:本文中的Array::GetCapacity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。