本文整理汇总了C++中IdList::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ IdList::contains方法的具体用法?C++ IdList::contains怎么用?C++ IdList::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdList
的用法示例。
在下文中一共展示了IdList::contains方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: elementsFromBlock
IdList RefactoringApplier::elementsFromBlock(QString const &blockType) const
{
IdList list;
IdList resultList;
IdList const refactoringElements = mRefactoringRepoApi->children(Id::rootId());
foreach (Id const &refactoringElement, refactoringElements) {
if (mRefactoringRepoApi->isGraphicalElement(refactoringElement)) {
if (refactoringElement.element() == "RefactoringDiagramNode") {
list = mRefactoringRepoApi->children(refactoringElement);
foreach (Id const &id, list) {
if (id.element() == blockType) {
resultList.append(mRefactoringRepoApi->children(id));
break;
}
}
foreach (Id const &id, list) {
if (id.element() == "Link" && resultList.contains(toInRule(id))
&& resultList.contains(fromInRule(id)))
{
resultList.append(id);
}
}
}
}
}
示例2: setItemsToDelete
void MultipleRemoveCommand::setItemsToDelete(IdList &itemsToDelete)
{
IdList itemsToUpdate;
addEdgesToBeDeleted(itemsToDelete);
// QGraphicsScene::selectedItems() returns items in no particular order,
// so we should handle parent-child relationships manually
while (!itemsToDelete.isEmpty()) {
const Id currentItem = itemsToDelete.at(0);
const IdList children = mGraphicalApi.children(currentItem);
foreach (const Id &child, children) {
itemsToDelete.removeAll(child);
// Child remove commands will be added in currentItem delete command
}
const bool isEdge = !mLogicalApi.editorManagerInterface().isGraphicalElementNode(currentItem);
if (isEdge) {
const Id src = mGraphicalApi.from(currentItem);
if (src != Id() && !itemsToUpdate.contains(src)) {
itemsToUpdate.append(src);
}
const Id dst = mGraphicalApi.to(currentItem);
if (dst != Id() && !itemsToUpdate.contains(dst)) {
itemsToUpdate.append(dst);
}
insertPreAction(graphicalDeleteCommand(currentItem), 0);
} else {
addPreAction(graphicalDeleteCommand(currentItem));
}
itemsToDelete.removeAll(currentItem);
}
示例3: logCycle
void
FunctionDefinitionRecursion::determineCycles(const Model& m)
{
IdIter it;
IdRange range;
IdList variables;
IdMap logged;
std::string id;
variables.clear();
/* create a list of variables that are cycles ie (x, x) */
for (it = mIdMap.begin(); it != mIdMap.end(); it++)
{
if ((*it).first == (*it).second)
{
id = (*it).first;
if (!variables.contains(id))
{
variables.append(id);
}
}
}
/* loop thru other dependencies for each; if the dependent is also
* in the list then this is the cycle
* keep a record of logged dependencies to avoid logging twice
*/
for (unsigned int n = 0; n < variables.size(); n++)
{
id = variables.at((int)n);
range = mIdMap.equal_range(id);
for (it = range.first; it != range.second; it++)
{
if (((*it).second != id)
&& (variables.contains((*it).second))
&& !alreadyExistsInMap(logged,
pair<const std::string, std::string>(id, (*it).second))
&& !alreadyExistsInMap(logged,
pair<const std::string, std::string>((*it).second, id)))
{
logCycle(m.getFunctionDefinition(id), m.getFunctionDefinition((*it).second));
logged.insert(pair<const std::string, std::string>(id, (*it).second));
}
}
}
}
示例4: diagramsFromList
IdList LogicalModelAssistApi::diagramsFromList(IdList const &list) const
{
// TODO: diagrams are kinda special, so we need the editor to be able to
// tell us whether this particular element is a diagram or not
IdList result;
foreach (Id type, list) {
if (type.element().split("_").back().contains("Diagram", Qt::CaseInsensitive)) {
if (!result.contains(type))
result.append(type);
}
}
return result;
}
示例5: nodeInfo
QList<NodeInfo> Clipboard::nodesData(const IdList &elements)
{
QList<NodeInfo> nodes;
for (const Id &item : elements) {
if (mModels.graphicalModelAssistApi().editorManagerInterface().isNodeOrEdge(item) > 0
&& !elements.contains(mModels.graphicalModelAssistApi().parent(item)))
{
nodes << nodeInfo(item);
}
}
for (const NodeInfo &node : nodes) {
addChildren(node.id(), nodes);
}
return nodes;
}
示例6:
bool
containsId(const ASTNode* ast, std::string id)
{
bool present = false;
List* variables = ast->getListOfNodes(ASTNode_isName);
IdList vars;
for (unsigned int i = 0; i < variables->getSize(); i++)
{
ASTNode* node = static_cast<ASTNode*>(variables->get(i));
string name = node->getName() ? node->getName() : "";
vars.append(name);
}
if (vars.contains(id))
{
present = true;
}
delete variables;
return present;
}
示例7: makeDetour
bool RulesChecker::makeDetour(Id const ¤tNode, IdList &usedNodes)
{
if (usedNodes.contains(currentNode)) {
return false; // cannot learn some more here
}
if (!mDiagramElements.contains(currentNode)) {
return true; // we already have made detour of forward nodes
}
mDiagramElements.removeOne(currentNode);
usedNodes.append(currentNode);
if (currentNode.element() != "MessageFlow" && isLink(currentNode)) {
Id const destinationNode = mGRepoApi->to(currentNode);
if (destinationNode == Id::rootId()) {
postError(noEndNode, currentNode); // we've already put info that link is incorrect
return true; // done end-job for link(50%)
}
return makeDetour(destinationNode, usedNodes);
}
if (isEndNode(currentNode)) {
return true; // we found real end-node
}
IdList frontNodes = outgoingSequenceFlow(currentNode);
if (frontNodes.isEmpty()) {
postError(noEndNode, currentNode);
return true; // done end-job for nodes (now 100%)
}
bool foundFinalNode = false; // to catch that we have found end-node anywhere in path
foreach (Id const &node, frontNodes) {
if (makeDetour(node, usedNodes)) {
foundFinalNode = true;
}
}
return foundFinalNode;
}
示例8: DisablePackageOnChildDocuments
// simple callback disabling packages on child documents
int DisablePackageOnChildDocuments(Model* m, SBMLErrorLog *, void* userdata)
{
if (m == NULL) return LIBSBML_OPERATION_FAILED;
IdList *pkgsToStrip = static_cast<IdList*>(userdata);
XMLNamespaces *ns = m->getSBMLNamespaces()->getNamespaces();
for (int i = 0; i < ns->getLength(); i++)
{
std::string nsURI = ns->getURI(i);
std::string package = ns->getPrefix(i);
if (package.empty() == true)
{
continue;
}
else if (pkgsToStrip->contains(package) == true)
{
m->enablePackageInternal(nsURI, package, false);
}
}
return LIBSBML_OPERATION_SUCCESS;
}
示例9: if
/* in L1 and L2 there were built in values for key units
* such as 'volume', 'length', 'area', 'substance' and 'time'
* In L3 these have been removed - thus if a model uses one of these
* it needs a unitDefinition to define it
*/
void
Model::addDefinitionsForDefaultUnits()
{
/* create a list of unit values */
IdList unitsUsed;
unsigned int n;
bool implicitVolume = false;
bool implicitArea = false;
bool implicitLength = false;
bool implicitSubstance = false;
for (n = 0; n < getNumCompartments(); n++)
{
if (getCompartment(n)->isSetUnits())
{
unitsUsed.append(getCompartment(n)->getUnits());
}
else
{
if (getCompartment(n)->getSpatialDimensions() == 3)
{
implicitVolume = true;
getCompartment(n)->setUnits("volume");
}
else if (getCompartment(n)->getSpatialDimensions() == 2)
{
implicitArea = true;
getCompartment(n)->setUnits("area");
}
else if (getCompartment(n)->getSpatialDimensions() == 1)
{
implicitLength = true;
getCompartment(n)->setUnits("length");
}
}
}
for (n = 0; n < getNumSpecies(); n++)
{
if (getSpecies(n)->isSetSubstanceUnits())
{
unitsUsed.append(getSpecies(n)->getSubstanceUnits());
}
else
{
implicitSubstance = true;
getSpecies(n)->setSubstanceUnits("substance");
}
if (getSpecies(n)->isSetSpatialSizeUnits())
unitsUsed.append(getSpecies(n)->getSpatialSizeUnits());
}
for (n = 0; n < getNumParameters(); n++)
{
if (getParameter(n)->isSetUnits())
unitsUsed.append(getParameter(n)->getUnits());
}
if (getUnitDefinition("volume") == NULL)
{
if (unitsUsed.contains("volume") || implicitVolume)
{
UnitDefinition * ud = createUnitDefinition();
ud->setId("volume");
Unit * u = ud->createUnit();
u->setKind(UnitKind_forName("litre"));
u->setScale(0);
u->setExponent(1.0);
u->setMultiplier(1.0);
setVolumeUnits("volume");
}
else
{
setVolumeUnits("litre");
}
}
else
{
setVolumeUnits("volume");
}
if (getUnitDefinition("substance") == NULL)
{
if (unitsUsed.contains("substance") || implicitSubstance)
{
UnitDefinition * ud = createUnitDefinition();
ud->setId("substance");
Unit * u = ud->createUnit();
u->setKind(UnitKind_forName("mole"));
u->setScale(0);
u->setExponent(1.0);
u->setMultiplier(1.0);
setSubstanceUnits("substance");
//.........这里部分代码省略.........
示例10: IdList
//.........这里部分代码省略.........
if (mModel->getReaction(i)->isSetKineticLaw())
{
if (mModel->getReaction(i)->getKineticLaw()->isSetMath())
{
SBMLTransforms::replaceFD(const_cast <ASTNode *> (mModel
->getReaction(i)->getKineticLaw()->getMath()),
mModel->getListOfFunctionDefinitions(), &idsToSkip);
}
}
for (j = 0; j < mModel->getReaction(i)->getNumReactants(); j++)
{
if (mModel->getReaction(i)->getReactant(j)->isSetStoichiometryMath())
{
if (mModel->getReaction(i)->getReactant(j)->getStoichiometryMath()
->isSetMath())
{
SBMLTransforms::replaceFD(const_cast <ASTNode *> (mModel
->getReaction(i)->getReactant(j)->getStoichiometryMath()->getMath()),
mModel->getListOfFunctionDefinitions(), &idsToSkip);
}
}
}
for (j = 0; j < mModel->getReaction(i)->getNumProducts(); j++)
{
if (mModel->getReaction(i)->getProduct(j)->isSetStoichiometryMath())
{
if (mModel->getReaction(i)->getProduct(j)->getStoichiometryMath()
->isSetMath(), &idsToSkip)
{
SBMLTransforms::replaceFD(const_cast <ASTNode *> (mModel
->getReaction(i)->getProduct(j)->getStoichiometryMath()->getMath()),
mModel->getListOfFunctionDefinitions(), &idsToSkip);
}
}
}
}
for (i = 0; i < mModel->getNumEvents(); i++)
{
if (mModel->getEvent(i)->isSetTrigger())
{
if (mModel->getEvent(i)->getTrigger()->isSetMath())
{
SBMLTransforms::replaceFD(const_cast <ASTNode *> (mModel
->getEvent(i)->getTrigger()->getMath()),
mModel->getListOfFunctionDefinitions(), &idsToSkip);
}
}
if (mModel->getEvent(i)->isSetDelay())
{
if (mModel->getEvent(i)->getDelay()->isSetMath())
{
SBMLTransforms::replaceFD(const_cast <ASTNode *> (mModel
->getEvent(i)->getDelay()->getMath()),
mModel->getListOfFunctionDefinitions(), &idsToSkip);
}
}
if (mModel->getEvent(i)->isSetPriority())
{
if (mModel->getEvent(i)->getPriority()->isSetMath())
{
SBMLTransforms::replaceFD(const_cast <ASTNode *> (mModel
->getEvent(i)->getPriority()->getMath()),
mModel->getListOfFunctionDefinitions(), &idsToSkip);
}
}
for(j = 0; j < mModel->getEvent(i)->getNumEventAssignments(); j++)
{
if (mModel->getEvent(i)->getEventAssignment(j)->isSetMath())
{
SBMLTransforms::replaceFD(const_cast <ASTNode *> (mModel
->getEvent(i)->getEventAssignment(j)->getMath()),
mModel->getListOfFunctionDefinitions(), &idsToSkip);
}
}
}
/* replace original consistency checks */
mDocument->setApplicableValidators(origValidators);
unsigned int size = mModel->getNumFunctionDefinitions();
unsigned int skipped = 0;
while (size--)
{
const std::string& id = mModel->getListOfFunctionDefinitions()->get(size)->getId();
if (idsToSkip.contains(id))
{
++skipped;
continue;
}
delete mModel->getListOfFunctionDefinitions()->remove(size);
}
success = (mModel->getNumFunctionDefinitions() == skipped);
if (success) return LIBSBML_OPERATION_SUCCESS;
return LIBSBML_OPERATION_FAILED;
}