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


C++ NodeSet类代码示例

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


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

示例1: evaluate

Value Filter::evaluate() const
{
    Value result = m_expression->evaluate();
    
    NodeSet& nodes = result.modifiableNodeSet();
    nodes.sort();

    EvaluationContext& evaluationContext = Expression::evaluationContext();
    for (auto& predicate : m_predicates) {
        NodeSet newNodes;
        evaluationContext.size = nodes.size();
        evaluationContext.position = 0;
        
        for (auto& node : nodes) {
            evaluationContext.node = node;
            ++evaluationContext.position;
            
            if (evaluatePredicate(*predicate))
                newNodes.append(node.copyRef());
        }
        nodes = WTFMove(newNodes);
    }

    return result;
}
开发者ID:eocanha,项目名称:webkit,代码行数:25,代码来源:XPathPath.cpp

示例2: writeRadiosFile

void ConfigFileWriter::writeRadiosFile(std::string filename, NodeSet& ns)
{
    std::fstream out;
    out.open(filename.c_str(), std::fstream::out | std::fstream::trunc);

    NodeSet::iterator it =  ns.begin();
    while (it != ns.end())
    {
        EntityStruct* ent = (*it)->entity;
        int len = strlen((char*)ent->marking.markingData);
        if (len == 0 || len > 11)
        {
            it++;
            continue;
        }

        RadioStruct* radio = (*it)->radio;
        if (radio)
        {
            out << (*it)->NodeId << ", ";
            out << ent->marking << ", ";
            out << radio->radioIndex << ", ";
            out << radio->relativePosition << ", ";
            out << radio->radioSystemType ;
            out << std::endl;
        }
        it++;
    }
    out.close();
}
开发者ID:LXiong,项目名称:ccn,代码行数:30,代码来源:configFiles.cpp

示例3: writeRouterModelFile

void ConfigFileWriter::writeRouterModelFile(std::string filename,
                                            NodeSet& ns)
{
    std::fstream out;

    std::set<std::string>::iterator it = ns.modelsUsed().begin();

    if (it != ns.modelsUsed().end())
    {
        out.open(filename.c_str(), std::fstream::out | std::fstream::trunc);
    }

    while (it != ns.modelsUsed().end())
    {
        ParameterMap* parameters = Config::instance().getModelParameterList(*it);
        const Parameter& model = parameters->getParameter("ROUTER-MODEL");
        if (model != Parameter::unknownParameter)
        {
            out << model << std::endl;
            ParameterMap::iterator pit = parameters->begin();
            while (pit != parameters->end())
            {
                if (pit->first != "ROUTER-MODEL")
                    out << pit->second << std::endl;
                pit++;
            }
            out << std::endl;
        }
        it++;
    }
}
开发者ID:LXiong,项目名称:ccn,代码行数:31,代码来源:configFiles.cpp

示例4: removeTrees

void State::removeTrees(const NodeSet& a_nodeSet)
{
	for (NodeSetConstIter iter = a_nodeSet.begin(); iter != a_nodeSet.end(); iter++)
	{
		removeTree(*iter);
	}
}
开发者ID:IdoBegun,项目名称:PAAV_Project,代码行数:7,代码来源:State.cpp

示例5: getVariableNodes

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

示例6: resolveNodeAndPushToNodeSet

 void XemProcessor::resolveNodeAndPushToNodeSet ( NodeSet& result, const String& nodeIdStr )
 {
   KeyId attributeKeyId = 0;
   ElementRef resolvedElement = resolveElementWithRole ( nodeIdStr, attributeKeyId );
   if ( !resolvedElement )
     {
       throwException ( Exception, "Could not resolve element fro '%s'.\n", nodeIdStr.c_str() );
     }
   if ( attributeKeyId )
     {
       AttributeRef attrRef = resolvedElement.findAttr ( attributeKeyId, AttributeType_String );
       if ( ! attrRef )
         {
           throwException ( Exception, "Could not get attr '%x' in element %s from '%s'\n", attributeKeyId,
               resolvedElement.generateVersatileXPath().c_str(), nodeIdStr.c_str() );
         }
       Log_XemRoleBased ( "Pushing attribute '%s'\n", attrRef.generateVersatileXPath().c_str() );
       result.pushBack ( attrRef );
     }
   else
     {
       Log_XemRoleBased ( "Pushing element '%s'\n", resolvedElement.generateVersatileXPath().c_str() );
       result.pushBack ( resolvedElement );
     }
 }
