本文整理汇总了C++中item::List::first方法的典型用法代码示例。如果您正苦于以下问题:C++ List::first方法的具体用法?C++ List::first怎么用?C++ List::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item::List
的用法示例。
在下文中一共展示了List::first方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onItemsFetched
void InfoCommand::onItemsFetched(KJob *job)
{
if (job->error() != 0) {
emit error(job->errorString());
emit finished(RuntimeError);
return;
}
ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob *>(job);
Q_ASSERT(fetchJob!=0);
Item::List items = fetchJob->items();
if (items.count()<1)
{
emit error(i18nc("@info:shell", "Cannot find '%1' as a collection or item", mEntityArg));
emit finished(RuntimeError);
return;
}
mInfoItem = new Item(items.first());
fetchParentPath(mInfoItem->parentCollection());
}
示例2: constantPropagate
Expression::Ptr Expression::constantPropagate(const StaticContext::Ptr &context) const
{
Q_ASSERT(context);
/* Optimization: We rewrite literals to literals here, which is pointless.
* Maybe we should have a property which says "doesn't disable elimination
* but don't eliminate me." */
if(staticType()->cardinality().allowsMany())
{
Item::Iterator::Ptr it(evaluateSequence(context->dynamicContext()));
Item::List result;
Item item(it->next());
while(item)
{
result.append(item);
item = it->next();
}
switch(result.count())
{
case 0:
return EmptySequence::create(this, context);
case 1:
return rewrite(Expression::Ptr(new Literal(result.first())), context);
default:
return rewrite(Expression::Ptr(new LiteralSequence(result)), context);
}
}
else
{
const Item item(evaluateSingleton(context->dynamicContext()));
if(item)
return rewrite(Expression::Ptr(new Literal(item)), context);
else
return EmptySequence::create(this, context);
}
}