当前位置: 首页>>代码示例>>C++>>正文


C++ NodeSet::insert方法代码示例

本文整理汇总了C++中NodeSet::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeSet::insert方法的具体用法?C++ NodeSet::insert怎么用?C++ NodeSet::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeSet的用法示例。


在下文中一共展示了NodeSet::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsReachable

bool IsReachable(ControlFlowNode *head, ControlFlowNode *tail)
{
    if (head == tail)
    {
        return true;
    }

    NodeSet visited;
    visited.insert(tail);

    stack<ControlFlowNode*> toProcess;
    toProcess.push(tail);
    while (!toProcess.empty())
    {
        ControlFlowNode *node = toProcess.top();
        toProcess.pop();

        for (ControlFlowNode *pred : node->Predecessors())
        {
            if (pred == head)
            {
                return true;
            }

            if (!visited.contains(pred))
            {
                visited.insert(pred);
                toProcess.push(pred);
            }
        }
    }
    return false;
}
开发者ID:OmerMor,项目名称:SCICompanion-1,代码行数:33,代码来源:TarjanAlgorithm.cpp

示例2: runtime_error

// -----------------------------------------------------------------------------
Graph *SpanningTree::create_spanning_tree(Graph* g, Node* root) {
   if(root == NULL)
      throw std::runtime_error("create_spanning_tree NULL exception");

   Graph *t = new Graph(FLAG_DAG);
   NodeSet visited;
   NodeStack node_stack;
   node_stack.push(root);

   while(!node_stack.empty()) {
      Node* n = node_stack.top();
      node_stack.pop();
      visited.insert(n);
      Node* tree_node1 = t->add_node_ptr(n->_value);
     
      EdgePtrIterator* eit = n->get_edges();
      Edge* e;
      while((e = eit->next()) != NULL) {
         Node* inner_node = e->traverse(n);
         if(inner_node != NULL && visited.count(inner_node) == 0) {
            Node* tree_node2 = t->add_node_ptr(inner_node->_value);
            t->add_edge(tree_node1, tree_node2, e->weight, e->label);
            node_stack.push(inner_node);
            visited.insert(inner_node);
         } 
      }
      delete eit;
   }

   return t;
}
开发者ID:DDMAL,项目名称:Gamera,代码行数:32,代码来源:spanning_tree.cpp

示例3: getLeftNeighbours

NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) {
	NodeSet *leftv = new NodeSet;
	NodeSet::iterator i=scanline.find(v);
	while(i--!=scanline.begin()) {
		Node *u=*(i);
		if(u->r->overlapX(v->r)<=0) {
			leftv->insert(u);
			return leftv;
		}
		if(u->r->overlapX(v->r)<=u->r->overlapY(v->r)) {
			leftv->insert(u);
		}
	}
	return leftv;
}
开发者ID:step21,项目名称:inkscape-osx-packaging-native,代码行数:15,代码来源:generate-constraints.cpp

示例4: getRightNeighbours

NodeSet* getRightNeighbours(NodeSet &scanline,Node *v) {
	NodeSet *rightv = new NodeSet;
	NodeSet::iterator i=scanline.find(v);
	for(++i;i!=scanline.end(); ++i) {
		Node *u=*(i);
		if(u->r->overlapX(v->r)<=0) {
			rightv->insert(u);
			return rightv;
		}
		if(u->r->overlapX(v->r)<=u->r->overlapY(v->r)) {
			rightv->insert(u);
		}
	}
	return rightv;
}
开发者ID:step21,项目名称:inkscape-osx-packaging-native,代码行数:15,代码来源:generate-constraints.cpp

示例5: CollectNodesBetween

// Returns the set of all nodes between tail and head, assuming 
// head and tail form a single entry and exit point.
// Possible is there just for debugging. There should be no nodes outside possible
NodeSet CollectNodesBetween(ControlFlowNode *head, ControlFlowNode *tail, NodeSet possible)
{
    NodeSet collection;
    stack<ControlFlowNode*> toProcess;
    toProcess.push(tail);
    while (!toProcess.empty())
    {
        ControlFlowNode *node = toProcess.top();
        toProcess.pop();

        collection.insert(node);
        if (node != head)
        {
            for (ControlFlowNode *pred : node->Predecessors())
            {
                if (!collection.contains(pred)) // Haven't already visited it
                {
                    assert(possible.contains(pred));// We could just filter these, but let's assert for now to catch bad callers.
                    toProcess.push(pred);
                }
            }
        }
    }
    return collection;
}
开发者ID:OmerMor,项目名称:SCICompanion-1,代码行数:28,代码来源:TarjanAlgorithm.cpp

