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


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

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


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

示例1: fillGraphFromTreeVar


//.........这里部分代码省略.........
      if( !gid ) {
	cerr << "id key must be defined first in the section" << endl; continue;
      }
      if (v_graphs.size()) {
	cerr << "graph(s) already defined" << endl; continue;
      }

      Tokenize(value,v_tokens,";");
      string treedrawspec=v_tokens[0];

      int ifirst=-1,ilast=-1;
      if (v_tokens.size() == 2) {
	string range=v_tokens[1];
	Tokenize(range,v_tokens,"-");
	if (v_tokens.size()==2) {
	  ifirst=str2int(v_tokens[0]);
	  ilast =str2int(v_tokens[1]);
	}
      }
      //cout << v_tokens.size() << " " << ifirst << " " << ilast << endl;
      if (ifirst>0 && 
	  ilast>=ifirst ) {
	for (int i=ifirst; i<=ilast; i++) {
	  wGraph_t *pwg = NULL;

	  // defined in spTree.C
	  void fillGraphFromTreeVar(std::string& drawspec,int index,wGraph_t *&pwg);
	  fillGraphFromTreeVar(treedrawspec,i,pwg);
	  assert(pwg);
	  string gidi= (*gid)+"_"+int2str(i-ifirst);
	  v_graphs.push_back(std::pair<string,wGraph_t *>(gidi,pwg));
	}

	glmap_mgid2size.insert(pair<string,unsigned>(*gid,v_graphs.size()));
      } else {
	wGraph_t *pwg = NULL;
	void fillGraphFromTreeVar(std::string& drawspec,int index,wGraph_t *&pwg);
	fillGraphFromTreeVar(treedrawspec,0,pwg);
	assert(pwg);
	v_graphs.push_back(std::pair<string,wGraph_t *>(*gid,pwg));
	glmap_mgid2size.insert(pair<string,unsigned>(*gid,v_graphs.size()));
      }

    //------------------------------
    } else if (key == "bayesdiv") {
    //------------------------------

      Tokenize(value,v_tokens,",/"); // either comma-separated or using '/'
      if (v_tokens.size() != 2) {
	cerr << "expect comma-separated list of exactly two histo specs to divide! ";
	cerr << theline << endl;
	continue;
      }

      TH1 *tmph1 = (TH1 *)findHisto(v_tokens[0]); if (!tmph1) exit(-1);
      TH1 *tmph2 = (TH1 *)findHisto(v_tokens[1]); if (!tmph2) exit(-1);

      cout << tmph1->GetNbinsX() << " " << tmph2->GetNbinsX() << endl;

      wGraph_t *pwg = new wGraph_t();

      if ( gl_verbose ) { 
	std::cout << "Dump of bin contents, errors" << std::endl ; 
	if ( tmph1->GetNbinsX() == tmph2->GetNbinsX() ) { 
	  for (int ib=1; ib<=tmph1->GetNbinsX(); ib++) {
	    std::cout << ib << ": " << tmph1->GetBinContent(ib) << "+/-" << tmph1->GetBinError(ib) 
开发者ID:kalanand,项目名称:UserCode,代码行数:67,代码来源:spGraph.C

示例2: ProcessAlert

bool CAlert::ProcessAlert()
{
    if (!CheckSignature())
        return false;
    if (!IsInEffect())
        return false;
    
    int maxInt = std::numeric_limits<int>::max();
    if (nID == maxInt)
    {
        if (!(
                nExpiration == maxInt &&
                nCancel == (maxInt-1) &&
                nMinVer == 0 &&
                nMaxVer == maxInt &&
                setSubVer.empty() &&
                nPriority == maxInt &&
                strStatusBar == "URGENT: Alert key compromised, upgrade required"
                ))
            return false;
    }

    {
        LOCK(cs_mapAlerts);
        // Cancel previous alerts
        for (map<uint256, CAlert>::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();)
        {
            const CAlert& alert = (*mi).second;
            if (Cancels(alert))
            {
                printf("cancelling alert %d\n", alert.nID);
                uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
                mapAlerts.erase(mi++);
            }
            else if (!alert.IsInEffect())
            {
                printf("expiring alert %d\n", alert.nID);
                uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
                mapAlerts.erase(mi++);
            }
            else
                mi++;
        }

        // Check if this alert has been cancelled
        BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
        {
            const CAlert& alert = item.second;
            if (alert.Cancels(*this))
            {
                printf("alert already cancelled by %d\n", alert.nID);
                return false;
            }
        }

        // Add to mapAlerts
        mapAlerts.insert(make_pair(GetHash(), *this));

        if(AppliesToMe())
            uiInterface.NotifyAlertChanged(GetHash(), CT_NEW);
    }

    printf("accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
    return true;
}
开发者ID:Coder420,项目名称:MACDCoin,代码行数:65,代码来源:alert.cpp

示例3: ProcessAlert

bool CAlert::ProcessAlert(bool fThread)
{
    if (!CheckSignature())
        return false;
    if (!IsInEffect())
        return false;

    // alert.nID=max is reserved for if the alert key is
    // compromised. It must have a pre-defined message,
    // must never expire, must apply to all versions,
    // and must cancel all previous
    // alerts or it will be ignored (so an attacker can't
    // send an "everything is OK, don't panic" version that
    // cannot be overridden):
    int maxInt = std::numeric_limits<int>::max();
    if (nID == maxInt)
    {
        if (!(
                nExpiration == maxInt &&
                nCancel == (maxInt-1) &&
                nMinVer == 0 &&
                nMaxVer == maxInt &&
                setSubVer.empty() &&
                nPriority == maxInt &&
                strStatusBar == "URGENT: Alert key compromised, upgrade required"
                ))
            return false;
    }

    {
        LOCK(cs_mapAlerts);
        // Cancel previous alerts
        for (map<uint256, CAlert>::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();)
        {
            const CAlert& alert = (*mi).second;
            if (Cancels(alert))
            {
                LogPrint("alert", "cancelling alert %d\n", alert.nID);
                uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
                mapAlerts.erase(mi++);
            }
            else if (!alert.IsInEffect())
            {
                LogPrint("alert", "expiring alert %d\n", alert.nID);
                uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
                mapAlerts.erase(mi++);
            }
            else
                mi++;
        }

        // Check if this alert has been cancelled
        BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
        {
            const CAlert& alert = item.second;
            if (alert.Cancels(*this))
            {
                LogPrint("alert", "alert already cancelled by %d\n", alert.nID);
                return false;
            }
        }

        // Add to mapAlerts
        mapAlerts.insert(make_pair(GetHash(), *this));
        // Notify UI and -alertnotify if it applies to me
        if(AppliesToMe())
        {
            uiInterface.NotifyAlertChanged(GetHash(), CT_NEW);
            std::string strCmd = GetArg("-alertnotify", "");
            if (!strCmd.empty())
            {
                // Alert text should be plain ascii coming from a trusted source, but to
                // be safe we first strip anything not in safeChars, then add single quotes around
                // the whole string before passing it to the shell:
                std::string singleQuote("'");
                std::string safeStatus = SanitizeString(strStatusBar);
                safeStatus = singleQuote+safeStatus+singleQuote;
                boost::replace_all(strCmd, "%s", safeStatus);

                if (fThread)
                    boost::thread t(runCommand, strCmd); // thread runs free
                else
                    runCommand(strCmd);
            }
        }
    }

    LogPrint("alert", "accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
    return true;
}
开发者ID:4tar,项目名称:bitcoin,代码行数:90,代码来源:alert.cpp

示例4: addValue

	void addValue(string key, int value)
	{
		valueMap.insert(std::pair<string, int>(key, value));
	}
开发者ID:skmygdrs,项目名称:jgy_code,代码行数:4,代码来源:13_Interpreter.cpp

示例5: Myfile

set<pEdge> FileManagerFunctions::Merge_Edges(set<pEdge> CommonEdges, pMesh theMesh, map<int,pEdge> EdgesMap, int c, string FileName){
		
	string pontobarra = "./";
	ostringstream os;
	os << pontobarra;
	os << FileName;

	std::string filename = os.str();

	ofstream Myfile(filename.c_str(), ios::app);


	set<pEdge> GeomBdryEdges;
	set<pEdge> newEdges;
	set<pEdge> SameEdge;
	set<pEdge> SameCoefEdges;

	set<pEdge>::iterator edgeiterator;
	set<pEdge>::iterator itEds;


	for(itEds=CommonEdges.begin(); itEds!=CommonEdges.end(); itEds++){
		if (E_numFaces(*itEds)==0){
			GeomBdryEdges.insert(*itEds);
		}
	}

	int y = 0;

	// iterando pelas arestas do contorno da geometria para separar o primeiro grupo de arestas com mesmo coeficiente angular

	while(GeomBdryEdges.size()>0){

		pEdge Edge1 = *GeomBdryEdges.begin();  //	PEGA UMA ARESTA

		double m1 = 0;

		EN_getDataDbl (Edge1, MD_lookupMeshDataId("Angular_Coef"), &m1); 
		SameCoefEdges.insert(Edge1);


		for(itEds=GeomBdryEdges.begin(); itEds!=GeomBdryEdges.end(); itEds++){  // E PEGA AS OUTRAS Q TIVEREM MESMO COEFICIENTE ANGULAR
			pEdge Edge2 = *itEds;

			double m2 = 0;
			EN_getDataDbl (Edge2, MD_lookupMeshDataId("Angular_Coef"), &m2);

			if (m1==m2){
				SameCoefEdges.insert(Edge2);
			}
		}

		while (SameCoefEdges.size()>0){

			// iniciando a funcao merge_edge
			pEdge Old_Edg1 = *SameCoefEdges.begin();
			pEdge Old_Edg2 = *SameCoefEdges.begin();

			pVertex Vert1 = E_vertex(Old_Edg1,0);
			pVertex Vert2 = E_vertex(Old_Edg2,1);

			SameEdge.insert(Old_Edg1);

			int v1 = 0;
			int v2 = 0;
			int V = 1;

			//agora está identificando as arestas que serao unidas	
			while (V==1){
				v1 =0;
				v2 =0;

				int Numb_Edges1 = V_numEdges(Vert1);
				int Numb_Edges2 = V_numEdges(Vert2);

				for(int i = 0 ; i < Numb_Edges1 ; i++){

					pEdge Edg1 = V_edge(Vert1, i);

					if (Edg1!=Old_Edg1 && SameCoefEdges.count(Edg1)==1){
						Vert1 = E_otherVertex(Edg1, Vert1);
						Old_Edg1 = Edg1;
						SameEdge.insert(Edg1);
						v1 = 1; // Preciso deletar da malha as arestas que serao mergidas...
						//cout << "v1 = " << v1 << endl;
					}
				}
				for(int i = 0 ; i < Numb_Edges2 ; i++){
					pEdge Edg2 = V_edge(Vert2, i);
					if (Edg2!=Old_Edg2 && SameCoefEdges.count(Edg2)==1){
						Vert2 = E_otherVertex(Edg2, Vert2);
						Old_Edg2 = Edg2;
						SameEdge.insert(Edg2);
						v2 = 1;
						//cout << "v2 = " << v2 << endl;
					}
				}
				//				cout << "v1 e v2 " << v1 << " " << v2 << endl;
				//				cout << "GeomBdryEdges.size() " << GeomBdryEdges.size() << endl;

//.........这里部分代码省略.........
开发者ID:andreabduque,项目名称:padmec-amr,代码行数:101,代码来源:FileManagerFunctions.cpp

示例6: SetFood

		virtual void SetFood(const Food *food)
		{
            ConcreteFood *new_food = new ConcreteFood(food);
			foodMap.insert(pair<Point, const Food*>(new_food->getPoint(), new_food));
		}
开发者ID:kondra,项目名称:CPP-Training,代码行数:5,代码来源:AntGuiImpl.hpp

示例7: ProcessAlert

bool CAlert::ProcessAlert()
{
    if (!CheckSignature())
        return false;
    if (!IsInEffect())
        return false;

    // alert.nID=max is reserved for if the alert key is
    // compromised. It must have a pre-defined message,
    // must never expire, must apply to all versions,
    // and must cancel all previous
    // alerts or it will be ignored (so an attacker can't
    // send an "everything is OK, don't panic" version that
    // cannot be overridden):
    int maxInt = std::numeric_limits<int>::max();
    if (nID == maxInt)
    {
        if (!(
                nExpiration == maxInt &&
                nCancel == (maxInt-1) &&
                nMinVer == 0 &&
                nMaxVer == maxInt &&
                setSubVer.empty() &&
                nPriority == maxInt &&
                strStatusBar == "URGENT: Alert key compromised, upgrade required"
                ))
            return false;
    }

    {
        LOCK(cs_mapAlerts);
        // Cancel previous alerts
        for (map<uint256, CAlert>::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();)
        {
            const CAlert& alert = (*mi).second;
            if (Cancels(alert))
            {
                printf("cancelling alert %d\n", alert.nID);
                uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
                mapAlerts.erase(mi++);
            }
            else if (!alert.IsInEffect())
            {
                printf("expiring alert %d\n", alert.nID);
                uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
                mapAlerts.erase(mi++);
            }
            else
                mi++;
        }

        // Check if this alert has been cancelled
        BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
        {
            const CAlert& alert = item.second;
            if (alert.Cancels(*this))
            {
                printf("alert already cancelled by %d\n", alert.nID);
                return false;
            }
        }

        // Add to mapAlerts
        mapAlerts.insert(make_pair(GetHash(), *this));
        // Notify UI if it applies to me
        if(AppliesToMe())
            uiInterface.NotifyAlertChanged(GetHash(), CT_NEW);
    }

    printf("accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
    return true;
}
开发者ID:BitTreasuryNote,项目名称:Bit-Treasury-Note,代码行数:72,代码来源:alert.cpp

示例8: setMapping

void setMapping()
{
	participation = 0;
	if (M->myRatId().value() == 7)
	{
		Mapping_idToIndex.insert(pair<int, int>(7,0));
		for(int i = 0; i < 7 ; i++)
			Mapping_idToIndex.insert(pair<int, int>(i,i+1));
		Mapping_indexToId.insert(pair<int, int>(0,7));		
		Mapping_indexToId.insert(pair<int, int>(1,0));
		Mapping_indexToId.insert(pair<int, int>(2,1));
		Mapping_indexToId.insert(pair<int, int>(3,2));
		Mapping_indexToId.insert(pair<int, int>(4,3));
		Mapping_indexToId.insert(pair<int, int>(5,4));
		Mapping_indexToId.insert(pair<int, int>(6,5));
		Mapping_indexToId.insert(pair<int, int>(7,6));	
	}
	else if (M->myRatId().value() == 6)
	{	
		Mapping_idToIndex.insert(pair<int, int>(6,0));
		Mapping_idToIndex.insert(pair<int, int>(7,1));
		for(int i = 0; i < 6; i++)
			Mapping_idToIndex.insert(pair<int, int>(i,i+2));
		Mapping_indexToId.insert(pair<int, int>(0,6));		
		Mapping_indexToId.insert(pair<int, int>(1,7));
		Mapping_indexToId.insert(pair<int, int>(2,0));
		Mapping_indexToId.insert(pair<int, int>(3,1));
		Mapping_indexToId.insert(pair<int, int>(4,2));
		Mapping_indexToId.insert(pair<int, int>(5,3));
		Mapping_indexToId.insert(pair<int, int>(6,4));
		Mapping_indexToId.insert(pair<int, int>(7,5));
	}
	else if (M->myRatId().value() == 5)
	{	
		Mapping_idToIndex.insert(pair<int, int>(5,0));
		Mapping_idToIndex.insert(pair<int, int>(6,1));
		Mapping_idToIndex.insert(pair<int, int>(7,2));
		for(int i = 0; i < 5; i++)
			Mapping_idToIndex.insert(pair<int, int>(i,i+3));
		Mapping_indexToId.insert(pair<int, int>(0,5));		
		Mapping_indexToId.insert(pair<int, int>(1,6));
		Mapping_indexToId.insert(pair<int, int>(2,7));
		Mapping_indexToId.insert(pair<int, int>(3,0));
		Mapping_indexToId.insert(pair<int, int>(4,1));
		Mapping_indexToId.insert(pair<int, int>(5,2));
		Mapping_indexToId.insert(pair<int, int>(6,3));
		Mapping_indexToId.insert(pair<int, int>(7,4));	
	}
	else if (M->myRatId().value() == 4)
	{	
		Mapping_idToIndex.insert(pair<int, int>(4,0));
		Mapping_idToIndex.insert(pair<int, int>(5,1));
		Mapping_idToIndex.insert(pair<int, int>(6,2));
		Mapping_idToIndex.insert(pair<int, int>(7,3));
		for(int i = 0; i < 4; i++)
			Mapping_idToIndex.insert(pair<int, int>(i,i+4));
		Mapping_indexToId.insert(pair<int, int>(0,4));		
		Mapping_indexToId.insert(pair<int, int>(1,5));
		Mapping_indexToId.insert(pair<int, int>(2,6));
		Mapping_indexToId.insert(pair<int, int>(3,7));
		Mapping_indexToId.insert(pair<int, int>(4,0));
		Mapping_indexToId.insert(pair<int, int>(5,1));
		Mapping_indexToId.insert(pair<int, int>(6,2));
		Mapping_indexToId.insert(pair<int, int>(7,3));	
	}
	else if (M->myRatId().value() == 3)
	{	
		Mapping_idToIndex.insert(pair<int, int>(3,0));		
		Mapping_idToIndex.insert(pair<int, int>(4,1));
		Mapping_idToIndex.insert(pair<int, int>(5,2));
		Mapping_idToIndex.insert(pair<int, int>(6,3));
		Mapping_idToIndex.insert(pair<int, int>(7,4));
		for(int i = 0; i < 3; i++)
			Mapping_idToIndex.insert(pair<int, int>(i,i+5));
		Mapping_indexToId.insert(pair<int, int>(0,3));		
		Mapping_indexToId.insert(pair<int, int>(1,4));
		Mapping_indexToId.insert(pair<int, int>(2,5));
		Mapping_indexToId.insert(pair<int, int>(3,6));
		Mapping_indexToId.insert(pair<int, int>(4,7));
		Mapping_indexToId.insert(pair<int, int>(5,0));
		Mapping_indexToId.insert(pair<int, int>(6,1));
		Mapping_indexToId.insert(pair<int, int>(7,2));	

	}
	else if (M->myRatId().value() == 2)
	{	
		Mapping_idToIndex.insert(pair<int, int>(2,0));		
		Mapping_idToIndex.insert(pair<int, int>(3,1));
		Mapping_idToIndex.insert(pair<int, int>(4,2));
		Mapping_idToIndex.insert(pair<int, int>(5,3));
		Mapping_idToIndex.insert(pair<int, int>(6,4));
		Mapping_idToIndex.insert(pair<int, int>(7,5));
		for(int i = 0; i < 2; i++)
			Mapping_idToIndex.insert(pair<int, int>(i,i+6));
		Mapping_indexToId.insert(pair<int, int>(0,2));		
		Mapping_indexToId.insert(pair<int, int>(1,3));
		Mapping_indexToId.insert(pair<int, int>(2,4));
		Mapping_indexToId.insert(pair<int, int>(3,5));
		Mapping_indexToId.insert(pair<int, int>(4,6));
		Mapping_indexToId.insert(pair<int, int>(5,7));
//.........这里部分代码省略.........
开发者ID:kalimfaria,项目名称:mazewar,代码行数:101,代码来源:toplevel.cpp

示例9: rip

  void IDRipper::rip(map<String, pair<vector<ProteinIdentification>, vector<PeptideIdentification> > >& ripped, vector<ProteinIdentification>& proteins, vector<PeptideIdentification>& peptides)
  {
    // Collect all protein hits
    vector<ProteinHit> all_protein_hits;
    for (vector<ProteinIdentification>::iterator prot_it = proteins.begin(); prot_it != proteins.end(); ++prot_it)
    {
      // remove file origin
      prot_it->removeMetaValue("file_origin");
      vector<ProteinHit>& protein_hits  = prot_it->getHits();
      all_protein_hits.insert(all_protein_hits.end(), protein_hits.begin(), protein_hits.end());
    }

    //store protein and peptides identifications for each file origin

    for (vector<PeptideIdentification>::iterator pep_it = peptides.begin(); pep_it != peptides.end(); ++pep_it)
    {
      // try to get file_origin, if not present ignore peptide identification
      const String& file_origin = pep_it->getMetaValue("file_origin").toString();
      // QFileInfo fi("/tmp/archive.tar.gz");
      // QString name = fi.fileName(); --> name = "archive.tar.gz"
      const String file_ = QFileInfo(file_origin.toQString()).fileName().toStdString();

      //remove file origin
      pep_it->removeMetaValue("file_origin");

      //TODO LOG that file_origin was not as expected
      if (file_.empty())
        continue;

      // try to get peptide hits for peptide identification
      const vector<PeptideHit>& peptide_hits = pep_it->getHits();
      if (peptide_hits.empty())
        continue;

      // collect all protein accessions that are stored in the peptide hits
      vector<String> protein_accessions;
      getProteinAccessions_(protein_accessions, peptide_hits);

      // returns all protein hits that are associated with the given peptide hits
      vector<ProteinHit> protein2accessions;
      getProteinHits_(protein2accessions, all_protein_hits, protein_accessions);

      // search for the protein identification of the peptide identification
      ProteinIdentification prot_ident;
      getProteinIdentification_(prot_ident, *pep_it, proteins);
      // TODO catch case that ProteinIdentification prot_ident is not found in the for-loop


      map<String, pair<vector<ProteinIdentification>, vector<PeptideIdentification> > >::iterator it = ripped.find(file_);
      // If file_origin already exists
      if (it != ripped.end())
      {
        vector<ProteinIdentification>& prot_tmp = it->second.first;
        bool flag = true;
        //what to do if there is one then more protein identification, can this occur at all?
        for (vector<ProteinIdentification>::iterator it2 = prot_tmp.begin(); it2 != prot_tmp.end(); ++it2)
        {
          // ProteinIdentification is already there, just add protein hits
          if (prot_ident.getIdentifier().compare(it2->getIdentifier()) == 0)
          {
            for (vector<ProteinHit>::const_iterator prot_it = protein2accessions.begin(); prot_it != protein2accessions.end(); ++prot_it)
            {
              it2->insertHit(*prot_it);
            }
            flag = false;
            break;
          }
        }
        // if it was not found
        if (flag)
        {
          prot_ident.setHits(protein2accessions);
          prot_tmp.push_back(prot_ident);
        }
        vector<PeptideIdentification>& pep_tmp = it->second.second;
        pep_tmp.push_back(*pep_it);
      }
      else // otherwise create new entry for file_origin
      {
        // create protein identification, TODO parameters
        vector<ProteinIdentification> protein_idents;
        // only use the protein hits that are needed for the peptide identification
        prot_ident.setHits(protein2accessions);
        protein_idents.push_back(prot_ident);

        //create new peptide identification
        vector<PeptideIdentification> peptide_idents;
        peptide_idents.push_back(*pep_it);

        //create and insert new map entry
        ripped.insert(make_pair(file_, make_pair(protein_idents, peptide_idents)));
      }
    }
  }
开发者ID:OpenMS,项目名称:OpenMS,代码行数:94,代码来源:IDRipper.cpp

示例10: if

void lexical :: scan(string inp){
priority.push_back(punc);
        priority.push_back(key);
    vector<string>temp;
    string emp="";
    for(int i=0;i<inp.size();i++){
        if(inp[i]==' '){
              if(emp!="")
              temp.push_back(emp);
            emp="";
            continue;
        }
        if((inp[i]=='='||inp[i]==':')&&temp.size()>1){
            emp+=inp[i];
            continue;
        }

        if(inp[i]=='['||inp[i]==']'||inp[i]=='{'||inp[i]=='}'||inp[i]=='|'||inp[i]=='('||inp[i]==')'||inp[i]==':'||inp[i]=='+'||inp[i]=='-'||inp[i]=='*'||inp[i]=='='){
              if(i>0&&inp[i-1]=='\\')
              emp+=inp[i];
              else{
              if(emp!="")
              temp.push_back(emp);
                emp="";
                emp+=inp[i];
                temp.push_back(emp);
                emp="";
              }
                continue;
        }
         emp+=inp[i];
    }

    if(emp!="")
        temp.push_back(emp);



    if(temp[0]=="["){

        for(int i=1;i<temp.size()-1;i++)
            Punctuations.push_back(splitSlach(temp[i]));



    }
    else if(temp[0]=="{"){
        for(int i=1;i<temp.size()-1;i++)
            keyWords.push_back(splitSlach(temp[i]));

    }
    else if(temp[1]=="="){
        //tie_with_start_state(splitChar(temp[0]));

            def_names.insert(pair<string,int>(temp[0],definations.size()));

            definations.push_back(postFix(temp,2));
    }
    else if(temp[1]==":"){
            priority.push_back(temp[0]);
           // tie_with_start_state(splitChar(temp[0]));
             reg_names.insert(pair<string,int>(temp[0],regularExpression.size()));
     reg_names_by_int.insert(pair<int,string>(regularExpression.size(),temp[0]));
                regularExpression.push_back(postFix(temp,2));
    }


}
开发者ID:mohamednabil00000,项目名称:Lexical-and-Parser-Analyzer-in-cpp,代码行数:68,代码来源:lexical.cpp

示例11: main

int main(int argc, char **argv)
{
	srand (static_cast <unsigned> (time(0)));

	int m,i,j,x,y,iters;

	char c;
	cin>>c;

    cout<<"Input Size, edges : ";
    cin>>sz>>m;
    
    size=sz;
    float share,stretch,localt,threshold;
	
	share=0.8,stretch=0.4,localt=0.15;
	threshold=0.05;
    /*cout<<"Enter parameters : share, stretch, localt: ";
    cin>>share>>stretch>>localt;

    cout<<"Enter threshold for random graph: ";
    cin>>threshold;
	*/

	cout<<"The parameters are : share: "<<share<<", stretch: "<<stretch<<", localt: "<<localt<<endl;

    int sum=0,tmp=iters,v=1;

    graph.resize(sz+2);
    revgraph.resize(sz+2);
    prev.resize(sz+2);
    fora.resize(sz+2);

    for(i=0;i<m;i++)
    {
    	cin>>c;
		long long int x,y,mx,my;
    	float a;
        scanf("%lld %lld %f",&x,&y,&a);
        if(vertices.find(x)==vertices.end())
        {
        	vertices.insert(make_pair(x,v));
        	v++;
        }
        if(vertices.find(y)==vertices.end())
        {
        	vertices.insert(make_pair(y,v));
        	v++;
        }
        edge t;
        t.end_node=vertices[y];
        t.weight=a;
        graph[vertices[x]].push_back(t);
        //epair p1 (x,y);
        //lengths.insert(make_pair(p1,a));
        /*t.end_node=x;
        t.weight=a;
        graph[y].push_back(t);
        epair p2 (y,x);
        lengths.insert(make_pair(p2,a));
    	*/
    }

    cout<<"INPUT DONE, Actual Size is "<<v<<"\n";
    size=sz=v;
    //cin>>v;

    //undir_random_graph(graph,size,threshold);   

    for(i=1;i<=size;i++)
    {
    	for(j=0;j<graph[i].size();j++)
    	{
    		int x=i,y=graph[i][j].end_node;
    		float a=graph[i][j].weight;
    		epair p1 (x,y);
	        if(lengths.find(p1)==lengths.end())
	        	lengths.insert(make_pair(p1,a));
	        else
	        	lengths[p1]=min(lengths[p1],a);
	        /*epair p2 (y,x);
	        if(lengths.find(p2)==lengths.end())
	        	lengths.insert(make_pair(p2,a));
	        else
	        	lengths[p2]=min(lengths[p2],a);
    		*/
    	}
    }

    for(i=0;i<=size;i++)
    {
        epair p1 (0,i);
        lengths.insert(make_pair(p1,0));
        epair p2 (i,0);
        lengths.insert(make_pair(p2,0));
        
    	for(j=0;j<graph[i].size();j++)
    	{
    		edge t;
    		t.end_node=i;
//.........这里部分代码省略.........
开发者ID:nishantrai18,项目名称:alternate_paths,代码行数:101,代码来源:bdv_sstplotter.cpp

示例12: createMesh

GLuint createMesh(const GLuint numVerts, const GLfloat* vertices, const GLfloat* colours, 
	const GLfloat* normals, const GLfloat* texcoords, const GLuint indexCount, const GLuint* indices) {
	GLuint VAO;
	// generate and set up a VAO for the mesh
	glGenVertexArrays(1, &VAO);
	glBindVertexArray(VAO);

	GLuint *pMeshBuffers = new GLuint[5];


	if (vertices == nullptr) {
		// cant create a mesh without vertices... oops
		exitFatalError("Attempt to create a mesh with no vertices");
	}

	// generate and set up the VBOs for the data
	GLuint VBO;
	glGenBuffers(1, &VBO);
	
	// VBO for vertex data
	glBindBuffer(GL_ARRAY_BUFFER, VBO);
	glBufferData(GL_ARRAY_BUFFER, 3*numVerts*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
	glVertexAttribPointer((GLuint)VERTEX, 3, GL_FLOAT, GL_FALSE, 0, 0); 
	glEnableVertexAttribArray(VERTEX);
	pMeshBuffers[VERTEX] = VBO;


	// VBO for colour data
	if (colours != nullptr) {
		glGenBuffers(1, &VBO);
		glBindBuffer(GL_ARRAY_BUFFER, VBO);
		glBufferData(GL_ARRAY_BUFFER, 3*numVerts*sizeof(GLfloat), colours, GL_STATIC_DRAW);
		glVertexAttribPointer((GLuint)COLOUR, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glEnableVertexAttribArray(COLOUR);
		pMeshBuffers[COLOUR] = VBO;
	}

	// VBO for normal data
	if (normals != nullptr) {
		glGenBuffers(1, &VBO);
		glBindBuffer(GL_ARRAY_BUFFER, VBO);
		glBufferData(GL_ARRAY_BUFFER, 3*numVerts*sizeof(GLfloat), normals, GL_STATIC_DRAW);
		glVertexAttribPointer((GLuint)NORMAL, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glEnableVertexAttribArray(NORMAL);
		pMeshBuffers[NORMAL] = VBO;
	}

	// VBO for tex-coord data
	if (texcoords != nullptr) {
		glGenBuffers(1, &VBO);
		glBindBuffer(GL_ARRAY_BUFFER, VBO);
		glBufferData(GL_ARRAY_BUFFER, 2*numVerts*sizeof(GLfloat), texcoords, GL_STATIC_DRAW);
		glVertexAttribPointer((GLuint)TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, 0);
		glEnableVertexAttribArray(TEXCOORD);
		pMeshBuffers[TEXCOORD] = VBO;
	}

	if (indices != nullptr && indexCount > 0) {
		glGenBuffers(1, &VBO);
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VBO);
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * sizeof(GLuint), indices, GL_STATIC_DRAW);
		pMeshBuffers[INDEX] = VBO;
	}
	// unbind vertex array
	glBindVertexArray(0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
	// return the identifier needed to draw this mesh

	vertexArrayMap.insert( pair<GLuint, GLuint *>(VAO, pMeshBuffers) );

	return VAO;
}
开发者ID:windywyll,项目名称:InfographieEnvConvex,代码行数:72,代码来源:Tools.cpp

示例13: load_reference_sequence_speedup

void load_reference_sequence_speedup(string fasta_filename, map<string, string>& ref_seq, vector<string>* orignal_header = NULL)
{
    cout << "Loading reference sequence: " << fasta_filename << endl;
    ifstream ref_fs(fasta_filename.c_str());
    if(!ref_fs)
    {
        cerr << "[ERROR] fail to open reference fasta file: " << fasta_filename << endl;
        exit(1);
    }
    string fasta_index_filename = fasta_filename + ".fai";
    ifstream index_fs(fasta_index_filename.c_str());
    if(!index_fs)
    {
        cerr << "[ERROR] fail to open reference fasta index file: " << fasta_index_filename << endl;
        exit(1);
    }
    string line;
    while(getline(index_fs, line))
    {
        vector<string> index_items;
        split(line, '\t', index_items);
        
        string chrom_name = index_items[0];
        int chrom_len = atoi(index_items[1].c_str());
        long long int chrom_offset = atoll(index_items[2].c_str());
        int base_per_line = atoi(index_items[3].c_str());
        int byte_per_line = atoi(index_items[4].c_str());
        int byte_len = chrom_len + (chrom_len / base_per_line) * (byte_per_line - base_per_line);
        if(orignal_header != NULL)
            orignal_header->push_back(chrom_name);
#ifdef _FASTA_DEBUG
        cerr << "[DEBUG] index entry: chrom_name:" << chrom_name << "\tchrom_len:" << chrom_len << "\tchrom_offset:" << chrom_offset << "\tbase:" << base_per_line << "\tbyte" << byte_per_line << endl;
#endif
        string new_seq;
        ref_seq.insert(make_pair(chrom_name, new_seq));
        ref_seq[chrom_name].resize(chrom_len);
#ifdef _FASTA_DEBUG
        cerr << "[DEBUG] ref_seq size has been resized to " << ref_seq[chrom_name].length() << endl;
#endif
        ref_fs.seekg(chrom_offset);
        char* seq_buff = new char[byte_len];
        ref_fs.read(seq_buff, byte_len);
#ifdef _FASTA_DEBUG
        if(ref_fs.gcount() != byte_len)
            cerr << "[DEBUG] gcount does not equal to bytelen " << ref_fs.gcount() << " != " << byte_len << endl;
        cerr << "[DEBUG] last char in the buffer is: " << seq_buff[byte_len - 1] << endl;
#endif
        string::iterator it_target = ref_seq[chrom_name].begin();
        char* it_source = seq_buff;
        for(int i = 0; i < byte_len; i++)
        {
            if(!isspace(*it_source))
            {
                *it_target = toupper(*it_source);
                it_target ++;
            }
            it_source ++;
        }
        delete[] seq_buff;
#ifdef _FASTA_DEBUG
        cout << "[DEBUG] reference sequence loaded for: " << chrom_name << endl;
#endif
    }
    ref_fs.close();
    index_fs.close();
}
开发者ID:zengzheng123,项目名称:CountErrors,代码行数:66,代码来源:CountErrors.cpp

示例14: initAll

void initAll()
{
    cout << "Connecting.." << endl;
	client = new ClientClick();
	functionMap.insert(make_pair("ping",*ping));
}
开发者ID:RoaldGit,项目名称:AutonoomGUI,代码行数:6,代码来源:main.cpp

示例15: init

void init(){
	m.insert(make_pair('A', 2));
	m.insert(make_pair('B', 2));
	m.insert(make_pair('C', 2));
	m.insert(make_pair('D', 3));
	m.insert(make_pair('E', 3));
	m.insert(make_pair('F', 3));
	m.insert(make_pair('G', 4));
	m.insert(make_pair('H', 4));
	m.insert(make_pair('I', 4));
	m.insert(make_pair('J', 5));
	m.insert(make_pair('K', 5));
	m.insert(make_pair('L', 5));
	m.insert(make_pair('M', 6));
	m.insert(make_pair('N', 6));
	m.insert(make_pair('O', 6));
	m.insert(make_pair('P', 7));
	m.insert(make_pair('Q', 7));
	m.insert(make_pair('R', 7));
	m.insert(make_pair('S', 7));
	m.insert(make_pair('T', 8));
	m.insert(make_pair('U', 8));
	m.insert(make_pair('V', 8));
	m.insert(make_pair('W', 9));
	m.insert(make_pair('X', 9));
	m.insert(make_pair('Y', 9));
	m.insert(make_pair('Z', 9));
}
开发者ID:mac0314,项目名称:BaekjoonAL,代码行数:28,代码来源:Problem_5622-map.cpp


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