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


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

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


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

示例1:

string		square_anagram(string s1, string s2)
{
    int			len = s1.length(), i;
    string		ret;

    for (i = 0; i < len; i++)
        if ((s1[i] >= 'A' && s1[i] <= 'Z'))
            break;
    if (i == len)
    {
        if (squares.find(s1) != squares.end() && squares.find(s2) != squares.end())
        {
            if (s1 > s2)
                return s1;
            return s2;
        }
        return "";
    }
    for (char c = '9'; c >= (i == 0 ? '1' : '0'); c--)
    {
        char save = s1[i];
        if (used.find(c) != used.end())
            continue;
        replace_all(s1, s2, s1[i], c);
        used.insert(c);
        if ((ret = square_anagram(s1, s2)) != "")
            return ret;
        used.erase(c);
        replace_all(s1, s2, c, save);
    }
    return "";
}
开发者ID:kart,项目名称:projecteuler,代码行数:32,代码来源:PE098.cpp

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

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

示例4: getNB

void getNB(HashGraph* G, int v, int distance, hash_set<int>& result, vector<bool>& mark)
{
	assert(distance==1 || distance==2);
	
	EdgeMap* p_neighbors=G->getNeighbors(v);
	EdgeMap::iterator pnb;
    for (pnb=p_neighbors->begin(); pnb!=p_neighbors->end(); pnb++)
    {
            UINT w=pnb->first;
            if(!mark[w])
            	result.insert(w);
    }
	
	if(distance==1)
		return;
	
	hash_set<int>::iterator p;
	vector<int> temp;
	for(p=result.begin(); p!=result.end(); p++)
		temp.push_back(*p);
	int imnb_size=result.size();
	//result.clear();
	for(int i=0; i<imnb_size; i++)
	{
		p_neighbors=G->getNeighbors(temp[i]);
		for (pnb=p_neighbors->begin(); pnb!=p_neighbors->end(); pnb++)
		{
			UINT w=pnb->first;
			if(!mark[w]) 
				result.insert(w); //automatically handel duplication.
		}
	}
	for(int i=0; i<imnb_size; i++)
		result.erase(temp[i]);
}
开发者ID:renqHIT,项目名称:Tale,代码行数:35,代码来源:query.cpp

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

示例6: print

void print(hash_set &S) {
  iterator_t p = S.begin();
  while(p!=S.end()) {
    cout << S.retrieve(p) << " ";
    p = S.next(p);
  }
  cout << endl;
}
开发者ID:Malows,项目名称:aedcode,代码行数:8,代码来源:tryhset2.cpp

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

示例8: checkgradRowSparse

void LinearSNNClassifier::checkgradRowSparse(const vector<Example>& examples, mat& Wd, const mat& gradWd, const string& mark, int iter,
        const hash_set<int>& sparseRowIndexes, const mat& ft) {
    //Random randWdRowcheck = new Random(iter + "Row".hashCode() + hash));
    int charseed = mark.length();
    for (int i = 0; i < mark.length(); i++) {
        charseed = (int) (mark[i]) * 5 + charseed;
    }
    srand(iter + charseed);
    std::vector<int> idRows, idCols;
    idRows.clear();
    idCols.clear();
    if (sparseRowIndexes.empty()) {
        for (int i = 0; i < Wd.n_rows; ++i)
            idRows.push_back(i);
    } else {
        hash_set<int>::iterator it;
        for (it = sparseRowIndexes.begin(); it != sparseRowIndexes.end(); ++it)
            idRows.push_back(*it);
    }

    for (int idx = 0; idx < Wd.n_cols; idx++)
        idCols.push_back(idx);

    random_shuffle(idRows.begin(), idRows.end());
    random_shuffle(idCols.begin(), idCols.end());

    int check_i = idRows[0], check_j = idCols[0];

    double orginValue = Wd(check_i, check_j);

    Wd(check_i, check_j) = orginValue + 0.001;
    double lossAdd = 0.0;
    for (int i = 0; i < examples.size(); i++) {
        Example oneExam = examples[i];
        lossAdd += computeScore(oneExam);
    }

    Wd(check_i, check_j) = orginValue - 0.001;
    double lossPlus = 0.0;
    for (int i = 0; i < examples.size(); i++) {
        Example oneExam = examples[i];
        lossPlus += computeScore(oneExam);
    }

    double mockGrad = (lossAdd - lossPlus) / (0.002 * ft(check_i, check_j));
    mockGrad = mockGrad / examples.size();
    double computeGrad = gradWd(check_i, check_j);

    printf("Iteration %d, Checking gradient for %s[%d][%d]:\t", iter, mark.c_str(), check_i, check_j);
    printf("mock grad = %.18f, computed grad = %.18f\n", mockGrad, computeGrad);

    Wd(check_i, check_j) = orginValue;
}
开发者ID:SUTDNLP,项目名称:NNTransitionParser,代码行数:53,代码来源:LinearSNNClassifier.cpp

示例9: main

int main(){
    
    for(int i=0;i<100;i++){
        tab.insert(2*i + 1);
    }
    for(hash_set<int>::iterator iter = tab.begin();
            iter!=tab.end();
            iter++){
        cout<<(*iter)<<" ";
    }
    cout<<endl;

	return 0;
}
开发者ID:ZhouWeikuan,项目名称:zoj,代码行数:14,代码来源:hash_set.cpp

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

示例11: mapNodes

void Query::mapNodes(vector<Neighborhood>& nbs, HashGraph* Gdb, OrthologInfoList* pOrthinfolist_db, hash_set<int>& Sq, hash_set<int>& Sdb, GraphMatch* gm, Queue& Q, hash_set<int>& nodesInQ, vector<bool>& mark, vector<bool>& dbmark)
{
	hash_set<int>::iterator p;
	hash_map< int, vector<int>, inthash > lmap_q, lmap_db;
	for(p=Sq.begin(); p!=Sq.end(); p++)
	{
		for(unsigned int i=0; i<(*pOrthinfolist)[*p].size(); i++)
		{
			if((*pOrthinfolist)[*p][i]==0)
				continue;
			lmap_q[(*pOrthinfolist)[*p][i]].push_back(*p);
		}
	}
	
	for(p=Sdb.begin(); p!=Sdb.end(); p++)
	{
		if(!dbmark[*p])
		{
			for(unsigned int i=0; i<(*pOrthinfolist_db)[*p].size(); i++)
			{
				if((*pOrthinfolist_db)[*p][i]==0)
					continue;
				lmap_db[(*pOrthinfolist_db)[*p][i]].push_back(*p);
			}
		}
	}
		
	hash_map<int, vector<int>, inthash>::iterator iter, iter2;
	for(iter=lmap_q.begin(); iter!=lmap_q.end(); iter++)
	{
		iter2=lmap_db.find(iter->first);
		if(iter2==lmap_db.end())
			continue;
		else
			mapNodesHelp(nbs, Gdb, pOrthinfolist_db, iter->second, iter2->second, gm, Q, nodesInQ, mark, dbmark);	
	}
}
开发者ID:renqHIT,项目名称:Tale,代码行数:37,代码来源:query.cpp

示例12: trim_entropy_filter

int trim_entropy_filter(vector<string>* keep_words, hash_set<string>& cad_words_set, WordInfoMap& wordinfo_map)
{
    keep_words->reserve(cad_words_set.size());
    for (hash_set<string>::iterator it = cad_words_set.begin(); it != cad_words_set.end(); ++it) {
        WordInfoMap::iterator it_map = wordinfo_map.find(*it);
        if (it_map == wordinfo_map.end()) {
            fprintf(stderr, "WARNING, word[%s] in cad_word, not in word_info", it->c_str());
            continue;
        }
        if (it_map->first.size() <= WORD_LEN - 4 && it_map->second.calc_is_keep()) {
            keep_words->push_back(*it);
        }
    }
    return 0;
}
开发者ID:HelloWorldCAT,项目名称:yaha,代码行数:15,代码来源:segword.cpp

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

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

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


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