示例6: separateConnectedComponents

 void LazyConstraintCallback::separateConnectedComponents( Graph          const & g
                                                         , GraphVariables const & vars
                                                         , Graph::Node    const & root
                                                         , NodeSetVector  const & nonZeroNodesComponents
                                                         , int                  & nCuts
                                                         ) {
   IloExpr rhs( getEnv() );

   for ( const NodeSet& S : nonZeroNodesComponents ) {
     // only consider the non-zero components that don't contain the root
     auto it = S.find( root );
     if ( it == S.end() || it->componentIndex() != root.componentIndex() ) {
       // determine dS
       NodeSet dS;
       for ( Graph::Node i : S ) {
         for ( Graph::Edge e : g.incEdges( i ) ) {
           Graph::Node j = g.oppositeNode( i, e );
           if ( S.find( j ) == S.end() )
           {
             dS.insert( j );
           }
         }
       }

       constructRHS( vars, dS, S, rhs );
       for ( Graph::Node i : S ) {
         assert( isValid( g, i, dS, S ) );
         add( vars.xVars[vars.nodeToIndex[i]] <= rhs, IloCplex::UseCutPurge ).end();
         ++nCuts;
       }
     }
   }

   rhs.end();
 }
开发者ID:falcong,项目名称:xheinz,代码行数:35,代码来源:LazyConstraintCallback.cpp

示例7: functionGreaterEqual

void State::functionGreaterEqual(const string& a_name, int a_value)
{
	NodeSet* parentSet = getVariableNodes(a_name);
	if (parentSet == NULL)
	{
		error("State::functionGreaterEqual - variable " + a_name + " doesn't exist" , false);
		return;
	}
	NodeSet removedRoots;
	for (NodeSetConstIter iter = parentSet->begin(); iter != parentSet->end(); iter++)
	{
		if ((*iter) == NULL)
		{
			error("State::functionGreaterEqual - iterator for variable " + a_name + " is NULL", false);
			continue;
		}

		if ((*iter)->getMaxValue() < a_value)
		{
			debug("State::functionGreaterEqual - Adding " + a_name + "'s root to removedRoots set");
			removedRoots.insert((*iter)->getRoot());
			continue;
		}

		if ((*iter)->getMinValue() < a_value)
		{
			(*iter)->setMinValue(a_value);
		}
	}

	debug("State::functionGreaterEqual - removing trees");
	removeTrees(removedRoots);
}
开发者ID:IdoBegun,项目名称:PAAV_Project,代码行数:33,代码来源:State.cpp

示例8: isValid

 bool Callback::isValid( Graph       const & g
                       , Graph::Node const & i
                       , NodeSet     const & dS
                       , NodeSet     const & S) const {
   if ( S.find( i ) == S.end() ) {
     // i must be in S
     return false;
   }

   if ( dS.find( i ) != dS.end() ) {
     // i must not be in dS
     return false;
   }

   // determine dS again
   NodeSet ddS;
   for ( Graph::Node i : S ) {
     for ( Graph::Edge e : g.incEdges( i) ) {
       Graph::Node j = g.oppositeNode( i, e );
       if ( S.find( j ) == S.end() )
       {
         ddS.insert( j );
       }
     }
   }

   return dS == ddS;
 }
开发者ID:falcong,项目名称:xheinz,代码行数:28,代码来源:Callback.cpp

示例9: reset

Item::Ptr UTransform::TransformResult::next(DynamicContext *context)
{
    context->testInterrupt();

    AutoVariableStoreReset reset(context, &scope_);

    if(toDo_) {
        toDo_ = false;

        NodeSet copiedNodes = NodeSet(nodecompare(context));

        VectorOfCopyBinding::const_iterator end = transform_->getBindings()->end();
        for(VectorOfCopyBinding::const_iterator it = transform_->getBindings()->begin();
                it != end; ++it) {
            if((*it)->qname_ == 0) continue;

            Sequence values = (*it)->expr_->createResult(context)->toSequence(context);

            // Keep a record of the nodes that have been copied
            Result valIt = values;
            Item::Ptr val;
            while((val = valIt->next(context)).notNull()) {
                copiedNodes.insert((Node*)val.get());
            }

            scope_.setVar((*it)->uri_, (*it)->name_, values);
        }

        // Get the pending update list
        PendingUpdateList pul = transform_->getModifyExpr()->createUpdateList(context);

        // Check that the targets of the pending updates are copied nodes
        for(PendingUpdateList::const_iterator i = pul.begin(); i != pul.end(); ++i) {
            Node::Ptr target = i->getTarget();
            while(copiedNodes.find(target) == copiedNodes.end()) {
                target = target->dmParent(context);
                if(target.isNull()) {
                    XQThrow3(StaticErrorException,X("UTransform::staticTyping"),
                             X("The target node of an update expression in the transform expression is not a node from the copy clauses [err:XUDY0014]"), &(*i));
                }
            }
        }

        // Apply the updates
        AutoDelete<UpdateFactory> ufactory(context->createUpdateFactory());
        ufactory->applyUpdates(pul, context, transform_->getRevalidationMode());

        // Execute the return expression
        result_ = transform_->getReturnExpr()->createResult(context);
    }

    Item::Ptr result = result_->next(context);

    if(result.isNull()) {
        result_ = 0;
        return 0;
    }

    return result;
}
开发者ID:kanbang,项目名称:Colt,代码行数:60,代码来源:UTransform.cpp

