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


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

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


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

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

示例2: updateHelper

static void updateHelper (SLE::ref entry,
    hash_set< uint256 >& seen,
    OrderBookDB::IssueToOrderBook& destMap,
    OrderBookDB::IssueToOrderBook& sourceMap,
    hash_set< Issue >& XDVBooks,
    int& books)
{
    if (entry->getType () == ltDIR_NODE &&
        entry->isFieldPresent (sfExchangeRate) &&
        entry->getFieldH256 (sfRootIndex) == entry->getIndex())
    {
        Book book;
        book.in.currency.copyFrom (entry->getFieldH160 (sfTakerPaysCurrency));
        book.in.account.copyFrom (entry->getFieldH160 (sfTakerPaysIssuer));
        book.out.account.copyFrom (entry->getFieldH160 (sfTakerGetsIssuer));
        book.out.currency.copyFrom (entry->getFieldH160 (sfTakerGetsCurrency));

        uint256 index = getBookBase (book);
        if (seen.insert (index).second)
        {
            auto orderBook = std::make_shared<OrderBook> (index, book);
            sourceMap[book.in].push_back (orderBook);
            destMap[book.out].push_back (orderBook);
            if (isXDV(book.out))
                XDVBooks.insert(book.in);
            ++books;
        }
    }
}
开发者ID:xdv,项目名称:divvyd,代码行数:29,代码来源:OrderBookDB.cpp

示例3: main

int main(int iArgc, char* apcArgv[])
{
	assert(iArgc >= 3);

	{
		_getcwd(g_acBuffer, 2048);
		_chdir(apcArgv[2]);
		_getcwd(g_acSave, 2048);
		_chdir(g_acBuffer);
		_chdir(apcArgv[1]);
		_getcwd(g_acLoad, 2048);

		char acBuffer[2048];
		_getcwd(acBuffer, 2048);
		printf_s("Working directory is: %s\n", acBuffer);
	}

	tm_sep.insert('*');
	tm_sep.insert(',');
	tm_sep.insert(' ');
	tm_sep.insert('\t');

	func_Type["return"] = FUNC_RETURN;
	func_Type["param"] = FUNC_PARAM;

	spec_Type["define:"] = SPEC_DEFINE;
	spec_Type["enum:"] = SPEC_ENUM;
	spec_Type["passthru:"] = SPEC_PASSTHRU;
	spec_Type["passend:"] = SPEC_PASSTHRU;

	trans["class"] = "class1";

	g_kTypeMap["LPCSTR"] = "LPCSTR";

	vector<const char*> kNameList;

	kNameList.clear();
	kNameList.push_back("enum.spec");
	kNameList.push_back("enumext.spec");
	kNameList.push_back("gl.spec");
	Generate("gl", kNameList);
	kNameList.clear();
	kNameList.push_back("glxenum.spec");
	kNameList.push_back("glxenumext.spec");
	kNameList.push_back("glxext.spec");
	kNameList.push_back("glx.spec");
	Generate("glX", kNameList);
	kNameList.clear();
	kNameList.push_back("wglenum.spec");
	kNameList.push_back("wglenumext.spec");
	kNameList.push_back("wgl.spec");
	kNameList.push_back("wglext.spec");
	Generate("wgl", kNameList);
	
	return 0;
}
开发者ID:Napoleon314,项目名称:Venus2D,代码行数:56,代码来源:OpenGLSpecLoader.cpp

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

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

示例6:

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

示例7: ReadNum

void ReadNum(ifstream &input,hash_set<long> &myset)
{
	long num;
	while(!input.fail()){
		input>>num;
		myset.insert(num);
	}
}
开发者ID:chungjin,项目名称:Algorithms-Design-and-Analysis-Part-1,代码行数:8,代码来源:1.cpp

示例8: value

 static_string () {
     if (!s_static_string_set) {
         s_static_string_set = VNEW hash_set<string>;
     }
     string value ( "" );
     const string &v = s_static_string_set->insert ( value );
     m_str = v.c_str();
 }
开发者ID:vengine,项目名称:xhnSTL,代码行数:8,代码来源:xhn_static_string.hpp

示例9: ComputeNodesReachableFrom

/// ComputeNodesReacahbleFrom - Compute the set of nodes in the specified
/// inverse graph that are reachable from N.  This is a simple depth first
/// search.
///
static void ComputeNodesReachableFrom(DSNode *N,
                            std::set<std::pair<DSNode*,DSNode*> > &InverseGraph,
                                      hash_set<const DSNode*> &Reachable) {
  if (!Reachable.insert(N).second) return;  // Already visited!
  
  std::set<std::pair<DSNode*,DSNode*> >::iterator I = 
    InverseGraph.lower_bound(std::make_pair(N, (DSNode*)0));
  for (; I != InverseGraph.end() && I->first == N; ++I)
    ComputeNodesReachableFrom(I->second, InverseGraph, Reachable);
}
开发者ID:brills,项目名称:pfpa,代码行数:14,代码来源:StructureFieldVisitor.cpp

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

示例11: markReachableFunctionsExternallyAccessible

void TDDataStructures::markReachableFunctionsExternallyAccessible(DSNode *N,
                                                   hash_set<DSNode*> &Visited) {
  if (!N || Visited.count(N)) return;
  Visited.insert(N);

  for (unsigned i = 0, e = N->getNumLinks(); i != e; ++i) {
    DSNodeHandle &NH = N->getLink(i);
    if (DSNode *NN = NH.getNode()) {
      std::vector<const Function*> Functions;
      NN->addFullFunctionList(Functions);
      ArgsRemainIncomplete.insert(Functions.begin(), Functions.end());
      markReachableFunctionsExternallyAccessible(NN, Visited);
    }
  }
}
开发者ID:brills,项目名称:pfpa,代码行数:15,代码来源:TopDownClosure.cpp

示例12: value

    static_string ( const char *str ) {
		euint32 hash_value = calc_hashnr ( str, _strlen ( str ) );
		xhn::hash_set<string>::bucket& b = s_static_string_set.get_bucket(hash_value);
		{
			SpinLock::Instance inst = b.m_lock.Lock();
			xhn::list<xhn::string>::iterator iter = b.begin();
			xhn::list<xhn::string>::iterator end = b.begin();
			for (; iter != end; iter++) {
				if (*iter == str) {
					m_str = (*iter).c_str();
					return;
				}
			}
		}
		string value ( str );
		const string &v = s_static_string_set.insert ( value );
		m_str = v.c_str();
    }
开发者ID:vengine,项目名称:XGC,代码行数:18,代码来源:xhn_static_string.hpp

示例13: ComputePostOrder

void TDDataStructures::ComputePostOrder(const Function* F,
                                        hash_set<DSGraph*> &Visited,
                                        std::vector<DSGraph*> &PostOrder) {
  if (F->isDeclaration()) return;
  DSGraph* G = getOrFetchDSGraph(F);
  if (Visited.count(G)) return;
  Visited.insert(G);

  // Recursively traverse all of the callee graphs.
  for (DSGraph::fc_iterator CI = G->fc_begin(), CE = G->fc_end(); CI != CE; ++CI){
    Instruction *CallI = CI->getCallSite().getInstruction();
    for (calleeTy::iterator I = callee.begin(CallI),
           E = callee.end(CallI); I != E; ++I)
      ComputePostOrder(*I, Visited, PostOrder);
  }

  PostOrder.push_back(G);
}
开发者ID:brills,项目名称:pfpa,代码行数:18,代码来源:TopDownClosure.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::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。