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


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

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


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

示例1: unweighted

void Graph::unweighted( const string & startName )
{
    clearAll( );

    vmap::iterator itr = vertexMap.find( startName );

    if( itr == vertexMap.end( ) )
    {
        cout << startName << " is not a vertex in this graph" << endl;
        return;
    }

    Vertex *start = (*itr).second;
    list<Vertex *> q;
    q.push_back( start ); start->dist = 0;

    while( !q.empty( ) )
    {
        Vertex *v = q.front( );	q.pop_front( );

        for( int i = 0; i < v->adj.size( ); i++ )
        {
            Vertex *w = v->adj[ i ];
            if( w->dist == INFINITY )
            {
                w->dist = v->dist + 1;
                w->path = v;
                q.push_back( w );
            }
        }
    }
}
开发者ID:piaoyimq,项目名称:CppSpace,代码行数:32,代码来源:Graph1.cpp

示例2: getVertex

Vertex* WGraph::getVertex (vdata v) {
  it = vertexMap.find (v);

  if (it == vertexMap.end())
    return addVertex (v);

  return it->second;
}
开发者ID:Azizou,项目名称:UVa-online-judge,代码行数:8,代码来源:10801.cpp

示例3: getVertex

Vertex* Graph::getVertex (vdata v)
{
	vmap::iterator it = vertexMap.find (v);
	
	if (it == vertexMap.end()) {
		return addVertex (v);
	}
	
	return (*it).second;
}
开发者ID:Azizou,项目名称:UVa-online-judge,代码行数:10,代码来源:10608.cpp

示例4: getVertex

Vertex* BinaryTree::getVertex (int v)
{
	vmap::iterator it = vertexMap.find (v);
	
	if (it == vertexMap.end()) {
		return addVertex (v);
	}
	
	return (*it).second;
}
开发者ID:Azizou,项目名称:UVa-online-judge,代码行数:10,代码来源:122.cpp

示例5: getVertex

Vertex* Graph::getVertex(const string& s){

	vmap::const_iterator it = vertexMap.find(s);
	if(it == vertexMap.end()){
		Vertex* v = new Vertex(s);
		vertexMap[s] = v;
		return v;
	}

	return (*it).second;
}
开发者ID:keshavnandan,项目名称:Hackerrank,代码行数:11,代码来源:dynamicGraph.cpp

示例6: prim

long long Graph::prim(const string& s){
	vmap::const_iterator itr = vertexMap.find(s);
	if(itr == vertexMap.end())
		cerr<<"Source vertex not found"<<endl;

	clearAll();
	int n = vertexMap.size() - 1;
	Vertex *p = itr->second;
	vector<Vertex*> Q;
//	priority_queue<Vertex*, vector<Vertex*>, Compare> Q;
	p->dist = 0;
	for(vmap::const_iterator it = vertexMap.begin(); it != vertexMap.end(); it++)
	Q.push_back(it->second);
	long long cost = 0;

	while(!Q.empty()){

		make_heap(Q.begin(), Q.end(), Compare());
		Vertex *u = Q.front();
		u->done = true;
		pop_heap(Q.begin(), Q.end(), Compare());
		Q.pop_back();
		for(vector<Edge>::const_iterator it = u->adj.begin(); it != u->adj.end(); it++){
			Vertex *v = it->dest;
			if(!v->done && v->dist > it->cost){
				v->dist = it->cost;
				v->prev = u;
//				cout<<"cost of "<<v->name<<" is updated to "<<v->dist<<endl;
			}
		}

	}

	for(vmap::const_iterator it = vertexMap.begin(); it != vertexMap.end(); it++){
	 	cost+=it->second->dist;
	}

	return cost;
}
开发者ID:keshavnandan,项目名称:Hackerrank,代码行数:39,代码来源:dynamicGraph.cpp

示例7: Vertex

// If vertexName is not present, add it to vertexMap
// In either case, return the Vertex
Vertex * Graph::getVertex( const string & vertexName )
{
    vmap::iterator itr = vertexMap.find( vertexName );

    if( itr == vertexMap.end( ) )
    {
        Vertex *newv = new Vertex( vertexName );
        allVertices.push_back( newv );
        vertexMap.insert( vpair( vertexName, newv ) );
        return newv;
    }
    return (*itr).second;
}
开发者ID:piaoyimq,项目名称:CppSpace,代码行数:15,代码来源:Graph1.cpp

示例8: addvertex

void graph::addvertex(const string &name)
{
	vmap::iterator itr=work.begin();
	itr=work.find(name);
	if(itr==work.end())
	{
		vertex *v;
		v= new vertex(name);
		work[name]=v;
		return;
	}
	cout<<"\nVertex already exists!";
}
开发者ID:jindal25,项目名称:Coding4cpp,代码行数:13,代码来源:graph_dictionary.cpp

示例9: printPath

void Graph::printPath( const string & destName ) const
{
    vmap::const_iterator itr = vertexMap.find( destName );

    if( itr == vertexMap.end( ) )
    {
        cout << "Destination vertex not found" << endl;
        return;
    }

    const Vertex & w = *(*itr).second;
    if( w.dist == INFINITY )
        cout << destName << " is unreachable";
    else
        printPath( w );
    cout << endl;
}
开发者ID:piaoyimq,项目名称:CppSpace,代码行数:17,代码来源:Graph1.cpp

示例10:

map<mmddyyyy, UI> construct_hits_map(const vmap &r)
{
	map<mmddyyyy, UI> k;

	// construct map of dates and number of visits in each date
	for(vmap::const_iterator i = r.begin(); i!=r.end(); i++)
	{
		for(dvec::const_iterator j = i->second.begin(); j!=i->second.end(); j++)
		{
			if(k.find(*j)==k.end())
				k[*j] = 1;
			else
				k[*j]++;
		}
	}

	// erase unwanted elements
	mmddyyyy td = k.rbegin()->first;
	td.yyyy--; // this serves as the upper bound for erasure
	k.erase(k.begin(), k.upper_bound(td));

	return k;
}
开发者ID:hansongjing,项目名称:Old-Projects,代码行数:23,代码来源:barchart.cpp

示例11: isVertex

bool Graph::isVertex(const string& s) const {

	vmap::const_iterator it = vertexMap.find(s);
	if(it == vertexMap.end()) return false;
	return true;
}
开发者ID:keshavnandan,项目名称:Hackerrank,代码行数:6,代码来源:dynamicGraph.cpp

示例12: clearAll

void Graph::clearAll(){

	for(vmap::iterator it = vertexMap.begin(); it != vertexMap.end(); it++)
		(*it).second->reset();
}
开发者ID:keshavnandan,项目名称:Hackerrank,代码行数:5,代码来源:dynamicGraph.cpp


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