开发者ID:Doloops,项目名称:Xemeiah,代码行数:25,代码来源:xem-rolebased.cpp

示例7: getAlternatives

 /**
  * Gets the spelling alternatives to the specified query terms.
  * Returns a map with term as key and an Alternative object as value for each query term
  */
 std::map<std::string, Alternative> getAlternatives() {
     if (!_alternatives.empty())
         return _alternatives;
     _alternatives.clear();
     NodeSet alternatives = doc->FindFast("cps:reply/cps:content/alternatives_list/alternatives", true);
     for (unsigned int i = 0; i < alternatives.size(); i++) {
         Node *el = alternatives[i]->getFirstChild();
         Alternative alt;
         while (el != NULL) {
         	std::string name = el->getName();
             if (name == "to")
                 alt.to = el->getContent();
             else if (name == "count")
                 alt.count = atoi(el->getContentPtr());
             else if (name == "word") {
                 Alternative::Word w;
                 w.count = atoi(el->getAttribute("count")->getContentPtr());
                 w.h = atof(el->getAttribute("h")->getContentPtr());
                 w.idif = atof(el->getAttribute("idif")->getContentPtr());
                 w.cr = atof(el->getAttribute("cr")->getContentPtr());
                 w.content = el->getContent();
                 alt.words.push_back(w);
             }
             el = el->getNextSibling();
         }
         _alternatives[alt.to] = alt;
     }
     return _alternatives;
 }
开发者ID:clusterpoint,项目名称:cpp-client-api,代码行数:33,代码来源:AlternativesResponse.hpp

示例8: check_range_set

static bool check_range_set( EntityTopology type, NodeSet set, unsigned dim, bool value = true )
{
  const unsigned max_count[] = { NodeSet::NUM_CORNER_BITS, NodeSet::NUM_EDGE_BITS,
                                 NodeSet::NUM_FACE_BITS, NodeSet::NUM_REGION_BITS };
  
    // test that any bits corresponding to some other dimension are not set.
  for (unsigned d = 0; d <= 3; ++d) {
    if (d == dim)
      continue;
    
    for (unsigned i = 0; i < max_count[d]; ++i)
      if (!set.node( Sample(d,i) ) != value)
        return false;
  }
  
    // test that any bits for this dimension beyond the number for this
    // type are not set
  for (unsigned i = TopologyInfo::adjacent( type, dim ); i < max_count[dim]; ++i)
    if (!set.node( Sample(dim,i) ) != value)
      return false;
  
    // test that any bits for the type and dimension are set
  for (unsigned i = 0; i < TopologyInfo::adjacent( type, dim ); ++i)
    if (set.node( Sample(dim,i) ) == value)
      return false;

  return true;
}
开发者ID:haripandey,项目名称:trilinos,代码行数:28,代码来源:NodeSetTest.cpp

示例9: createButton

	void ActionChoiceWindow::createButtons(
		ActionNode* actions, const CEGUI::Point& center, 
		float radius, float angle, float angleWidth)
	{
		PushButton* button = NULL;

		if (actions->isLeaf())
		{
			button = createButton(actions->getAction()->getName(), center);
		}
		else
		{
			if (actions->getGroup() != NULL)
			{
				button = createButton(actions->getGroup()->getName(), center);
			}
			
            const NodeSet children = actions->getChildren();
			float angleStep = angleWidth / (float)children.size();
			float ang = children.size()>1 ? angle - angleWidth : angle - 180;
			for (NodeSet::const_iterator iter = children.begin(); 
				iter != children.end(); iter++)
			{
				CEGUI::Point centerChild = getPositionOnCircle(center, radius, ang);
				createButtons(*iter, centerChild, radius, ang, 60);
				ang += angleStep;
			}
		}

		actions->setButton(button);
		if (button != NULL)
			mWindow->addChildWindow(button);		
	}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:33,代码来源:ActionChoiceWindow.cpp

示例10: DLOG

