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


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

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


在下文中一共展示了hash_set::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: PE098

int PE098()
{
    ifstream	fs;
    string		line;
    int			count = 0;

    fs.open("C:\\Users\\Karthik\\words2.txt", ifstream::in);
    getline(fs, line);
    istringstream ss(line);

    while (ss)
    {
        string		word, sig;
        if (!getline(ss, word, ','))
            break;
        sig = string_signature(word);
        if (anagrams.find(sig) != anagrams.end())
            anagrams[sig].push_back(word);
        else
        {
            vector<string> v(1, word);
            anagrams[sig] = v;
        }
    }
    for (long long i = 1; i * i <= MAX; i++)
        squares.insert(convert2string(i * i));
    for (map<string, vector<string> >::iterator it = anagrams.begin(); it != anagrams.end(); it++)
    {
        vector<string>		v = (*it).second;
        string				ret;

        if (v.size() == 2 && v[0].length() >= 4)
        {
            used.clear();
            if ("" != (ret = square_anagram(v[0], v[1])))
                cout << v[0] << "; " << v[1] << " == > " << ret << endl;
        }
    }
    fs.close();
    return 0;
}
开发者ID:kart,项目名称:projecteuler,代码行数:41,代码来源:PE098.cpp

示例3: main

int main(int argc, char** argv) {
  SatProblem cnf;
  cnf.parse(stdin);

  size_t count = 0;

  while (count < 100) {
    cerr << "count = " << count << endl;

    equivalences.clear();
    implications.clear();
    for (size_t i = 0; i < cnf.clauses.size(); ++i) {
      if (cnf.clauses[i].size() == 0) {
        abort();
      } else if (cnf.clauses[i].size() == 1) {
        addEquivalence(cnf.clauses[i][0], TRUE);
        addEquivalence(invert(cnf.clauses[i][0]), FALSE);
      } else if (cnf.clauses[i].size() == 2) {
        implications[invert(cnf.clauses[i][0])].push_back(cnf.clauses[i][1]);
        implications[invert(cnf.clauses[i][1])].push_back(cnf.clauses[i][0]);
      } else {
        // Do nothing
      }
    }

    done.clear();
    for (hash_map<Lit, vector<Lit> >::const_iterator i = implications.begin();
         i != implications.end(); ++i) {
      vector<Lit> stack;
      // cerr << "Exploring " << i->first << endl;
      explore(i->first, stack);
    }

    vector<Clause> oldClauses = cnf.clauses;
    cnf.clauses.clear();

    for (size_t i = 0; i < oldClauses.size(); ++i) {
      Clause cl = oldClauses[i];
      for (size_t j = 0; j < cl.size(); ++j) {
        cl[j] = normalize(cl[j]);
      }
      cnf.addClause(cl);
    }

    for (size_t i = 0; i < cnf.interfaceVariables.size(); ++i) {
      InterfaceVariable& iv = cnf.interfaceVariables[i];
      for (size_t j = 0; j < iv.second.size(); ++j) {
        Lit oldLit = iv.second[j];
        Lit newLit = normalize(oldLit);
        iv.second[j] = newLit;
      }
    }

    if (equivalences.empty()) break; // No changes

    ++count;
  }

  cnf.unparse(stdout);

  return 0;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:62,代码来源:binaryClauseSimplify.C


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