本文整理汇总了C++中KeyType::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyType::insert方法的具体用法?C++ KeyType::insert怎么用?C++ KeyType::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyType
的用法示例。
在下文中一共展示了KeyType::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lookupAssignment
/// lookupAssignment - Lookup a cached result for the given \arg query.
///
/// \param query - The query to lookup.
/// \param key [out] - On return, the key constructed for the query.
/// \param result [out] - The cached result, if the lookup is succesful. This is
/// either a satisfying assignment (for a satisfiable query), or 0 (for an
/// unsatisfiable query).
/// \return True if a cached result was found.
bool CexCachingSolver::lookupAssignment(const Query &query,
KeyType &key,
Assignment *&result) {
key = KeyType(query.constraints.begin(), query.constraints.end());
ref<Expr> neg = Expr::createIsZero(query.expr);
bool keyHasAddedConstraint = false;
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(neg)) {
if (CE->isFalse()) {
result = (Assignment*) 0;
++stats::queryCexCacheHits;
return true;
}
} else {
key.insert(neg);
keyHasAddedConstraint = true;
}
bool found = searchForAssignment(key, result);
if (found)
++stats::queryCexCacheHits;
else ++stats::queryCexCacheMisses;
if (keyHasAddedConstraint && !unsatCore.empty()) {
/// Here we remove the added component (neg)
/// from the unsatisfiability core.
unsatCore.erase(std::remove(unsatCore.begin(), unsatCore.end(), neg),
unsatCore.end());
}
return found;
}
示例2: lookupAssignment
/// lookupAssignment - Lookup a cached result for the given \arg query.
///
/// \param query - The query to lookup.
/// \param key [out] - On return, the key constructed for the query.
/// \param result [out] - The cached result, if the lookup is succesful. This is
/// either a satisfying assignment (for a satisfiable query), or 0 (for an
/// unsatisfiable query).
/// \return True if a cached result was found.
bool CexCachingSolver::lookupAssignment(const Query &query,
KeyType &key,
Assignment *&result) {
key = KeyType(query.constraints.begin(), query.constraints.end());
ref<Expr> neg = Expr::createIsZero(query.expr);
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(neg)) {
if (CE->isFalse()) {
result = (Assignment*) 0;
return true;
}
} else {
key.insert(neg);
}
return searchForAssignment(key, result);
}