void RegionGraph::constructCVM( const FactorGraph &fg, const std::vector<NodeSet> &cl) {
  using std::pair;

  DLOG(INFO) << "constructCVM called (" << fg.nrNodes() << " vars, " << fg.nrFactors() << " facs, " << cl.size() << " clusters)";

  // Retain only maximal clusters
  DLOG(INFO) << "  Constructing ClusterGraph";
  ClusterGraph cg( cl );
  DLOG(INFO) << "  Erasing non-maximal clusters";
  cg.eraseNonMaximal();

  // Create inner regions - first pass
  DLOG(INFO) << "  Creating inner regions (first pass)";
  std::set<NodeSet> betas;
  for( size_t alpha = 0; alpha < cg.nrClusters(); alpha++ )
    for( size_t alpha2 = alpha; (++alpha2) != cg.nrClusters(); ) {
      NodeSet intersection = cg.cluster(alpha) & cg.cluster(alpha2);
      if( intersection.size() > 0 )
        betas.insert( intersection );
    }

  // Create inner regions - subsequent passes
  DLOG(INFO) << "  Creating inner regions (next passes)";
  std::set<NodeSet> new_betas;
  do {
    new_betas.clear();
    for (std::set<NodeSet>::const_iterator gamma = betas.begin(); gamma != betas.end(); gamma++ )
      for (std::set<NodeSet>::const_iterator gamma2 = gamma; (++gamma2) != betas.end(); ) {
        NodeSet intersection = (*gamma) & (*gamma2);
        if( (intersection.size() > 0) && (betas.count(intersection) == 0) )
          new_betas.insert( intersection );
      }
    betas.insert(new_betas.begin(), new_betas.end());
  } while( new_betas.size() );

  // Create inner regions - final phase
  DLOG(INFO) << "  Creating inner regions (final phase)";
  std::vector<Region> irs;
  irs.reserve( betas.size() );
  for (std::set<NodeSet>::const_iterator beta = betas.begin(); beta != betas.end(); beta++ )
    irs.push_back( Region(*beta,0.0) );

  // Create edges
  DLOG(INFO) << "  Creating edges";
  std::vector<std::pair<size_t,size_t> > edges;
  for( size_t beta = 0; beta < irs.size(); beta++ )
    for( size_t alpha = 0; alpha < cg.nrClusters(); alpha++ )
      if( cg.cluster(alpha) >> irs[beta] )
        edges.push_back( pair<size_t,size_t>(alpha,beta) );

  // Construct region graph
  DLOG(INFO) << "  Constructing region graph";
  construct( fg, cg.clusters(), irs, edges );

  // Calculate counting numbers
  DLOG(INFO) << "  Calculating counting numbers";
  calcCVMCountingNumbers();

  DLOG(INFO) << "Done.";
}
开发者ID:ushadow,项目名称:pdbntk,代码行数:60,代码来源:region_graph.cpp

示例11: 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

示例12: evaluate