示例10:

    void ActionChoiceWindow::ActionNode::getAllNodes(ActionNode* treeRoot, NodeSet& nodes)
	{
		nodes.insert(treeRoot);
		const NodeSet children = treeRoot->getChildren();
		
		for (NodeSet::const_iterator iter = children.begin(); iter != children.end(); iter++)
			getAllNodes(*iter, nodes);
	}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:8,代码来源:ActionChoiceWindow.cpp

示例11: nodes_for_root

static void nodes_for_root(GepNode *Root, NodeChildrenMap &NCM,
                           NodeSet &Nodes) {
    NodeVect Work;
    Work.push_back(Root);
    Nodes.insert(Root);

    while (!Work.empty()) {
      NodeVect::iterator First = Work.begin();
      GepNode *N = *First;
      Work.erase(First);
      NodeChildrenMap::iterator CF = NCM.find(N);
      if (CF != NCM.end()) {
        Work.insert(Work.end(), CF->second.begin(), CF->second.end());
        Nodes.insert(CF->second.begin(), CF->second.end());
      }
    }
}
开发者ID:crabtw,项目名称:llvm,代码行数:17,代码来源:HexagonCommonGEP.cpp

示例12: getAllReachedUses

NodeSet Liveness::getAllReachedUses(RegisterRef RefRR,
      NodeAddr<DefNode*> DefA, const RegisterAggr &DefRRs) {
  NodeSet Uses;

  // If the original register is already covered by all the intervening
  // defs, no more uses can be reached.
  if (DefRRs.hasCoverOf(RefRR))
    return Uses;

  // Add all directly reached uses.
  // If the def is dead, it does not provide a value for any use.
  bool IsDead = DefA.Addr->getFlags() & NodeAttrs::Dead;
  NodeId U = !IsDead ? DefA.Addr->getReachedUse() : 0;
  while (U != 0) {
    auto UA = DFG.addr<UseNode*>(U);
    if (!(UA.Addr->getFlags() & NodeAttrs::Undef)) {
      RegisterRef UR = UA.Addr->getRegRef(DFG);
      if (PRI.alias(RefRR, UR) && !DefRRs.hasCoverOf(UR))
        Uses.insert(U);
    }
    U = UA.Addr->getSibling();
  }

  // Traverse all reached defs. This time dead defs cannot be ignored.
  for (NodeId D = DefA.Addr->getReachedDef(), NextD; D != 0; D = NextD) {
    auto DA = DFG.addr<DefNode*>(D);
    NextD = DA.Addr->getSibling();
    RegisterRef DR = DA.Addr->getRegRef(DFG);
    // If this def is already covered, it cannot reach anything new.
    // Similarly, skip it if it is not aliased to the interesting register.
    if (DefRRs.hasCoverOf(DR) || !PRI.alias(RefRR, DR))
      continue;
    NodeSet T;
    if (DFG.IsPreservingDef(DA)) {
      // If it is a preserving def, do not update the set of intervening defs.
      T = getAllReachedUses(RefRR, DA, DefRRs);
    } else {
      RegisterAggr NewDefRRs = DefRRs;
      NewDefRRs.insert(DR);
      T = getAllReachedUses(RefRR, DA, NewDefRRs);
    }
    Uses.insert(T.begin(), T.end());
  }
  return Uses;
}
开发者ID:bugsnag,项目名称:llvm,代码行数:45,代码来源:RDFLiveness.cpp

示例13: DefRRs

