本文整理汇总了C++中expression::List::last方法的典型用法代码示例。如果您正苦于以下问题:C++ List::last方法的具体用法?C++ List::last怎么用?C++ List::last使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类expression::List
的用法示例。
在下文中一共展示了List::last方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOperands
void PairContainer::setOperands(const Expression::List &ops)
{
Q_ASSERT(ops.count() == 2);
m_operand1 = ops.first();
m_operand2 = ops.last();
Q_ASSERT(m_operand1);
Q_ASSERT(m_operand2);
}
示例2: invokeOptimizers
Expression::Ptr Expression::invokeOptimizers(const Expression::Ptr &expr,
const StaticContext::Ptr &context)
{
Q_ASSERT(expr);
const OptimizationPass::List opts(expr->optimizationPasses());
if(opts.isEmpty()) /* Early exit. */
{
return expr;
}
const OptimizationPass::List::const_iterator passEnd(opts.constEnd());
const OptimizationPass::List::const_iterator end(opts.constEnd());
OptimizationPass::List::const_iterator passIt(opts.constBegin());
for(; passIt != passEnd; ++passIt) /* Invoke each optimization pass. */
{
const OptimizationPass::Ptr pass(*passIt); /* Alias, for readability. */
OptimizationPass::ExpressionMarker sourceMarker(pass->sourceExpression);
if(pass->startIdentifier && !pass->startIdentifier->matches(expr))
{
/* This pass specified a start identifier and it did
* not match -- let's try the next OptimizationPass. */
continue;
}
const ExpressionIdentifier::List::const_iterator idEnd(pass->operandIdentifiers.constEnd());
ExpressionIdentifier::List::const_iterator idIt(pass->operandIdentifiers.constBegin());
const Expression::List ops(expr->operands());
const Expression::List::const_iterator opEnd(ops.constEnd());
Expression::List::const_iterator opIt(ops.constBegin());
switch(pass->operandsMatchMethod)
{
case OptimizationPass::Sequential:
{
for(; opIt != opEnd; ++opIt)
{
const Expression::Ptr operand(*opIt); /* Alias, for readability. */
const ExpressionIdentifier::Ptr opIdentifier(*idIt); /* Alias, for readability. */
if(opIdentifier && !opIdentifier->matches(operand))
{
break;
}
++idIt;
}
if(opIt == opEnd)
break; /* All operands matched, so this pass matched. */
else
{
/* The loop above did not finish which means all operands did not match.
Therefore, this OptimizationPass did not match -- let's try the next one. */
continue;
}
}
case OptimizationPass::AnyOrder:
{
Q_ASSERT_X(ops.count() == 2, Q_FUNC_INFO,
"AnyOrder is currently only supported for Expressions with two operands.");
if(pass->operandIdentifiers.first()->matches(ops.first()) &&
pass->operandIdentifiers.last()->matches(ops.last()))
{
break;
}
else if(pass->operandIdentifiers.first()->matches(ops.last()) &&
pass->operandIdentifiers.last()->matches(ops.first()))
{
sourceMarker.first() = 1;
sourceMarker[1] = 0;
break; /* This pass matched. */
}
else
continue; /* This pass didn't match, let's loop through the next pass. */
}
}
/* Figure out the source Expression, if any. */
Expression::List operands;
Expression::Ptr sourceExpr;
if(!sourceMarker.isEmpty())
{
const OptimizationPass::ExpressionMarker::const_iterator mEnd(sourceMarker.constEnd());
OptimizationPass::ExpressionMarker::const_iterator mIt(sourceMarker.constBegin());
sourceExpr = expr;
for(; mIt != mEnd; ++mIt)
{
Q_ASSERT(*mIt >= 0);
sourceExpr = sourceExpr->operands().at(*mIt);
}
operands.append(sourceExpr);
}
if(operands.isEmpty())
//.........这里部分代码省略.........