本文整理汇总了C++中Words::at方法的典型用法代码示例。如果您正苦于以下问题:C++ Words::at方法的具体用法?C++ Words::at怎么用?C++ Words::at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Words
的用法示例。
在下文中一共展示了Words::at方法的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;
//.........这里部分代码省略.........