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


C++ hash_map::find方法代码示例

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


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

示例1: Compute

Value VarExpression::Compute(const hash_map<string, Value>& vars) const
{
	if (vars.find(name) == vars.end())
		throw UnknownIdentifierException(name);

	return vars.find(name)->second;
}
开发者ID:stormbreakerbg,项目名称:stormsql,代码行数:7,代码来源:Expression.cpp

示例2: GetSuitableField

Field VarExpression::GetSuitableField(const string& fieldName, const hash_map<string, Field>& v) const
{
	if (v.find(name) == v.end())
		throw UnknownIdentifierException(name);

	Field f = v.find(name)->second;
	return Field(fieldName.c_str(), f.type, f.size);
}
开发者ID:stormbreakerbg,项目名称:stormsql,代码行数:8,代码来源:Expression.cpp

示例3: countPairs

void countPairs(vector<Event*> &events){

  for( vector<Event*>::iterator fst = events.begin();
       fst != events.end(); fst++){
    
    for( vector<Event*>::iterator snd = fst;
         snd != events.end() && snd - fst < THRESHOLD; snd++){

      if( (*fst)->thread != (*snd)->thread ){

        string fString = (*fst)->btString();
        string sString = (*snd)->btString();
      
        bool found = false;

        pthread_rwlock_rdlock( &histoLock );
        if( histo.find( fString ) != histo.end() ){
          
          if( histo[fString].find( sString ) != histo[fString].end() ){
            found = true;
            histo[fString][sString][snd-fst]++;
          }

        }
        pthread_rwlock_unlock( &histoLock );

        if( !found ){

          pthread_rwlock_wrlock( &histoLock );

          if( (histo.find( fString )) == histo.end() ){
            histo.insert(
              std::pair<string,
                        hash_map<string, vector<unsigned long> > >(fString,
                                                                   hash_map<string, vector<unsigned long> >()));
          }

          if( histo[fString].find(sString) == histo[fString].end() ){
            histo[fString].insert(std::pair<string,
                                            vector<unsigned long> >(sString,
                                                                    vector<unsigned long>()));
            for(int i = 0; i < THRESHOLD; i++ ){
              histo[fString][sString].push_back(0);
            }
          } 
          assert(snd - fst < THRESHOLD);
          histo[fString][sString][snd-fst]++;
          pthread_rwlock_unlock( &histoLock );

        }
         
      } 
      
    }
    
  }

}
开发者ID:blucia0a,项目名称:Aviso,代码行数:58,代码来源:computePairHistogram.cpp

示例4: computeIDoms

void computeIDoms(vector<IFR_BasicBlock> &bblist, 
                  hash_map<ADDRINT, set<ADDRINT> > &dom, 
                  hash_map<ADDRINT, ADDRINT> &idom){

  for( vector<IFR_BasicBlock>::iterator bi = bblist.begin();
       bi != bblist.end();
       bi++
     ){

    for( set<ADDRINT>::iterator di = dom[bi->getEntryAddr()].begin();
         di != dom[bi->getEntryAddr()].end();
         di++
       ){
  
      if( *di == bi->getEntryAddr() ){ continue; }  //only strict dominators are considered
      bool iDom = true; 
      for( set<ADDRINT>::iterator odi = dom[bi->getEntryAddr()].begin();
           odi != dom[bi->getEntryAddr()].end();
           odi++
         ){

        if( *odi == bi->getEntryAddr() ){ continue; }  //bi-> is the one whose idom we're looking for
        if( *odi == *di ){ continue; }  //only strict dominators are considered

        /*If any other dominator in bi's dominator set is dominated by di, then
         *di can't be bi's iDom.
         */
        if( dom[ *odi ].find( *di ) != dom[ *odi ].end()){
          iDom = false;
        }

      }

      if( iDom ){
        assert( idom.find(bi->getEntryAddr()) == idom.end() );
        idom.insert( std::pair<ADDRINT, ADDRINT>(bi->getEntryAddr(), *di) );
      } 

    }

    if( idom.find(bi->getEntryAddr()) == idom.end() ){
      /*an immediate dominator of 0 means this node has no immediate dominator*/
      idom.insert( std::pair<ADDRINT, ADDRINT>(bi->getEntryAddr(), 0) );
    }

  }

}
开发者ID:JaonLin,项目名称:PinCFG,代码行数:48,代码来源:IFR_PinDriver.cpp

示例5: calc

