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


C++ set::begin方法代码示例

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


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

示例1: Core_NotifyShutdown

void Core_NotifyShutdown() {
	for (auto it = shutdownFuncs.begin(); it != shutdownFuncs.end(); ++it) {
		(*it)();
	}
}
开发者ID:716Girl,项目名称:ppsspp,代码行数:5,代码来源:Core.cpp

示例2: HandleReadBlock

    void UdpServerListenHandler::HandleReadBlock(const ErrorCode & error_code, const boost::shared_ptr<BlockData> & block,
        const RID & resource_id, boost::uint32_t transaction_id, boost::uint16_t block_index,
        const std::set<boost::uint16_t> & subpiece_indexs, boost::uint16_t dest_protocol_version,
        const boost::asio::ip::udp::endpoint & end_point)
    {
        if (!server_)
        {
            return;
        }

        if (error_code == ErrorCodes::Success)
        {
            for(std::set<boost::uint16_t>::const_iterator iter = subpiece_indexs.begin(); iter != subpiece_indexs.end(); ++iter)
            {
                protocol::SubPieceInfo sub_piece_info = RequestParser::ParseFromSNToPeer(block_index, *iter);
                boost::uint16_t subpiece_index = *iter;

                if (subpiece_index < block->GetSubPieceNumber())
                {
                    statistics_->OnSubPieceResponseSent();

                    boost::shared_ptr<ResponseTask> subpiece_response(
                        new SubPieceResponseTask(
                            end_point, 
                            block,
                            subpiece_index,
                            transaction_id,
                            resource_id,
                            guid_,
                            sub_piece_info,
                            dest_protocol_version));

                    AddResponseTask(subpiece_response);
                }
                else
                {
                    statistics_->OnError(ErrorCodes::ResourceNotFound);

                    boost::shared_ptr<ResponseTask> error_response(
                        new ErrorResponseTask(
                            end_point, 
                            transaction_id, 
                            resource_id, 
                            guid_, 
                            protocol::ErrorPacket::PPV_SUBPIECE_NO_RESOURCEID, 
                            dest_protocol_version));

                    AddResponseTask(error_response);
                }
            }
        }
        else
        {
            statistics_->OnError(error_code);

            boost::shared_ptr<ResponseTask> error_response(
                new ErrorResponseTask(
                end_point, 
                transaction_id, 
                resource_id, 
                guid_, 
                protocol::ErrorPacket::PPV_SUBPIECE_NO_RESOURCEID, 
                dest_protocol_version));

            AddResponseTask(error_response);
        }
    }
开发者ID:huangyt,项目名称:MyProjects,代码行数:67,代码来源:UdpServerListenHandler.cpp

示例3: DrawProjectilesSetShadow

void CProjectileDrawer::DrawProjectilesSetShadow(std::set<CProjectile*>& projectiles)
{
	for (std::set<CProjectile*>::iterator setIt = projectiles.begin(); setIt != projectiles.end(); ++setIt) {
		DrawProjectileShadow(*setIt);
	}
}
开发者ID:lordelven,项目名称:spring,代码行数:6,代码来源:ProjectileDrawer.cpp

示例4: add_fog_override

	/// Records hexes that were cleared of fog via WML.
	void add_fog_override(const std::set<map_location> &hexes) { fog_clearer_.insert(hexes.begin(), hexes.end()); }
开发者ID:justinzane,项目名称:wesnoth-ng,代码行数:2,代码来源:team.hpp

示例5: itwrite

		inline BOSTREAM2(const std::set<T, C, A> &a) { return itwrite(out, a.size(), a.begin()); }
开发者ID:eford,项目名称:swarm,代码行数:1,代码来源:binarystream.hpp

示例6: main

