• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ set类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: insert_brkpt_batch

/**
 *	Inserts all the breakpoints, called after user provided 'continue' command
 *
 * 	@param pid: Process ID of the child (debuggee) 
 */
void insert_brkpt_batch( pid_t pid ) {
	for ( auto it = brkpt_batch.begin(); it != brkpt_batch.end(); ) {
		set_brkpt( pid, *it, true );
		brkpt_batch.erase( it++ /* makes a copy and destroys current it */ );
	}
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:super_debugger,代码行数:11,代码来源:tryingPtrace_copy12.cpp


示例2: localAvailableSpecsWithout

int PolySolverNAD::FindBestSolution(SADNADGraph &graph, vector<pair<Node*, Node*> > availableSpecs, set<pair<Node*, Node*> > chosenSpecs, int verbose)
{


    if (availableSpecs.size() == 0)
    {
        //return the # of AD components
        int nb = graph.GetNbADComponents(chosenSpecs) - 1;

        if (verbose > 0)
        {

            cout<<" RETURNING "<<nb<<endl;

        }

        if (nb < bestSolSoFar)
        {
            bestSolSoFar = nb;
            bestChoiceSoFar = chosenSpecs;
        }

        return nb;
    }

    int bestWith = 0;
    int bestWithout = 0;

    //2 cases : next available spec is chosen, or not

    //EASY CASE : NOT CHOSEN
    vector<pair<Node*, Node*> > localAvailableSpecsWithout(availableSpecs);
    localAvailableSpecsWithout.erase(localAvailableSpecsWithout.begin());
    bestWithout = FindBestSolution(graph, localAvailableSpecsWithout, chosenSpecs, verbose);


    //TOUGH CASE : IT'S CHOSEN.  Then update what's available or not, and chosen or not
    set<pair<Node*, Node*> > localChosen(chosenSpecs);
    pair<Node*, Node*> nextSpec = availableSpecs[0];
    vector<pair<Node*, Node*> > localAvailableSpecs(availableSpecs);
    localChosen.insert(nextSpec);
    localAvailableSpecs.erase(localAvailableSpecs.begin());

    if (verbose > 0)
    {
        cout<<endl<<"CHOOSING AN EDGE "<<endl<<"AVAIL="<<availableSpecs.size()<<" CHOSEN="<<chosenSpecs.size();
        cout<<" Choice="<<nextSpec.first->GetLabel()<<" "<<nextSpec.second->GetLabel();

        for (vector<pair<Node*, Node*> >::iterator vit = availableSpecs.begin(); vit != availableSpecs.end(); vit++)
        {
            cout<<(*vit).first->GetLabel()<<" "<<(*vit).second->GetLabel()<<endl;
        }

        cout<<"CHOSEN="<<endl;

        for (set<pair<Node*, Node*> >::iterator vit = chosenSpecs.begin(); vit != chosenSpecs.end(); vit++)
        {
            cout<<(*vit).first->GetLabel()<<" "<<(*vit).second->GetLabel()<<endl;
        }
    }

    //automatically include every spec in the same clique as nextSpec
    //what nextSpec does is that it "combines" two cliques
    //first, get the 2 cliques the nextSpec vertices are in
    Node* v1 = nextSpec.first;
    Node* v2 = nextSpec.second;
    set<Node*> cliqueV1;
    cliqueV1.insert(v1);
    set<Node*> cliqueV2;
    cliqueV2.insert(v2);

    for (set<pair<Node*, Node*> >::iterator it = localChosen.begin(); it != localChosen.end(); it++)
    {
        pair<Node*, Node*> e = (*it);

        if (e != nextSpec)
        {
            if (e.first == v1)
                cliqueV1.insert(e.second);
            if (e.second == v1)
                cliqueV1.insert(e.first);

            if (e.first == v2)
                cliqueV2.insert(e.second);
            if (e.second == v2)
                cliqueV2.insert(e.first);
        }
    }


    //now, each cliqueV1 and cliqueV2 should be complete to eachother (otherwise this code is not working)
    //The spec edges that link these 2 cliques are chosen "by default", so no need to make them available
    vector<pair<Node*, Node*> >::iterator avit = localAvailableSpecs.begin();
    while (avit != localAvailableSpecs.end())
    {
        pair<Node*, Node*> e = (*avit);

        //NOTE : next spec shouldn't be in localAvailableSpecs
        if ((cliqueV1.find(e.first) != cliqueV1.end() && cliqueV2.find(e.second) != cliqueV2.end()) ||
            (cliqueV2.find(e.first) != cliqueV2.end() && cliqueV1.find(e.second) != cliqueV1.end()))
//.........这里部分代码省略.........
开发者ID:UdeM-LBIT,项目名称:SuGeT,代码行数:101,代码来源:polysolver_nad.cpp


示例3: stoi

namespace v81c { namespace xml {


namespace patch {

// В сигвинѣ нѣт std::stoi

static
int stoi(const string &s)
{
    int r;
    sscanf(s.c_str(), "%d", &r);
    return r;
}

}

v8::String &__read(v8::String &dst, xmlpp::Node *element)
{
    const xmlpp::Node::NodeList children = element->get_children(); // совместимость с libxml++ < 2.36
    if (!children.empty()) {
        const xmlpp::Node *text = children.front();

        const xmlpp::TextNode *tn = dynamic_cast<const xmlpp::TextNode *>(text);
        string sc(tn->get_content().c_str());

        dst = v8::String(sc);

    } else
        dst = v8::String();

    return dst;
}

v8::StringInLanguage &__read(v8::StringInLanguage &dst, xmlpp::Node *element)
{
    v8::String lang;
    v8::String content;

    xmlpp::Node::PrefixNsMap ns;
    ns["xmlns"] = v8::xmlns;

    xmlpp::NodeSet nodes;
    nodes = element->find("xmlns:lang", ns);
    if (!nodes.empty()) {
        dst.setLang(__read(lang, nodes.at(0)));
    }

    nodes = element->find("xmlns:content", ns);
    if (!nodes.empty()) {
        dst.setContent(__read(content, nodes.at(0)));
    }

    return dst;
}

v8::StringInDifferentLanguages &
__read(v8::StringInDifferentLanguages &dst, xmlpp::Node *element)
{
    xmlpp::Node::PrefixNsMap ns;
    ns["xmlns"] = v8::xmlns;

    xmlpp::NodeSet nodes;
    nodes = element->find("xmlns:item", ns);

    dst.clear();

    for (auto node : nodes) {
        v8::StringInLanguage item;
        dst.push_back(__read(item, node));
    }

    return dst;
}

v8::Boolean &
__read(v8::Boolean &dst, xmlpp::Node *element)
{
    dst.setValue(false);

    const xmlpp::Node::NodeList children = element->get_children(); // совместимость с libxml++ < 2.36
    if (!children.empty()) {
        const xmlpp::Node *text = children.front();

        const xmlpp::TextNode *tn = dynamic_cast<const xmlpp::TextNode *>(text);
        string sc(tn->get_content().c_str());

        if (sc == "true")
            dst.setValue(true);

    }

    return dst;
}

v8::Number &
__read(v8::Number &dst, xmlpp::Node *element)
{
    const xmlpp::Node::NodeList children = element->get_children(); // совместимость с libxml++ < 2.36
    if (!children.empty()) {
//.........这里部分代码省略.........
开发者ID:dmpas,项目名称:v81cformat,代码行数:101,代码来源:serializer.cpp


示例4: InstrumentCalls

static void InstrumentCalls (BPatch_image *appImage, BPatch_addressSpace *appProcess,
	ApplicationType *appType, set<string> &OMPset, set<string> &USERset,
    map<string, vector<string> > & LoopLevels,
    bool instrumentMPI, bool instrumentOMP, bool instrumentUF)
{
	unsigned i = 0;
	unsigned OMPinsertion = 0;
	unsigned OMPreplacement_intel_v11 = 0;
	unsigned MPIinsertion = 0;
	unsigned APIinsertion = 0;
	unsigned UFinsertion = 0;
	const char *PMPI_C_prefix = "PMPI_";
	const char *PMPI_F_prefix = "pmpi_";
	const char *MPI_C_prefix = "MPI_";
	const char *MPI_F_prefix= "mpi_";

	cout << PACKAGE_NAME << ": Obtaining functions from application image (this may take a while)..." << flush;
	BPatch_Vector<BPatch_function *> *vfunctions = appImage->getProcedures (false);
	cout << "Done" << endl;

	set<string> CUDAkernels;

	/* Look for CUDA kernels if the application is CUDA */
	if (appType->get_isCUDA())
	{
		cout << PACKAGE_NAME << ": Looking for CUDA kernels inside binary (this may take a while)..." << endl;

		i = 0;
		while (i < vfunctions->size())
		{
			char name[1024];

			BPatch_function *f = (*vfunctions)[i];
			f->getName (name, sizeof(name));
			BPatch_Vector<BPatch_point *> *vpoints = f->findPoint (BPatch_subroutine);

			if (vpoints != NULL)
			{
				unsigned j = 0;
				while (j < vpoints->size())
				{
					BPatch_function *called = ((*vpoints)[j])->getCalledFunction();
					if (NULL != called)
					{
						char calledname[1024];
						called->getName (calledname, 1024);
	
						if (strncmp (calledname, "__device_stub__", strlen("__device_stub__")) == 0)
						{
							CUDAkernels.insert (name);
							if (VerboseLevel)
								cout << PACKAGE_NAME << ": Found kernel " << name << endl;
						}
					}
					j++;
				}
			}
			i++;
		}
		cout << PACKAGE_NAME << ": Finished looking for CUDA kernels" << endl;
	}

	cout << PACKAGE_NAME << ": Parsing executable looking for instrumentation points (" << vfunctions->size() << ") ";
	if (VerboseLevel)
		cout << endl;
	else
		cout << flush;

	/*
	  The 1st step includes:
	  a) gather information of openmp outlined routines (original is added to USERset),
	  b) instrument openmp outlined routines
	  c) instrument mpi calls
	  d) instrument api calls
	*/

	i = 0;
	while (i < vfunctions->size())
	{
		char name[1024], sharedlibname_c[1024];

		BPatch_function *f = (*vfunctions)[i];
		(f->getModule())->getFullName (sharedlibname_c, sizeof(sharedlibname_c));
		f->getName (name, sizeof(name));

		string sharedlibname = sharedlibname_c;

		string sharedlibname_ext;
		if (sharedlibname.rfind('.') != string::npos)
			sharedlibname_ext = sharedlibname.substr (sharedlibname.rfind('.'));
		else
			sharedlibname_ext = "";

		/* For OpenMP apps, if the application has been linked with Extrae, just need to
		   instrument the function calls that have #pragma omp in them. The outlined
			 routines will be instrumented by the library attached to the binary */
		if (!BinaryLinkedWithInstrumentation &&
		    instrumentOMP && appType->get_isOpenMP() && loadedModule != sharedlibname)
		{
			/* OpenMP instrumentation (just for OpenMP apps) */
//.........这里部分代码省略.........
开发者ID:polca-project,项目名称:polca-toolbox,代码行数:101,代码来源:extrae.C


示例5: initialize_exclusion_set

void initialize_exclusion_set( set<string> &exs){
    static string _exclude[6] = {"a","an","the","but","or","and"};
    exs.insert(_exclude,_exclude+6);
}
开发者ID:xiazhiyiyun,项目名称:C-Program,代码行数:4,代码来源:exercise3.1.0.cpp


示例6: StoreInst

void WorklessInstrument::InstrumentWorkless0Or1Star(Module * pModule, Loop * pLoop, set<string> & setWorkingBlocks)
{
	LoadInst * pLoad0 = NULL;
	LoadInst * pLoad1 = NULL;
	//BinaryOperator* pAdd = NULL;
	StoreInst * pStore = NULL;
	CallInst * pCall = NULL;

	Function * pMain = NULL;

	if(strMainName != "" )
	{
		pMain = pModule->getFunction(strMainName.c_str());
	}
	else
	{
		pMain = pModule->getFunction("main");
	}

	for (Function::iterator BB = pMain->begin(); BB != pMain->end(); ++BB) 
	{
		if(BB->getName().equals("entry"))
		{
			CallInst * pCall;
			StoreInst * pStore;

			Instruction * II = BB->begin();
			pCall = CallInst::Create(this->InitHooks, "", II);
			pCall->setCallingConv(CallingConv::C);
			pCall->setTailCall(false);
			AttributeSet emptySet;
			pCall->setAttributes(emptySet);

			pCall = CallInst::Create(this->getenv, this->SAMPLE_RATE_ptr, "", II);
			pCall->setCallingConv(CallingConv::C);
			pCall->setTailCall(false);
			AttributeSet AS;
			{
				SmallVector<AttributeSet, 4> Attrs;
				AttributeSet PAS;
				{
					AttrBuilder B;
					B.addAttribute(Attribute::NoUnwind);
					PAS = AttributeSet::get(pModule->getContext(), ~0U, B);
				}
				Attrs.push_back(PAS);
				AS = AttributeSet::get(pModule->getContext(), Attrs);
			}
			pCall->setAttributes(AS);

			pCall = CallInst::Create(this->function_atoi, pCall, "", II);
			pCall->setCallingConv(CallingConv::C);
			pCall->setTailCall(false);
			{
  				SmallVector<AttributeSet, 4> Attrs;
   				AttributeSet PAS;
    			{
    	 			AttrBuilder B;
     				B.addAttribute(Attribute::NoUnwind);
     				B.addAttribute(Attribute::ReadOnly);
     				PAS = AttributeSet::get(pModule->getContext(), ~0U, B);
    			}
   
   				Attrs.push_back(PAS);
   				AS = AttributeSet::get(pModule->getContext(), Attrs);
   
  			}
  			pCall->setAttributes(AS);

  			pStore = new StoreInst(pCall, this->SAMPLE_RATE, false, II);
  			pStore->setAlignment(4);

  			pCall = CallInst::Create(this->geo, pCall, "", II);
  			pCall->setCallingConv(CallingConv::C);
  			pCall->setTailCall(false);
  			pCall->setAttributes(emptySet);

  			CastInst * pCast = CastInst::CreateIntegerCast(pCall, this->LongType, true, "", II);
  			pStore = new StoreInst(pCast, this->CURRENT_SAMPLE, false, II);
  			pStore->setAlignment(8);

  			vector<Value *> vecParam;
  			vecParam.push_back(this->Output_Format_String);
  			vecParam.push_back(pCall);
  			pCall = CallInst::Create(this->printf, vecParam, "", II);
  			pCall->setCallingConv(CallingConv::C);
  			pCall->setTailCall(false);
  			pCall->setAttributes(emptySet);
  			break;
		}
	}

	for (Function::iterator BB = pMain->begin(); BB != pMain->end(); ++BB) 
	{
		for (BasicBlock::iterator Ins = BB->begin(); Ins != BB->end(); ++Ins) 
		{
			if (isa<ReturnInst>(Ins) || isa<ResumeInst>(Ins)) 
			{
				vector<Value*> vecParams;
				pLoad0 = new LoadInst(numIterations, "", false, Ins); 
//.........这里部分代码省略.........
开发者ID:songlh,项目名称:LDoctor,代码行数:101,代码来源:WLInstrument.cpp


示例7: Get_END_Boundary_Range_For_START

void CDetCandit::Creating_DismCase_Cases(const char* inputchar, size_t i, size_t SENID, size_t& CASID,  set<size_t>&  START_s, set<size_t>& END_s, map<size_t, double>& START_Rtn_map, 
map<size_t, double>& END_Rtn_map, map<size_t, set<size_t>>& pmSavedPair, map<size_t, map<size_t, ACE_entity_mention*>>& EntityMention_mm, vector<CanditCase*>& pmCandit_v)
{
	size_t length = NLPOP::Get_Chinese_Sentence_Length_Counter(inputchar);


	if((START_s.find(i) != START_s.end()) && START_Feedback_Ref_Flag){
		multimap<double, size_t> FeedbackCase_mm;
		if(!Greedy_Matching_Method_FLag){
			size_t FeedBorder = Get_END_Boundary_Range_For_START(START_s, END_s, i, length);
			for(size_t j = i; j <= FeedBorder; j++){//:* <? <=?
				if(END_Rtn_map.find(j) == END_Rtn_map.end()){//decreasing performance...
					continue;
				}
				if(END_s.find(j) != END_s.end()){
					FeedbackCase_mm.insert(make_pair(2, j));
				}
				else if(END_Rtn_map[j] > FEEDBACE_PRO_LIMIT){
					FeedbackCase_mm.insert(make_pair(END_Rtn_map[j], j));
				}
			}
		}
		else{
			//AppCall::Secretary_Message_Box("Can not be use yet! in CDetCandit::Creating_DismCase_Cases()", MB_OK);
		}
		Erasing_Prescribed_Candidates(FeedbackCase_mm);
		for(multimap<double, size_t>::iterator mmite = FeedbackCase_mm.begin(); mmite != FeedbackCase_mm.end(); mmite++){
			if(Exist_Detection_and_Updata(pmSavedPair, i, mmite->second)){
				continue;
			}
			pCanditCase ploc_Candit = new CanditCase;
			ploc_Candit->SENID = SENID;
			ploc_Candit->CASID = CASID++;
			ploc_Candit->CEDT_Head_Flag = CEDT_Head_Flag;
//			ploc_Candit->Detection_Flag = CEDT_Detection_Flag;
			ploc_Candit->START = i;
			ploc_Candit->END = mmite->second;

			int Left_Out_Range = Get_Left_Outer_Feature_Range_For_START(START_s, END_s, ploc_Candit->START, -1);
			int Right_Out_Range = Get_Right_Outer_Feature_Range_For_END(START_s, END_s, ploc_Candit->END, length-1);
			ploc_Candit->l_outmstr = Sentop::Get_Substr_by_Chinese_Character_Cnt(inputchar, Left_Out_Range+1, ploc_Candit->START-Left_Out_Range-1);
			ploc_Candit->r_outmstr = Sentop::Get_Substr_by_Chinese_Character_Cnt(inputchar, ploc_Candit->END+1, Right_Out_Range-ploc_Candit->END-1);
			
			ploc_Candit->prix = Sentop::Get_Substr_by_Chinese_Character_Cnt(inputchar, 0, ploc_Candit->START);
			ploc_Candit->prox = Sentop::Get_Substr_by_Chinese_Character_Cnt(inputchar, ploc_Candit->END+1, -1);
			ploc_Candit->mention = Sentop::Get_Substr_by_Chinese_Character_Cnt(inputchar, ploc_Candit->START, ploc_Candit->END-ploc_Candit->START+1);

			ploc_Candit->Cand_Flag = false;
			ploc_Candit->pNE_mention = NULL;
			ploc_Candit->predit_TYPE = (Detect_Single_NE_TYPE.length()==0)?POSITIVE:Detect_Single_NE_TYPE;
			ploc_Candit->org_TYPE = NEGETIVE;
			if(EntityMention_mm.find(ploc_Candit->START) != EntityMention_mm.end()){
				if(EntityMention_mm[ploc_Candit->START].find(ploc_Candit->END) != EntityMention_mm[ploc_Candit->START].end()){
					ploc_Candit->Cand_Flag = true;
					ploc_Candit->pNE_mention = EntityMention_mm[ploc_Candit->START][ploc_Candit->END];
					ploc_Candit->org_TYPE = CEDT_Detection_Flag?POSITIVE:EntityMention_mm[ploc_Candit->START][ploc_Candit->END]->Entity_TYPE;
				}
			}
			pmCandit_v.push_back(ploc_Candit);
		}
	}
	if((END_s.find(i) != END_s.end()) && END_Feedback_Ref_Flag){
		multimap<double, size_t> FeedbackCase_mm;
		if(!Greedy_Matching_Method_FLag){
			int FeedBorder = Get_START_Boundary_Range_For_END(START_s, END_s, i, 0);
			for(int j = i; j >= FeedBorder; j--){
				if(START_Rtn_map.find(j) == START_Rtn_map.end()){
					continue;
				}
				if(START_s.find(j) != START_s.end()){
					FeedbackCase_mm.insert(make_pair(2, j));
				}
				else if(START_Rtn_map[j] > FEEDBACE_PRO_LIMIT){
					FeedbackCase_mm.insert(make_pair(START_Rtn_map[j], j));
				}
			}
		}
		else{
			set<size_t> matched_s;
			Greedy_Right_to_Left_matching(START_s, END_s, i, 0, 2, matched_s);
			//Greedy_Left_to_Right_matching(START_s, END_s, i, length-1, 2, matched_s);

			for(set<size_t>::iterator site = matched_s.begin(); site != matched_s.end(); site++){
				if(START_Rtn_map.find(*site) == START_Rtn_map.end()){
					continue;
				}
				else{
					FeedbackCase_mm.insert(make_pair(START_Rtn_map[*site], *site));
				}
			}
		}
		Erasing_Prescribed_Candidates(FeedbackCase_mm);
		for(multimap<double, size_t>::iterator mmite = FeedbackCase_mm.begin(); mmite != FeedbackCase_mm.end(); mmite++){
			if(Exist_Detection_and_Updata(pmSavedPair, mmite->second, i)){
				continue;
			}
			pCanditCase ploc_Candit = new CanditCase;
			ploc_Candit->SENID = SENID;
			ploc_Candit->CASID = CASID++;
			ploc_Candit->CEDT_Head_Flag = CEDT_Head_Flag;
//.........这里部分代码省略.........
开发者ID:YPench,项目名称:CEDT,代码行数:101,代码来源:DetCandit.cpp


示例8: while

void WorklessInstrument::CloneInnerLoop(Loop * pLoop, vector<BasicBlock *> & vecAdd, ValueToValueMapTy & VMap, set<BasicBlock *> & setCloned)
{
	Function * pFunction = pLoop->getHeader()->getParent();
	BasicBlock * pPreHeader = vecAdd[0];

	SmallVector<BasicBlock *, 4> ExitBlocks;
	pLoop->getExitBlocks(ExitBlocks);

	set<BasicBlock *> setExitBlocks;

	for(unsigned long i = 0; i < ExitBlocks.size(); i++)
	{
		setExitBlocks.insert(ExitBlocks[i]);
	}

	for(unsigned long i = 0; i < ExitBlocks.size(); i++ )
	{
		VMap[ExitBlocks[i]] = ExitBlocks[i];
	}

	vector<BasicBlock *> ToClone;
	vector<BasicBlock *> BeenCloned;

	
	//clone loop
	ToClone.push_back(pLoop->getHeader());

	while(ToClone.size()>0)
	{
		BasicBlock * pCurrent = ToClone.back();
		ToClone.pop_back();

		WeakVH & BBEntry = VMap[pCurrent];
		if (BBEntry)
		{
			continue;
		}

		BasicBlock * NewBB;
		BBEntry = NewBB = BasicBlock::Create(pCurrent->getContext(), "", pFunction);

		if(pCurrent->hasName())
		{
			NewBB->setName(pCurrent->getName() + ".CPI");
		}

		if(pCurrent->hasAddressTaken())
		{
			errs() << "hasAddressTaken branch\n" ;
			exit(0);
		}

		for(BasicBlock::const_iterator II = pCurrent->begin(); II != pCurrent->end(); ++II )
		{
			Instruction * NewInst = II->clone();
			if(II->hasName())
			{
				NewInst->setName(II->getName() + ".CPI");
			}
			VMap[II] = NewInst;
			NewBB->getInstList().push_back(NewInst);
		}

		const TerminatorInst *TI = pCurrent->getTerminator();
		for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
		{
			ToClone.push_back(TI->getSuccessor(i));
		}

		setCloned.insert(NewBB);
		BeenCloned.push_back(NewBB);
	}

	//remap value used inside loop
	vector<BasicBlock *>::iterator itVecBegin = BeenCloned.begin();
	vector<BasicBlock *>::iterator itVecEnd = BeenCloned.end();

	for(; itVecBegin != itVecEnd; itVecBegin ++)
	{
		for(BasicBlock::iterator II = (*itVecBegin)->begin(); II != (*itVecBegin)->end(); II ++ )
		{
			//II->dump();
			RemapInstruction(II, VMap);
		}
	}

	//add to the else if body
	BasicBlock * pElseBody = vecAdd[1];

	BasicBlock * pClonedHeader = cast<BasicBlock>(VMap[pLoop->getHeader()]);

	BranchInst::Create(pClonedHeader, pElseBody);

	//errs() << pPreHeader->getName() << "\n";
	for(BasicBlock::iterator II = pClonedHeader->begin(); II != pClonedHeader->end(); II ++ )
	{
		if(PHINode * pPHI = dyn_cast<PHINode>(II))
		{
			vector<int> vecToRemoved;
			for (unsigned i = 0, e = pPHI->getNumIncomingValues(); i != e; ++i) 
//.........这里部分代码省略.........
开发者ID:songlh,项目名称:LDoctor,代码行数:101,代码来源:WLInstrument.cpp


示例9: findUniqueWidgetTypes

void findUniqueWidgetTypes(fstream& stream, WidgetNode *root, set<string> &widgetTypes) {
	if(root->widgetType!="Gui" && root->widgetType!="root")
		widgetTypes.insert(root->widgetType);
	for(size_t i = 0; i < root->children.size(); i++)
		findUniqueWidgetTypes(stream, root->children[i], widgetTypes); 
}
开发者ID:AliSayed,项目名称:MoSync,代码行数:6,代码来源:main.cpp


示例10: end

bool
TileMapLayerInfoVector::updateLayers( TileMapLayerInfoVector& clientVector,
                                      const set<int>& existinLayers )
{
   // The clientVector will be the target of this operation.
   // Afterwards the vector is copied.
   int changed = 0;

   // Add changes from the client vector to our settings.
   for( TileMapLayerInfoVector::iterator it = clientVector.begin();
        it != clientVector.end();
        ++it ) {
      TileMapLayerInfo* myInfo = NULL;
      // Find the info from the server.
      for ( TileMapLayerInfoVector::iterator jt = this->begin();
            jt != this->end();
            ++jt ) {
         if ( jt->getID() == it->getID() ) {
            myInfo = &(*jt);
            break;
         }
      }
      changed += it->setPresent( myInfo &&
                ( existinLayers.find( it->getID() ) != existinLayers.end() ) );
      if ( ! myInfo ) {
         continue;
      }
      // These are always correct from the server by definition
      changed += it->setOptional( myInfo->isOptional() );
      changed += it->setAffectedByACPMode( myInfo->isAffectedByACPMode() );
      changed += it->setFetchLayerWhenACPEnabled( myInfo->getFetchLayerWhenACPEnabled() );
      changed += it->setFetchLayerWhenACPDisabled( myInfo->getFetchLayerWhenACPDisabled() );
      
      // Non-optional layers can not be turned off.
      if ( ! it->isOptional() ) {
         changed += it->setVisible( true );
      }
      if ( it->getServerOverrideNumber() !=
           myInfo->getServerOverrideNumber() ) {
         // Force the update into the vector.
         changed +=
            it->setUpdatePeriodMinutes( myInfo->getUpdatePeriodMinutes() );
         changed += it->setVisible( myInfo->isVisible() );
         // But only do it once.
         it->setServerOverrideNumber( myInfo->getServerOverrideNumber() );
      } else {
         // Keep the info that the client entered
      }
   }
   // Add layers to the vector that are not present yet.
   for ( iterator jt = begin();
         jt != end();
         ++jt ) {
      bool found = false;
      for ( iterator it = clientVector.begin();
            it != clientVector.end();
            ++it ) {
         if ( jt->getID() == it->getID() ) {
            found = true;
            break;
         }
      }
      if ( ! found ) {
         // Insert that into the client vector.
         ++changed;
         clientVector.push_back( *jt );
      }
   }

   // This vector will now be the same as the other one.
   *this = clientVector;
   
   return changed;
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-CppCore-v2,代码行数:74,代码来源:TileMapLayerInfo.cpp


示例11: deleteMyself

	void deleteMyself(set<Shape<int>* >& aSet) 
	{
		aSet.erase(this);
    cout << "Me: " << this->getName() << " is still in here" << endl;
    
	}
开发者ID:projectsf,项目名称:snippets,代码行数:6,代码来源:test2.cpp


示例12: GenerateSymFile

static void GenerateSymFile (set<string> &ParFunc, set<string> &UserFunc, BPatch_image *appImage, BPatch_addressSpace *appProces)
{
	ofstream symfile;
	string symname = string(::XML_GetFinalDirectory())+string("/")+string(::XML_GetTracePrefix())+".sym";

	symfile.open (symname.c_str());
	if (!symfile.good())
	{
		cerr << "Cannot create the symbolic file" << symname << endl;
		return;
	}

	for (set<string>::iterator iter = ParFunc.begin();
		iter != ParFunc.end(); iter++)
	{
		BPatch_function *f = getRoutine ((*iter).c_str(), appImage);

		if (f != NULL)
		{
			BPatch_Vector< BPatch_statement > lines;

			appProces->getSourceLines ((unsigned long) f->getBaseAddr(), lines);
			if (lines.size() > 0)
			{
				symfile << "P " << hex << f->getBaseAddr() << dec << " \"" << *iter
					<< "\" \"" <<  lines[0].fileName() <<  "\" " << lines[0].lineNumber()
					<< endl;
			}
			else
			{
				/* this happens if the application was not compiled with -g */
				char modname[1024];
				f->getModuleName (modname, 1024);
				symfile << "P " << hex << f->getBaseAddr() << dec << " \"" << *iter
					<< "\" \"" << modname << "\" 0" << endl;
			}
		}
	}

	for (set<string>::iterator iter = UserFunc.begin();
		iter != UserFunc.end(); iter++)
	{
		BPatch_function *f = getRoutine ((*iter).c_str(), appImage);

		if (f != NULL)
		{
			BPatch_Vector< BPatch_statement > lines;

			appProces->getSourceLines ((unsigned long) f->getBaseAddr(), lines);
			if (lines.size() > 0)
			{
				symfile << "U " << hex << f->getBaseAddr() << dec << " \"" << *iter
					<< "\" \"" << lines[0].fileName() <<  "\" " << lines[0].lineNumber()
					<< endl;
			}
			else
			{
				/* this happens if the application was not compiled with -g */
				char modname[1024];
				f->getModuleName (modname, 1024);
				symfile << "U " << hex << f->getBaseAddr() << dec << " \"" << *iter
					<< "\" \"" << modname << "\" 0" << endl;
			}
		}
	}

    map<string, unsigned>::iterator BB_symbols_iter = BB_symbols->begin();
    map<string, unsigned>::iterator BB_symbols_end = BB_symbols->end();
    while(BB_symbols_iter != BB_symbols_end){
        symfile << "b " << BB_symbols_iter->second << " \"" << BB_symbols_iter->first << "\"\n";
        BB_symbols_iter++;
    }



	symfile.close();
}
开发者ID:polca-project,项目名称:polca-toolbox,代码行数:77,代码来源:extrae.C


示例13: buildSymbols

void Grammar::build_CFSM() {
	set<ConfigurationSet> 	S;
	queue<ConfigurationSet>	Q;
	ConfigurationSet 		s0, sb;
	int 					label = 0;
	ConfigurationSet::State state;
	
	state.dot = 0;
	state.lookahead = vector<string>();
	state.lookahead.push_back(Grammar::lambda);
	for(size_t i = 0; i < rules.size(); i++) {
		if(rules[i].LHS == this->start_symbol) {
			s0.configs.insert(make_pair(rules[i], state));
		}
	}
	s0 = ConfigurationSet::closure0(s0, *this);
	s0.label = label++;
	
	S.insert(s0);
	Q.push(s0);
	
	buildSymbols();
	/* hw need */
	map<int, vector< pair<int, string> > > hwPrint;
	/* hw need */
	while(!Q.empty()) {
		s0 = Q.front(), Q.pop();
		LRstates.push_back(s0);
		for(set<string>::iterator it = symbols.begin();
			it != symbols.end(); it++) {
			sb = ConfigurationSet::go_to0(s0, *it, *this);
			if(sb.configs.size() > 0) {
				if(S.find(sb) == S.end()) {
					sb.label = label++;
					S.insert(sb);
					Q.push(sb);
				}
				
				go_to_table[s0.label][*it] = (* S.find(sb)).label;
				/* hw need */
				hwPrint[(* S.find(sb)).label].push_back(make_pair(s0.label, *it));
			}
		}
	}
	// build_action();
#ifdef DEBUG	
	printf("Total State: %d\n", label);
	for(int i = 0; i < label; i++) {
		if(hwPrint[i].size() > 0) {
			printf("State %d from", i);
			for(vector< pair<int, string> >::iterator it = hwPrint[i].begin();
				it != hwPrint[i].end(); it++) {
				printf("%cState %d(%s)", it == hwPrint[i].begin() ? ' ' : ',', it->first, it->second.c_str());
			}
			puts("");
		} else {
			printf("State %d\n", i);
		}
		LRstates[i].print(*this);
		puts("");
	}
#endif
}
开发者ID:JohnXinhua,项目名称:UVa,代码行数:63,代码来源:171+-+Car+Trialling.cpp


示例14: AddTimeData

void AddTimeData(const CNetAddr& ip, int64_t nTime)
{
    int64_t nOffsetSample = nTime - GetTime();

    LOCK(cs_nTimeOffset);
    // Ignore duplicates
    static set<CNetAddr> setKnown;
    if (!setKnown.insert(ip).second)
        return;

    // Add data
    static CMedianFilter<int64_t> vTimeOffsets(200,0);
    vTimeOffsets.input(nOffsetSample);
    LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60);

    // There is a known issue here (see issue #4521):
    //
    // - The structure vTimeOffsets contains up to 200 elements, after which
    // any new element added to it will not increase its size, replacing the
    // oldest element.
    //
    // - The condition to update nTimeOffset includes checking whether the
    // number of elements in vTimeOffsets is odd, which will never happen after
    // there are 200 elements.
    //
    // But in this case the 'bug' is protective against some attacks, and may
    // actually explain why we've never seen attacks which manipulate the
    // clock offset.
    //
    // So we should hold off on fixing this and clean it up as part of
    // a timing cleanup that strengthens it in a number of other ways.
    //
    if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)
    {
        int64_t nMedian = vTimeOffsets.median();
        std::vector<int64_t> vSorted = vTimeOffsets.sorted();
        // Only let other nodes change our time by so much
        if (abs64(nMedian) < 70 * 60)
        {
            nTimeOffset = nMedian;
        }
        else
        {
            nTimeOffset = 0;

            static bool fDone;
            if (!fDone)
            {
                // If nobody has a time different than ours but within 5 minutes of ours, give a warning
                bool fMatch = false;
                BOOST_FOREACH(int64_t nOffset, vSorted)
                    if (nOffset != 0 && abs64(nOffset) < 5 * 60)
                        fMatch = true;

                if (!fMatch)
                {
                    fDone = true;
                    string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Litedoge will not work properly.");
                    strMiscWarning = strMessage;
                    LogPrintf("*** %s\n", strMessage);
                    uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
                }
            }
        }
开发者ID:ctgiant,项目名称:litedoge---DO-NOT-USE,代码行数:64,代码来源:timedata.cpp


示例15: Node

vector<vector<Node*> > PolySolverNAD::GetSortedLocalADComponents(SADNADGraph &graph, set<Node*> guys, set<Node*> otherGuys)
{
    //TODO : I was sick when I wrote the fake node addition thing.  It could probably be a lot better...
    map<Node*, vector<Node*> > localADComps;


    for (set<Node*>::iterator leftIt = guys.begin(); leftIt != guys.end(); leftIt++)
    {
        Node* g = (*leftIt);

        vector<Node*> comp;
        Node* gCompRep = graph.GetADComponentRepresentantOf(g);
        if (localADComps.find(gCompRep) != localADComps.end())
            comp = localADComps[gCompRep];
        comp.push_back(g);

        localADComps[gCompRep] = comp;
    }


    //for those AD-comps with a bridge, we need to add one fake node
    //that might break out ties in the sort and it is important
    for (map<Node*, vector<Node*> >::iterator it = localADComps.begin(); it != localADComps.end(); it++)
    {
        vector<Node*> curComp = (*it).second;
        bool hasBridge = false;

        for (int i = 0; i < curComp.size() && !hasBridge; i++)
        {
            Node* n1 = curComp[i];
            for (set<Node*>::iterator otherIt = otherGuys.begin(); otherIt != otherGuys.end() && !hasBridge; otherIt++)
            {
                Node* n2 = (*otherIt);

                if (graph.HaveSameADComponent(n1, n2))
                    hasBridge = true;
            }
        }

        if (hasBridge)
        {
            Node* nfake = new Node(false);
            //cout<<"BRIDGE ADDED TO CC OF "<<curComp[0]->GetLabel()<<endl;
            nfake->SetLabel("fake");
            curComp.push_back(nfake);
            localADComps[(*it).first] = curComp;
        }
    }


    //sort the local comps by size
    vector<vector<Node*> > v_localADComps;
    for (map<Node*, vector<Node*> >::iterator lit = localADComps.begin(); lit != localADComps.end(); lit++)
    {
        v_localADComps.push_back((*lit).second);
        //cout<<"COMP OF "<<(*lit).second[0]->GetLabel()<<"="<<(*lit).second.size()<<endl;
    }

    std::sort(v_localADComps.begin(), v_localADComps.end(), vector_size_sorter());




    vector<vector<Node*> > v_final_ad_comps;
    //then, delete any fakeass node we added
    for (int i = 0; i < v_localADComps.size(); i++)
    {
        vector<Node*> curComp = v_localADComps[i];

        //cout<<i<<" : "<<curComp[0]->GetLabel()<<" SIZE="<<curComp.size()<<endl;

        Node* last = curComp[curComp.size() - 1];
        if (last->GetLabel() == "fake")
        {
            curComp.pop_back();
            delete last;

            //localADComps[(*it).first] = curComp;
        }
        v_final_ad_comps.push_back(curComp);

    }


    return v_final_ad_comps;
}
开发者ID:UdeM-LBIT,项目名称:SuGeT,代码行数:86,代码来源:polysolver_nad.cpp


示例16: getIntervals

 vector<Interval> getIntervals() {
     return vector<Interval>(interval.begin(), interval.end());
 }
开发者ID:viing937,项目名称:leetcode,代码行数:3,代码来源:352.cpp


示例17: init_lookup_table

void init_lookup_table() { vis.clear(); }
开发者ID:XMUsoftwarehouse,项目名称:OnlineJudgeCode,代码行数:1,代码来源:8d.cpp


示例18: f

void f(int b) {
    q.clear();
    BORDER = b;
    dfs(0, 0);
}
开发者ID:slava-sh,项目名称:code-plagiarism-detector,代码行数:5,代码来源:006589-open-2015-028-Magenta.cpp


示例19: visit

 virtual void visit(SgNode* n) {nodes.insert(n);}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:1,代码来源:copyGraph.C


示例20: isinL

bool isinL(int x){
	if (L.find(x) != L.end()) return true;
	return false;
}
开发者ID:m-den-i,项目名称:nastya,代码行数:4,代码来源:main.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ set_type类代码示例发布时间:2022-05-31
下一篇:
C++ session_ptr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap