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


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

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


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

示例1: fun

int fun(){
    ut i, t;
    Node one = {0}, next;
    tab.clear();
    for(i=0;i<SIZ;i++){
        cin>>t;
        if(t){
            one.m |= (1<<i);
            one.s++;
        } 
    }
    priority_queue<Node, vector<Node>, Node::cmp> q;
    q.push(one);
    while(!q.empty()){
        one=q.top(); q.pop();
        if(one.m == 0)
            break;
        for(i=0;i<SIZ;i++){
            next = one;
            next.o |= (1<<i);
            set(next,i);
            if(tab.find(next.m) == tab.end()){
                q.push(next);
                tab.insert(next.m);
            }
        }
    }
    output(one.o);
    return 0;
}
开发者ID:ZhouWeikuan,项目名称:zoj,代码行数:30,代码来源:1354.cpp

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

示例3: calculaCertos

// Alínea D
int Aposta::calculaCertos(const hash_set<int> &sorteio) const{
	hash_set<int>::iterator it;
	int c =0;
	for (it=numeros.begin(); it!=numeros.end(); it++)
		if (sorteio.find(*it)!=sorteio.end()) c++;
	return c;
}
开发者ID:andrefreitas,项目名称:feup-aeda,代码行数:8,代码来源:Aposta.cpp

示例4: GetCount

int GetCount(int a, int b) {
    int qres = a + b + 1, n = 1;
    while (primes.find(qres) != primes.end()) {
        n += 1;
        qres = n*n + n*a + b;
    }
    return n;
}
开发者ID:andreytim,项目名称:contests,代码行数:8,代码来源:solve.cpp

示例5: GetTmWorld

void GetTmWorld(const char* pcBuffer, char* pcLeft, char* pcRight)
{
	while(*pcBuffer != '\0')
	{
		if(tm_sep.find(*pcBuffer) == tm_sep.end() || ((*pcBuffer) == ' '))
		{
			*pcLeft = *pcBuffer;
			++pcLeft;
			++pcBuffer;
		}
		else
		{
			break;
		}
	}
	*pcLeft = '\0';

	while(tm_sep.find(*pcBuffer) != tm_sep.end())
	{
		++pcBuffer;
	}

	while(*pcBuffer != '\0')
	{
		if(tm_sep.find(*pcBuffer) == tm_sep.end() || ((*pcBuffer) == ' ') || ((*pcBuffer) == '*'))
		{
			*pcRight = *pcBuffer;
			++pcRight;
			++pcBuffer;
		}
		else
		{
			break;
		}
	}
	*pcRight = '\0';
}
开发者ID:Napoleon314,项目名称:Venus2D,代码行数:37,代码来源:OpenGLSpecLoader.cpp

示例6: gen_trim_entropy

int gen_trim_entropy(hash_set<string>& cad_words_set, WordInfoMap* wordinfo_map)
{
    for (WordInfoMap::iterator it = wordinfo_map->begin(); it != wordinfo_map->end(); ++it) {
        string& word = const_cast<string&>(it->first);
        uint32_t freq = it->second.freq;
        if (word.length() >= 3 * 2) {//三个汉字,abc,插入词bc's left trim a,插入词ab's right trim c
            string left_trim(word.begin(), word.begin() + 2);
            string right_part(word.begin() + 2, word.end());
            if (cad_words_set.find(right_part) != cad_words_set.end()) {
                WordInfoMap::iterator it_r = wordinfo_map->find(right_part);
                if (it_r == wordinfo_map->end()) {
                    fprintf(stderr, "WARNING, word[%s] in cad word, not in word_info", right_part.c_str());
                    continue;
                }
                it_r->second.left_trim[left_trim] += freq;
#ifdef DEBUG
                fprintf(stderr, "DEBUG, word[%s],left_trim[%s]\n", word.c_str(), left_trim.c_str());
#endif
            }
            string right_trim(word.end() - 2, word.end());
            string left_part(word.begin(), word.end() - 2);
            if (cad_words_set.find(left_part) != cad_words_set.end()) {
                WordInfoMap::iterator it_l = wordinfo_map->find(left_part);
                if (it_l == wordinfo_map->end()) {
                    fprintf(stderr, "WARNING, word[%s] in cad_word, not in word_info", left_part.c_str());
                    continue;
                }
                it_l->second.right_trim[right_trim] += freq;
#ifdef DEBUG
                fprintf(stderr, "DEBUG, word[%s],right_trim[%s]\n", word.c_str(), right_trim.c_str());
#endif
            }
        }
    }
    return 0;
}
开发者ID:HelloWorldCAT,项目名称:yaha,代码行数:36,代码来源:segword.cpp

示例7: solve

void solve()
{
    int op,x;
    for( f>>N; N; --N )
    {
        f>>op>>x;
        switch( op )
        {
        case 1 :
            H.insert(x);
            break;
        case 2 :
            H.erase(x);
            break;
        case 3 :
            g<< ( H.find(x)!=H.end() ) <<"\n";
        }
    }
}
开发者ID:george-popoiu,项目名称:infoarena_campion,代码行数:19,代码来源:hash_set.cpp

示例8: containsArrayOps

bool containsArrayOps(const ASTNode& n, hash_set<int> & visited)
{
        if (n.GetIndexWidth() > 0)
            return true;

        if (n.Degree() ==0)
            return false;

        if (visited.find(n.GetNodeNum()) != visited.end())
            return false;

        visited.insert(n.GetNodeNum());

	for (int i =0; i < n.Degree();i++)
		if (containsArrayOps(n[i],visited))
			return true;

	return false;
}
开发者ID:chubbymaggie,项目名称:Tac-Symbolic-Executor,代码行数:19,代码来源:ASTmisc.cpp

示例9: numberOfReadsLessThan

// counts the number of reads. Shortcut when we get to the limit.
void numberOfReadsLessThan(const ASTNode& n, hash_set<int>& visited, int& soFar,
                           const int limit)
{
  if (n.isAtom())
    return;

  if (visited.find(n.GetNodeNum()) != visited.end())
    return;

  if (n.GetKind() == READ)
    soFar++;

  if (soFar > limit)
    return;

  visited.insert(n.GetNodeNum());

  for (size_t i = 0; i < n.Degree(); i++)
    numberOfReadsLessThan(n[i], visited, soFar, limit);
}
开发者ID:cambridgehackers,项目名称:stp,代码行数:21,代码来源:ASTmisc.cpp

示例10: support

 void support(const ast &t, std::set<std::string> &res, hash_set<ast> &memo){
     if(memo.find(t) != memo.end()) return;
     memo.insert(t);
 
     int nargs = num_args(t);
     for(int i = 0; i < nargs; i++)
         support(arg(t,i),res,memo);
 
     switch(op(t)){
     case Uninterpreted:
         if(nargs == 0 || !is_tree) {
             std::string name = string_of_symbol(sym(t));
             res.insert(name);
         }
         break;
     case Forall:
     case Exists:
         support(get_quantifier_body(t),res,memo);
         break;
     default:;
     }
 }
开发者ID:greatmazinger,项目名称:z3,代码行数:22,代码来源:iz3checker.cpp

示例11: terminated

/*!	\brief Returns lists of applications to be asked to quit on shutdown.

	\param userApps List of RosterAppInfos identifying the user applications.
		   Those will be ask to quit first.
	\param systemApps List of RosterAppInfos identifying the system applications
		   (like Tracker and Deskbar), which will be asked to quit after the
		   user applications are gone.
	\param vitalSystemApps A set of team_ids identifying teams that must not
		   be terminated (app server and registrar).
	\return \c B_OK, if everything went fine, another error code otherwise.
*/
status_t
TRoster::GetShutdownApps(AppInfoList& userApps, AppInfoList& systemApps,
	AppInfoList& backgroundApps, hash_set<team_id>& vitalSystemApps)
{
	BAutolock _(fLock);

	status_t error = B_OK;

	// get the vital system apps:
	// * ourself
	// * kernel team
	// * app server
	// * debug server

	// ourself
	vitalSystemApps.insert(be_app->Team());

	// kernel team
	team_info teamInfo;
	if (get_team_info(B_SYSTEM_TEAM, &teamInfo) == B_OK)
		vitalSystemApps.insert(teamInfo.team);

	// app server
	RosterAppInfo* info
		= fRegisteredApps.InfoFor("application/x-vnd.haiku-app_server");
	if (info != NULL)
		vitalSystemApps.insert(info->team);

	// debug server
	info = fRegisteredApps.InfoFor("application/x-vnd.haiku-debug_server");
	if (info != NULL)
		vitalSystemApps.insert(info->team);

	// populate the other groups
	for (AppInfoList::Iterator it(fRegisteredApps.It());
			RosterAppInfo* info = *it; ++it) {
		if (vitalSystemApps.find(info->team) == vitalSystemApps.end()) {
			RosterAppInfo* clonedInfo = info->Clone();
			if (clonedInfo) {
				if (_IsSystemApp(info)) {
					if (!systemApps.AddInfo(clonedInfo))
						error = B_NO_MEMORY;
				} else if (info->flags & B_BACKGROUND_APP) {
					if (!backgroundApps.AddInfo(clonedInfo))
						error = B_NO_MEMORY;
				} else {
					if (!userApps.AddInfo(clonedInfo))
						error = B_NO_MEMORY;
				}

				if (error != B_OK)
					delete clonedInfo;
			} else
				error = B_NO_MEMORY;
		}

		if (error != B_OK)
			break;
	}

	// Special case, we add the input server to vital apps here so it is
	// not excluded in the lists above
	info = fRegisteredApps.InfoFor("application/x-vnd.Be-input_server");
	if (info != NULL)
		vitalSystemApps.insert(info->team);

	// clean up on error
	if (error != B_OK) {
		userApps.MakeEmpty(true);
		systemApps.MakeEmpty(true);
	}

	return error;
}
开发者ID:looncraz,项目名称:haiku,代码行数:85,代码来源:TRoster.cpp

示例12: mapNodesHelp

void Query::mapNodesHelp(vector<Neighborhood>& nbs, HashGraph* Gdb, OrthologInfoList* pOrthinfolist_db, vector<int>& Vq, vector<int>& Vdb, GraphMatch* gm, Queue& Q, hash_set<int>& nodesInQ, vector<bool>& mark, vector<bool>& dbmark)
{
	vector<Neighborhood> dbnbh;
	bool* qvisit=new bool[Vq.size()];
	bool* dbvisit=new bool[Vdb.size()];
	for(unsigned int j=0; j<Vdb.size(); j++)
	{
		dbvisit[j]=false;
		Neighborhood nbh;
		nbh.degree=Gdb->degree(Vdb[j]);
		
		getNeighborhood(Gdb, (*pOrthinfolist_db), Vdb[j], nbh);
		dbnbh.push_back(nbh);
	}
	vector<MappingIndex> mcand;
	for(unsigned int i=0; i<Vq.size(); i++)
	{
		qvisit[i]=false;
		Neighborhood& nbh=nbs[Vq[i]];
		for(unsigned int j=0; j<Vdb.size(); j++)
		{
			MappingIndex m;
			m.indexv=i;
			m.indexw=j;
			if( getScore(nbh, dbnbh[j], m.score) )
				mcand.push_back(m);
		}
	}
	
	std::sort(mcand.begin(), mcand.end(), orderMappingIndexByScore);
	
	for(unsigned int i=0; i<mcand.size(); i++)
	{
		int vi=mcand[i].indexv;
		int wi=mcand[i].indexw;
		float score=mcand[i].score;
		if(!qvisit[vi] && !dbvisit[wi])
		{
			NodeMapping nm;
			nm.source=Vq[vi];
			nm.target=Vdb[wi];
				
			if(nodesInQ.find(Vq[vi])==nodesInQ.end())//Vq[vi] has no mapping in Q) 
			{
				qvisit[vi]=true;
				dbvisit[wi]=true;
				Q.insert(nm);
				nodesInQ.insert(nm.source);
				dbmark[nm.target]=true;
			}else
			{
				//find the mapping in Q
				Queue::iterator p;
				for(p=Q.begin(); p!=Q.end(); p++)
					if(p->source==Vq[vi])
						break;
				if( score < p->score )
				{
					qvisit[vi]=true;
					dbvisit[wi]=true;
					dbmark[p->target]=false;
					Q.erase(p);//edge tm= remove the mapping of m.source from Q 
					Q.insert(nm);
					//nodesInQ.insert(nm.source);
					dbmark[nm.target]=true;
				}else
				{
					qvisit[vi]=true;
				}
			}			
		}
	}
	
	delete [] dbvisit;
	delete [] qvisit;
}
开发者ID:renqHIT,项目名称:Tale,代码行数:76,代码来源:query.cpp

示例13: contains

bool contains(hash_set<long>&myset, long target)
{
	hash_set<long>::iterator iter = myset.find(target);
	if(iter!=myset.end()) return true;
	else		      return false;
}
开发者ID:chungjin,项目名称:Algorithms-Design-and-Analysis-Part-1,代码行数:6,代码来源:1.cpp


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