int main(void){

	int i,cur = 0,steps;
	char c;
	std::set<int>::iterator it1;

	points.insert(0);

	scanf("%d %d",&N,&K);

	//store moves in the form start-end
	for(i = 0;i < N; i++){
		scanf("\n%d %c",&steps,&c);

		if(c == 'R'){
			moves[i].start = cur;
			cur += steps;
			moves[i].end = cur;
		}else {
			moves[i].end = cur;
			cur -= steps;
			moves[i].start = cur;
		}
		points.insert(cur);
	}

	P = points.size();

	//compress coordinates
	for(it1 = points.begin(),i = 0; it1 != points.end(); ++it1,i++){
		cc[*it1] = i;
		original[i] = *it1;
	}

	//replace original with compressed values
	for(i = 0;i < N; i++){
		moves[i].start = cc[moves[i].start];
		moves[i].end = cc[moves[i].end];
	}

	//mark visited
	for(i = 0;i < N; i++){
		visited[moves[i].start+1] += 1;
		visited[moves[i].end+1] += -1;
	}

	int vis = 0;
	for(i = 0;i < P; i++){
		vis += visited[i];
		visited[i] = vis;
	}

	//count visited more than K times
	int count = 0;
	for(i = 1;i < P; i++){
		if(visited[i] >= K){
			count += original[i] - original[i-1];
		}
	}

	printf("%d\n",count);

	return 0;
}
开发者ID:My-Favorites,项目名称:ioi-training,代码行数:64,代码来源:Painting+the+Fence+(Silver).cpp

示例7: printTopN

// prints the values in the set
void printTopN(std::set<tfidfPair>& set) {
    std::for_each(set.begin(), set.end(), [](tfidfPair a) {
            std::cout << a.word << ": " << a.value << std::endl;
        });
}
开发者ID:haitzza,项目名称:classwork,代码行数:6,代码来源:haitzza_tfidf.cpp

示例8: check_victory