int calc(char s[])
{
    len = strlen(s);
    Manacher(s,len);

    sum[0] = s[0];
    for (int i = 1; i < len; i++)
        sum[i] = sum[i-1]*muts+s[i];

    int res = 0;
    uint tmp;
    int nt = 0;
    hash.clear();
    //odd
    for (int i = 0; i < len; i++)
        if (Mp[i*2+2]%2 == 0)
        {
            int pl = Mp[i*2+2]/2;
            if (i+pl < nt || pl == 0)	continue;
            for (int j = i-pl+1; j <= i; j++)
            {
                tmp = gethashcode(j,i);
                if (hash.find(tmp,i-j+1) != -1)	break;
                hash.insert(tmp,i-j+1);
            }
            nt = i+pl;
        }
    res += hash.N;

    nt = 0;
    hash.clear();
    //even
    for (int i = 0; i < len; i++)
        if (Mp[i*2+3] > 1)
        {
            int pl = Mp[i*2+3]/2;
            if (i+pl < nt || pl == 0)	continue;
            for (int j = i-pl+1; j <= i; j++)
            {
                tmp = gethashcode(j,i);
                if (hash.find(tmp,i-j+1) != -1)	break;
                hash.insert(tmp,i-j+1);
            }
            nt = i+pl;
        }
    res += hash.N;
    return res;
}
开发者ID:mzry1992,项目名称:workspace,代码行数:48,代码来源:3948.cpp

示例6: print_tree

  void print_tree(const ast &tree, hash_map<expr*,symbol> &cnames, std::ostream &out){
    hash_map<expr*,symbol>::iterator foo = cnames.find(to_expr(tree.raw()));
    if(foo != cnames.end()){
      symbol nm = foo->second;
      if (is_smt2_quoted_symbol(nm)) {
	out << mk_smt2_quoted_symbol(nm);
      }
      else {
	out << nm;
      }
    }
    else if(op(tree) == And){
      out << "(and";
      int nargs = num_args(tree);
      for(int i = 0; i < nargs; i++){
	out << " ";
	print_tree(arg(tree,i), cnames, out);
      }
      out << ")";
    }
    else if(op(tree) == Interp){
      out << "(interp ";
      print_tree(arg(tree,0), cnames, out);
      out << ")";
    }
    else throw iz3pp_bad_tree();
  }
开发者ID:jackluo923,项目名称:juxta,代码行数:27,代码来源:iz3pp.cpp

示例7: init

	void init(){
		string ff;
		hash_map<int, string> user;
		ifstream fin("in");
		int k = 0;

		while (true){
			if (fin.eof())break;
			fin >> ff;
			vector<string> tmp;
			split(ff, ",", tmp);
			hash_map<string, vector<Node>*>::iterator it = mylog.find(tmp[0]);
			if (it == mylog.end()){
				vector<Node>* newVector = new vector<Node>();
				mylog[tmp[0]] = newVector;
				user[k++] = tmp[0];
			}

			mylog[tmp[0]]->push_back(Node(tmp[0], tmp[1], tmp[2], tmp[3]));
		}
		fin.close();
		hash_map<string, vector<Node>*>::iterator it;
		for (it = mylog.begin(); it != mylog.end(); it++){
			vector<string> v;
			net[it->first] = v;
			for (int i = 0; i < 5; i++){
				int ran = rand() % 9999;
				net[it->first].push_back(user[ran]);
			}
		}
	}
开发者ID:ladfaa,项目名称:CCF,代码行数:31,代码来源:源.cpp

示例8: process

bool process(state* astate, queue<state*>& bfsq)
{
	if(astate->clocks == ten9)
	{
		return print(astate);
	}
	
	for(int i=0; i<9; i++)
	{
		newstate.set(astate);
		newstate.inc(config[i]);
		//cout<<"trying state: "<<newstates[i].getnum()<<", foundsz="<<answers.size()<<endl;

		if(visited.find(newstate.clocks) == visited.end())
		{
			state *ns = new state();
			ns->clocks = newstate.clocks;
			ns->prevop = i+1;
		    ns->prevstate = astate;
			bfsq.push(ns);
			visited[ns->clocks] = true;
			nobj++;
		}
	}
	return true;
}
开发者ID:ragebiswas,项目名称:algorepo,代码行数:26,代码来源:clocks.cpp

示例9: UpdateBest

void UpdateBest(string& str, int& best)
{
	if(f.find(str)!=f.end())
	{
		best=max(best,f[str]);
	}
}
开发者ID:chenyinzhu,项目名称:twilight-poj-solution,代码行数:7,代码来源:11097004_AC_1469MS_1864K.cpp

示例10: GetHatFit

static double GetHatFit( // args same as non CACHE version, see below
    int          x,      // in
    int          y,      // in
    const HatFit hatfit) // in
{
    const double* descbuf = NULL;       // the HAT descriptor
    // for max cache hit rate, x and y should divisible by HAT_SEARCH_RESOL
    CV_DbgAssert(x % HAT_SEARCH_RESOL == 0);
    CV_DbgAssert(y % HAT_SEARCH_RESOL == 0);
    if (TRACE_CACHE)
        ncalls_g++;
    const unsigned key(Key(x, y));
    #pragma omp critical                // prevent OpenMP concurrent access to cache_g
    {
        hash_map<unsigned, VEC>:: const_iterator it(cache_g.find(key));
        if (it != cache_g.end())        // in cache?
        {
            descbuf = Buf(it->second);  // use cached descriptor
            if (TRACE_CACHE)
                nhits_g++;
        }
    }
    if (descbuf == NULL)                // descriptor not in cache?
    {
        const VEC desc(hat_g.Desc_(x, y));
        #pragma omp critical            // prevent OpenMP concurrent access to cache_g
        cache_g[key] = desc;            // remember descriptor for possible re-use
        descbuf = Buf(desc);
    }
    return hatfit(descbuf);
}
开发者ID:GianpaoloR,项目名称:polyphemus,代码行数:31,代码来源:hatdesc.cpp

