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


C++ Words::count方法代码示例

本文整理汇总了C++中Words::count方法的典型用法代码示例。如果您正苦于以下问题:C++ Words::count方法的具体用法?C++ Words::count怎么用?C++ Words::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Words的用法示例。


在下文中一共展示了Words::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findLicense

LicensePos findLicense( const Words & words, const QList< Statement > & license,
	int & idx )
{
	LicensePos res{ -1, -1 };

	int firstWord = 0;

	// Find first real word.
	for( int i = 0; i < license.count(); ++i )
	{
		if( license.at( i ).type() == Statement::Word )
		{
			firstWord = i;

			break;
		}
	}

	auto first = words.cbegin();
	first += idx;

	auto it = std::find( first, words.cend(), WordWithPlace{
		license.at( firstWord ), -1, -1 } );

	while( it != words.cend() )
	{
		idx = std::distance( words.cbegin(), it );

		bool found = true;
		int wp = idx;

		for( int j = firstWord; j < license.count(); ++j )
		{
			if( license.at( j ).type() == Statement::Word )
			{
				// Skip line endings.
				while( wp < words.count() &&
					words.at( wp ).m_st.type() == Statement::LineEnding )
				{
					++wp;
				}

				if( wp >= words.count() )
				{
					found = false;

					break;
				}

				if( license.at( j ).word() != words.at( wp ).m_st.word() )
				{
					found = false;

					break;
				}
			}
			else if( license.at( j ).type() == Statement::SkipLine )
			{
				bool skipped = false;

				if( wp < words.count() &&
					words.at( wp ).m_st.type() == Statement::LineEnding )
				{
					++wp;

					skipped = true;
				}

				while( wp < words.count() &&
					words.at( wp ).m_st.type() != Statement::LineEnding )
				{
					++wp;

					skipped = true;
				}

				if( ( wp >= words.count() && j < license.count() - 1 ) ||
					!skipped )
				{
					found = false;

					break;
				}

				if( wp < words.count() - 1 &&
					words.at( wp ).m_st.type() == Statement::LineEnding )
						--wp;
			}
			else if( license.at( j ).type() == Statement::SkipWord )
			{
				// Skip line endings.
				while( wp < words.count() &&
					words.at( wp ).m_st.type() == Statement::LineEnding )
				{
					++wp;
				}
			}

			if( j < license.count() - 1 )
				++wp;
//.........这里部分代码省略.........
开发者ID:igormironchik,项目名称:tools,代码行数:101,代码来源:utils.cpp


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