std::pair<NodeSet,bool>
Liveness::getAllReachingDefsRecImpl(RegisterRef RefRR, NodeAddr<RefNode*> RefA,
      NodeSet &Visited, const NodeSet &Defs, unsigned Nest, unsigned MaxNest) {
  if (Nest > MaxNest)
    return { NodeSet(), false };
  // Collect all defined registers. Do not consider phis to be defining
  // anything, only collect "real" definitions.
  RegisterAggr DefRRs(PRI);
  for (NodeId D : Defs) {
    const auto DA = DFG.addr<const DefNode*>(D);
    if (!(DA.Addr->getFlags() & NodeAttrs::PhiRef))
      DefRRs.insert(DA.Addr->getRegRef(DFG));
  }

  NodeList RDs = getAllReachingDefs(RefRR, RefA, false, true, DefRRs);
  if (RDs.empty())
    return { Defs, true };

  // Make a copy of the preexisting definitions and add the newly found ones.
  NodeSet TmpDefs = Defs;
  for (NodeAddr<NodeBase*> R : RDs)
    TmpDefs.insert(R.Id);

  NodeSet Result = Defs;

  for (NodeAddr<DefNode*> DA : RDs) {
    Result.insert(DA.Id);
    if (!(DA.Addr->getFlags() & NodeAttrs::PhiRef))
      continue;
    NodeAddr<PhiNode*> PA = DA.Addr->getOwner(DFG);
    if (Visited.count(PA.Id))
      continue;
    Visited.insert(PA.Id);
    // Go over all phi uses and get the reaching defs for each use.
    for (auto U : PA.Addr->members_if(DFG.IsRef<NodeAttrs::Use>, DFG)) {
      const auto &T = getAllReachingDefsRecImpl(RefRR, U, Visited, TmpDefs,
                                                Nest+1, MaxNest);
      if (!T.second)
        return { T.first, false };
      Result.insert(T.first.begin(), T.first.end());
    }
  }

  return { Result, true };
}
开发者ID:bugsnag,项目名称:llvm,代码行数:45,代码来源:RDFLiveness.cpp

示例14: getAllReachedUses

NodeSet Liveness::getAllReachedUses(RegisterRef RefRR,
      NodeAddr<DefNode*> DefA, const RegisterSet &DefRRs) {
  NodeSet Uses;

  // If the original register is already covered by all the intervening
  // defs, no more uses can be reached.
  if (RAI.covers(DefRRs, RefRR, DFG))
    return Uses;

  // Add all directly reached uses.
  NodeId U = DefA.Addr->getReachedUse();
  while (U != 0) {
    auto UA = DFG.addr<UseNode*>(U);
    if (!(UA.Addr->getFlags() & NodeAttrs::Undef)) {
      auto UR = UA.Addr->getRegRef();
      if (RAI.alias(RefRR, UR, DFG) && !RAI.covers(DefRRs, UR, DFG))
        Uses.insert(U);
    }
    U = UA.Addr->getSibling();
  }

  // Traverse all reached defs.
  for (NodeId D = DefA.Addr->getReachedDef(), NextD; D != 0; D = NextD) {
    auto DA = DFG.addr<DefNode*>(D);
    NextD = DA.Addr->getSibling();
    auto DR = DA.Addr->getRegRef();
    // If this def is already covered, it cannot reach anything new.
    // Similarly, skip it if it is not aliased to the interesting register.
    if (RAI.covers(DefRRs, DR, DFG) || !RAI.alias(RefRR, DR, DFG))
      continue;
    NodeSet T;
    if (DFG.IsPreservingDef(DA)) {
      // If it is a preserving def, do not update the set of intervening defs.
      T = getAllReachedUses(RefRR, DA, DefRRs);
    } else {
      RegisterSet NewDefRRs = DefRRs;
      NewDefRRs.insert(DR);
      T = getAllReachedUses(RefRR, DA, NewDefRRs);
    }
    Uses.insert(T.begin(), T.end());
  }
  return Uses;
}
开发者ID:tpoechtrager,项目名称:llvm-dsymutil,代码行数:43,代码来源:RDFLiveness.cpp

示例15: numNodes

uint64_t CVC4::theory::bv::utils::numNodes(TNode node, NodeSet& seen) {
  if (seen.find(node) != seen.end())
    return 0;

  uint64_t size = 1;
  for (unsigned i = 0; i < node.getNumChildren(); ++i) {
    size += numNodes(node[i], seen);
  }
  seen.insert(node);
  return size;
}
开发者ID:kbansal,项目名称:CVC4,代码行数:11,代码来源:theory_bv_utils.cpp


注:本文中的NodeSet::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。