Value LocationPath::evaluate() const
{
    EvaluationContext& evaluationContext = Expression::evaluationContext();
    EvaluationContext backupContext = evaluationContext;
    // http://www.w3.org/TR/xpath/
    // Section 2, Location Paths:
    // "/ selects the document root (which is always the parent of the document element)"
    // "A / by itself selects the root node of the document containing the context node."
    // In the case of a tree that is detached from the document, we violate
    // the spec and treat / as the root node of the detached tree.
    // This is for compatibility with Firefox, and also seems like a more
    // logical treatment of where you would expect the "root" to be.
    Node* context = evaluationContext.node.get();
    if (m_absolute && context->nodeType() != Node::DOCUMENT_NODE)  {
        if (context->inDocument())
            context = context->ownerDocument();
        else
            context = context->highestAncestor();
    }

    NodeSet nodes;
    nodes.append(context);
    evaluate(nodes);
    
    evaluationContext = backupContext;
    return Value(nodes, Value::adopt);
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:27,代码来源:XPathPath.cpp

示例13: coefficients

void TriLagrangeShape::coefficients( Sample loc,
                                     NodeSet nodeset,
                                     double* coeff_out,
                                     size_t* indices_out,
                                     size_t& num_coeff,
                                     MsqError& err ) const
{
  if (nodeset.have_any_mid_face_node()) {
    MSQ_SETERR(err)("TriLagrangeShape does not support mid-element nodes",
                    MsqError::UNSUPPORTED_ELEMENT);
    return;
  }
  
  switch (loc.dimension) {
    case 0:
      num_coeff = 1;
      indices_out[0] = loc.number;
      coeff_out[0] = 1.0;
      break;
    case 1:
      if (nodeset.mid_edge_node(loc.number)) { // if mid-edge node is present
        num_coeff = 1;
        indices_out[0] = 3+loc.number;
        coeff_out[0] = 1.0;
      }
      else { // no mid node on edge
        num_coeff = 2;
        indices_out[0] = loc.number;
        indices_out[1] = (loc.number+1)%3;
        coeff_out[0] = 0.5;
        coeff_out[1] = 0.5;
      }
      break;
    case 2:
      num_coeff = 3;
      indices_out[0] = 0;
      indices_out[1] = 1;
      indices_out[2] = 2;
      coeff_out[0] = 1.0/3.0;
      coeff_out[1] = 1.0/3.0;
      coeff_out[2] = 1.0/3.0;
      for (int i = 0; i < 3; ++i) { // for each mid-edge node
        if (nodeset.mid_edge_node(i)) { // if node is present
          indices_out[num_coeff] = i+3;
            // coeff for mid-edge node
          coeff_out[num_coeff] = 4.0/9.0;
            // adjust coeff for adj corner nodes
          coeff_out[i]       -= 2.0/9.0;
          coeff_out[(i+1)%3] -= 2.0/9.0;
            // update count
          ++num_coeff;
        }
      }
      break;
    default:
      MSQ_SETERR(err)(MsqError::UNSUPPORTED_ELEMENT,
                  "Request for dimension %d mapping function value"
                  "for a triangular element", loc.dimension);
  }
}
开发者ID:00liujj,项目名称:trilinos,代码行数:60,代码来源:TriLagrangeShape.cpp

示例14: compare_coefficients

static void compare_coefficients( const double* coeffs,
                                  const size_t* indices,
                                  const double* expected_coeffs,
                                  size_t num_coeff,
                                  unsigned loc, NodeSet bits )
{
    // find the location in the returned list for each node
  size_t revidx[6];
  double test_vals[6];
  for (size_t i = 0; i < 6; ++i) {
    revidx[i] = std::find( indices, indices+num_coeff, i ) - indices;
    test_vals[i] = (revidx[i] == num_coeff) ? 0.0 : coeffs[revidx[i]];
  }

    // Check that index list doesn't contain any nodes not actually
    // present in the element.
  CPPUNIT_ASSERT( bits.mid_edge_node(0) || (revidx[3] == num_coeff) );
  CPPUNIT_ASSERT( bits.mid_edge_node(1) || (revidx[4] == num_coeff) );
  CPPUNIT_ASSERT( bits.mid_edge_node(2) || (revidx[5] == num_coeff) );
    
    // compare expected and actual coefficient values
  ASSERT_VALUES_EQUAL( expected_coeffs[0], test_vals[0], loc, bits );
  ASSERT_VALUES_EQUAL( expected_coeffs[1], test_vals[1], loc, bits );
  ASSERT_VALUES_EQUAL( expected_coeffs[2], test_vals[2], loc, bits );
  ASSERT_VALUES_EQUAL( expected_coeffs[3], test_vals[3], loc, bits );
  ASSERT_VALUES_EQUAL( expected_coeffs[4], test_vals[4], loc, bits );
  ASSERT_VALUES_EQUAL( expected_coeffs[5], test_vals[5], loc, bits );
}
开发者ID:00liujj,项目名称:trilinos,代码行数:28,代码来源:TriLagrangeShapeTest.cpp

示例15: derivatives

void TriLagrangeShape::derivatives( Sample loc,
                                    NodeSet nodeset,
                                    size_t* vertex_indices_out,
                                    MsqVector<2>* d_coeff_d_xi_out,
                                    size_t& num_vtx,
                                    MsqError& err ) const
{
  if (!nodeset.have_any_mid_node()) {
    num_vtx = 3;
    get_linear_derivatives( vertex_indices_out, d_coeff_d_xi_out );
    return;
  }

  if (nodeset.have_any_mid_face_node()) {
    MSQ_SETERR(err)("TriLagrangeShape does not support mid-element nodes",
                    MsqError::UNSUPPORTED_ELEMENT);
    return;
  }
  
  switch (loc.dimension) {
    case 0:
      derivatives_at_corner( loc.number, nodeset, vertex_indices_out, d_coeff_d_xi_out, num_vtx );
      break;
    case 1:
      derivatives_at_mid_edge( loc.number, nodeset, vertex_indices_out, d_coeff_d_xi_out, num_vtx );
      break;
    case 2:
      derivatives_at_mid_elem( nodeset, vertex_indices_out, d_coeff_d_xi_out, num_vtx );
      break;
    default:
      MSQ_SETERR(err)("Invalid/unsupported logical dimension",MsqError::INVALID_ARG);
  }
}
开发者ID:00liujj,项目名称:trilinos,代码行数:33,代码来源:TriLagrangeShape.cpp


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