void game_board::check_victory(bool & continue_level, bool & found_player, bool & found_network_player, bool & cleared_villages, std::set<unsigned> & not_defeated, bool remove_from_carryover_on_defeat)
{
	continue_level = true;
	found_player = false;
	found_network_player = false;
	cleared_villages = false;

	not_defeated = std::set<unsigned>();

	for (const unit & i : units())
	{
		DBG_EE << "Found a unit: " << i.id() << " on side " << i.side() << std::endl;
		const team& tm = teams()[i.side()-1];
		DBG_EE << "That team's defeat condition is: " << tm.defeat_condition() << std::endl;
		if (i.can_recruit() && tm.defeat_condition() == team::DEFEAT_CONDITION::NO_LEADER) {
			not_defeated.insert(i.side());
		} else if (tm.defeat_condition() == team::DEFEAT_CONDITION::NO_UNITS) {
			not_defeated.insert(i.side());
		}
	}

	for (team& tm : teams_)
	{
		if(tm.defeat_condition() == team::DEFEAT_CONDITION::NEVER)
		{
			not_defeated.insert(tm.side());
		}
		// Clear villages for teams that have no leader and
		// mark side as lost if it should be removed from carryover.
		if (not_defeated.find(tm.side()) == not_defeated.end())
		{
			tm.clear_villages();
			// invalidate_all() is overkill and expensive but this code is
			// run rarely so do it the expensive way.
			cleared_villages = true;

			if (remove_from_carryover_on_defeat)
			{
				tm.set_lost(true);
			}
		}
		else if(remove_from_carryover_on_defeat)
		{
			tm.set_lost(false);
		}
	}

	for (std::set<unsigned>::iterator n = not_defeated.begin(); n != not_defeated.end(); ++n) {
		size_t side = *n - 1;

		DBG_EE << "Side " << (side+1) << " is a not-defeated team" << std::endl;

		std::set<unsigned>::iterator m(n);
		for (++m; m != not_defeated.end(); ++m) {
			if (teams()[side].is_enemy(*m)) {
				return;
			}
			DBG_EE << "Side " << (side+1) << " and " << *m << " are not enemies." << std::endl;
		}

		if (teams()[side].is_local_human()) {
			found_player = true;
		}

		if (teams()[side].is_network_human()) {
			found_network_player = true;
		}
	}

	continue_level = false;
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:71,代码来源:game_board.cpp

示例9: InfiLEmptyStencilModeCache

void InfiLEmptyStencilModeCache() {
	auto iter = cache.begin();
	for ( ;iter!=cache.end();++iter )
		delete *iter;
	cache.clear();
}
开发者ID:GalacticonRex,项目名称:Infinity,代码行数:6,代码来源:infi_stencil_mode.cpp

示例10: set_subset

 bool set_subset(const std::set<K,C,A>& x,
                 const std::set<K,C,A>& y)
 {
   return std::includes(x.begin(), x.end(), y.begin(), y.end());
 }
开发者ID:2asoft,项目名称:xray-16,代码行数:5,代码来源:set_adaptor.hpp

示例11: smooth_metric_

double highOrderTools::smooth_metric_(std::vector<MElement*>  & v,
                                      GFace *gf,
                                      dofManager<double> &myAssembler,
                                      std::set<MVertex*> &verticesToMove,
                                      elasticityTerm &El)
{
  std::set<MVertex*>::iterator it;
  double dx = 0.0;

  if (myAssembler.sizeOfR()){

    // while convergence
    for (unsigned int i = 0; i < v.size(); i++){
      MElement *e = v[i];
      int nbNodes = e->getNumVertices();
      const int n2 = 2 * nbNodes;
      const int n3 = 3 * nbNodes;

      fullMatrix<double> K33(n3, n3);
      fullMatrix<double> K22(n2, n2);
      fullMatrix<double> J32(n3, n2);
      fullMatrix<double> J23(n2, n3);
      fullVector<double> D3(n3);
      fullVector<double> R2(n2);
      fullMatrix<double> J23K33(n2, n3);
      K33.setAll(0.0);
      SElement se(e);
      El.elementMatrix(&se, K33);
      computeMetricInfo(gf, e, J32, J23, D3);
      J23K33.gemm(J23, K33, 1, 0);
      K22.gemm(J23K33, J32, 1, 0);
      J23K33.mult(D3, R2);
      for (int j = 0; j < n2; j++){
        Dof RDOF = El.getLocalDofR(&se, j);
        myAssembler.assemble(RDOF, -R2(j));
        for (int k = 0; k < n2; k++){
          Dof CDOF = El.getLocalDofC(&se, k);
          myAssembler.assemble(RDOF, CDOF, K22(j, k));
        }
      }
    }
    myAssembler.systemSolve();
    // for all element, compute detJ at integration points --> material law end
    // while convergence

    for (it = verticesToMove.begin(); it != verticesToMove.end(); ++it){
      if ((*it)->onWhat()->dim() == 2){
	SPoint2 param;
	reparamMeshVertexOnFace((*it), gf, param);
	SPoint2 dparam;
	myAssembler.getDofValue((*it), 0, _tag, dparam[0]);
	myAssembler.getDofValue((*it), 1, _tag, dparam[1]);
	SPoint2 newp = param+dparam;
	dx += newp.x() * newp.x() + newp.y() * newp.y();
	(*it)->setParameter(0, newp.x());
	(*it)->setParameter(1, newp.y());
      }
    }
    myAssembler.systemClear();
  }

  return dx;
}
开发者ID:iyer-arvind,项目名称:gmsh,代码行数:63,代码来源:OptHomElastic.cpp

示例12: AddExclusionList

// Atom::AddExclusionList()
void Atom::AddExclusionList(std::set<int> const& elist) {
  excluded_.clear();
  for (std::set<int>::const_iterator ei = elist.begin(); ei != elist.end(); ei++)
    excluded_.push_back( *ei );
}
开发者ID:SAMAN-64,项目名称:cpptraj,代码行数:6,代码来源:Atom.cpp

示例13: arrayVars

void Context::arrayVars(const std::set<Value*> &arrayValues){
    for(std::set<Value*>::iterator it = arrayValues.begin(); it != arrayValues.end();it++){
        ExprPtr expr = Expression::mkIntToIntVar((*it) -> getName());
        this->val2expr[*it] = expr;
    }
}
开发者ID:belolourenco,项目名称:sniper,代码行数:6,代码来源:Context.cpp

示例14: if

Mesh::Mesh(const std::map<MElement*,GEntity*> &element2entity,
           const std::set<MElement*> &els, std::set<MVertex*> &toFix,
           bool fixBndNodes, bool fastJacEval) :
  _fastJacEval(fastJacEval)
{

  _dim = (*els.begin())->getDim();

  // Initialize elements, vertices, free vertices and element->vertices
  // connectivity
  const int nElements = els.size();
  _nPC = 0;
  _el.resize(nElements);
  _el2FV.resize(nElements);
  _el2V.resize(nElements);
  _nBezEl.resize(nElements);
  _nNodEl.resize(nElements);
  _indPCEl.resize(nElements);
  int iEl = 0;
  bool nonGeoMove = false;
  for(std::set<MElement*>::const_iterator it = els.begin();
      it != els.end(); ++it, ++iEl) {
    _el[iEl] = *it;
    const JacobianBasis *jac = _el[iEl]->getJacobianFuncSpace();
    _nBezEl[iEl] = _fastJacEval ? jac->getNumJacNodesFast() : jac->getNumJacNodes();
    _nNodEl[iEl] = jac->getNumMapNodes();
    for (int iVEl = 0; iVEl < jac->getNumMapNodes(); iVEl++) {
      MVertex *vert = _el[iEl]->getVertex(iVEl);
      GEntity *ge = vert->onWhat();
      const int vDim = ge->dim();
      const bool hasParam = ge->haveParametrization();
      int iV = addVert(vert);
      _el2V[iEl].push_back(iV);
      if ((vDim > 0) && (toFix.find(vert) == toFix.end()) && (!fixBndNodes || vDim == _dim)) {   // Free vertex?
        ParamCoord *param;
        if (vDim == 3) param = new ParamCoordPhys3D();
        else if (hasParam) param = new ParamCoordParent(vert);
        else {
          if (vDim == 2) param = new ParamCoordLocalSurf(vert);
          else param = new ParamCoordLocalLine(vert);
          nonGeoMove = true;
        }
        int iFV = addFreeVert(vert,iV,vDim,param,toFix);
        _el2FV[iEl].push_back(iFV);
        for (int i=_startPCFV[iFV]; i<_startPCFV[iFV]+vDim; i++) _indPCEl[iEl].push_back(i);
      }
      else _el2FV[iEl].push_back(-1);
    }
  }

  if (nonGeoMove) Msg::Info("WARNING: Some vertices will be moved along local lines "
                            "or planes, they may not remain on the exact geometry");

  // Initial coordinates
  _ixyz.resize(nVert());
  for (int iV = 0; iV < nVert(); iV++) _ixyz[iV] = _vert[iV]->point();
  _iuvw.resize(nFV());
  for (int iFV = 0; iFV < nFV(); iFV++) _iuvw[iFV] = _paramFV[iFV]->getUvw(_freeVert[iFV]);

  // Set current coordinates
  _xyz = _ixyz;
  _uvw = _iuvw;

  // Set normals to 2D elements (with magnitude of inverse Jacobian) or initial
  // Jacobians of 3D elements
  if (_dim == 2) {
    _scaledNormEl.resize(nEl());
    for (int iEl = 0; iEl < nEl(); iEl++) calcScaledNormalEl2D(element2entity,iEl);
  }
  else {
    _invStraightJac.resize(nEl(),1.);
    double dumJac[3][3];
    for (int iEl = 0; iEl < nEl(); iEl++)
      _invStraightJac[iEl] = 1. / fabs(_el[iEl]->getPrimaryJacobian(0.,0.,0.,dumJac));
  }

}
开发者ID:feelpp,项目名称:debian-gmsh,代码行数:77,代码来源:OptHomMesh.cpp

示例15: AddOutOfRangeGUID

void UpdateData::AddOutOfRangeGUID(std::set<uint64>& guids)
{
    m_outOfRangeGUIDs.insert(guids.begin(), guids.end());
}
开发者ID:Carbinfibre,项目名称:ArcPro,代码行数:4,代码来源:UpdateData.cpp


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