示例11: merge_recommended_queries

  void query_recommender::merge_recommended_queries(std::multimap<double,std::string,std::less<double> > &related_queries,
      hash_map<const char*,double,hash<const char*>,eqstr> &update)
  {
    hash_map<const char*,double,hash<const char*>,eqstr>::iterator hit;
    std::multimap<double,std::string,std::less<double> >::iterator mit
    = related_queries.begin();
    while(mit!=related_queries.end())
      {
        std::string rquery = (*mit).second;
        if ((hit = update.find(rquery.c_str()))!=update.end())
          {
            (*hit).second = std::min((*mit).first,(*hit).second);
            std::multimap<double,std::string,std::less<double> >::iterator mit2 = mit;
            ++mit;
            related_queries.erase(mit2);
          }
        else ++mit;
      }
    hit = update.begin();
    hash_map<const char*,double,hash<const char*>,eqstr>::iterator chit;
    while(hit!=update.end())
      {
        related_queries.insert(std::pair<double,std::string>((*hit).second,std::string((*hit).first)));
        chit = hit;
        ++hit;
        free_const((*chit).first);
      }

  }
开发者ID:Psycojoker,项目名称:seeks,代码行数:29,代码来源:query_recommender.cpp

示例12: explore

void explore(Lit l, vector<Lit>& stack) {
  if (find(stack.begin(), stack.end(), l) != stack.end()) {
    // Found cycle
    // cerr << "Found cycle from " << l << endl;
    for (vector<Lit>::const_iterator i = find(stack.begin(), stack.end(), l);
         ++i != stack.end(); ) {
      addEquivalence(l, *i);
      addEquivalence(invert(l), invert(*i));
      // cerr << ".. containing " << *i << endl;
    }
    // cerr << "End of cycle" << endl;
  } else if (find(stack.begin(), stack.end(), invert(l)) != stack.end()) {
    // We have not(l) -> l, so l is true
    addEquivalence(normalize(l), TRUE);
    addEquivalence(normalize(invert(l)), FALSE);
    // cerr << "Found known true literal " << l << endl;
  } else if (done.find(l) != done.end()) {
    // Nothing
  } else if (implications.find(l) == implications.end()) {
    // cerr << "Found pure literal " << l << endl;
  } else {
    done.insert(l);
    stack.push_back(l);
    for (size_t i = 0; i < implications[l].size(); ++i) {
      explore(implications[l][i], stack);
    }
    stack.pop_back();
  }
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:29,代码来源:binaryClauseSimplify.C

示例13: normalize

Lit normalize(Lit a) {
  while (true) {
    hash_map<Lit, Lit>::const_iterator i = equivalences.find(a);
    if (i == equivalences.end()) break;
    a = i->second;
  }
  return a;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:8,代码来源:binaryClauseSimplify.C

示例14: ComputeTFIDFWeights

void ComputeTFIDFWeights(string directory,vector<data*>& Y,hash_map<string,indx>& X)
{
	string temp;
	string tempx;
	hash_map<string,indx>::iterator ter;
	std::ofstream ofs(directory+"train.dat");
	std::ofstream ofss(directory+"predict\\test.dat");
	double Num;
	double DeNum;
	for(int i=0;i<Y.size();i++)
	{
		if(Y[i]->label==1)
			temp.append("+1");
		else if(Y[i]->label==-1)
			temp.append("-1");
		else
			temp.append("0");
		tempx.append(" # ");
		for(set<attribute,attribute>::iterator it=Y[i]->features.begin();it!=Y[i]->features.end();it++)
		{
			temp.append(" ");
			if((ter=X.find(it->feature))!=X.end() && ter->second.DF>MIN_DF_FOR_FEATURE)
			{
			temp.append(IntToString(it->index));
			temp.append(":");
			Num=(double)Y.size();
			DeNum=(ter=X.find(it->feature))==X.end()?0.0:(double)ter->second.DF;
			double IDF=log(Num/DeNum);
			temp.append(DoubleToString(it->TF*IDF));
			}
			tempx.append(it->feature);
			tempx.append(",");
		}
		if(*(tempx.end()-1)==',')
		tempx.erase(tempx.end()-1);
		if(Y[i]->label==0)
		ofss<<temp<<tempx<<"\n";
		else
		ofs<<temp<<tempx<<"\n";
		temp.clear();
		tempx.clear();

	}
	ofs.close();
	ofss.close();
}
开发者ID:OrlandoChen0308,项目名称:karana,代码行数:46,代码来源:main.cpp

示例15: addColor

int addColor(const string & s) {
  hash_map<string, int>::iterator found = colorMap.find(s);
  if (found == colorMap.end()) {
    colorMap[s] = totalColors;
    return totalColors++;
  } else {
    return found->second;
  }
}
开发者ID:pavel-zeman,项目名称:CodeJam,代码行数:9,代码来源:B2.cpp


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