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


C++ deque::erase方法代码示例

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


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

示例1: handleBombsAndDiamonds

// erase bombs and diamonds when off screen.
void handleBombsAndDiamonds(XInfo &xInfo) {
	for (int i = 0; i < (int)dBombList.size(); i++) {
		if (dBombList[i]->getX() < -20 || (dBombList[i]->getSpeedY() > 0 && dBombList[i]->getY() > xInfo.height + 20)
			|| (dBombList[i]->getSpeedY() < 0 && dBombList[i]->getY() < -20)){
			delete dBombList[i];
			dBombList.erase(dBombList.begin() + i);
		}
	}
	for (int i = 0; i < (int)dDiamondList.size(); i++) {
		if (dDiamondList[i]->getX() < -20 || dDiamondList[i]->getY() > xInfo.height){
			delete dDiamondList[i];
			dDiamondList.erase(dDiamondList.begin() + i);
		}
	}
}
开发者ID:aimango,项目名称:xshooter,代码行数:16,代码来源:Game.cpp

示例2: DeleteVip

void DeleteVip()
{
	cin.get();
	size_t i;
	string studentId;
	cout << endl;
    cout << "********************************************************" <<endl;
    cout << "*              Delete vip by number...                 *" <<endl;
    cout << "********************************************************" <<endl;

	cout << "Please input student Id(string): ";
	cin >> studentId;
	for(i = 0; i < vip.size(); i++)
	{
		pVip = vip[i];
		if(0 == studentId.compare(pVip->GetStudentId()))
		{
			cout << endl;
			pVip->DisplayInfo();
			pVip->DisplayOtherInfo();

			pVip = 0;
			vip.erase(vip.begin() + i);
            cout << "********************************************************" <<endl;
            cout << "*                Finished to delete...                 *" <<endl;
            cout << "********************************************************" <<endl;
			return;
		}
	}
    cout << "********************************************************" <<endl;
    cout << "*                  Can't find vip...                   *" <<endl;
    cout << "********************************************************" <<endl;
}
开发者ID:jeakeven,项目名称:VipInfoMgr,代码行数:33,代码来源:VipMgr.cpp

示例3: Solve

bool Huffman::Solve(){
	while(tree.size()>=digitNum){
		sort(tree.begin(),tree.end(),NodeCompare);
		Node* combine=new Node;
		combine->value=CHAR_MAX;
		combine->frequency=0;
		combine->child=tree.front();
		combine->sibling=NULL;
		for(int i=0;i<digitNum;i++){
			if(combine->value>tree[i]->value)
				combine->value=tree[i]->value;
			combine->frequency+=tree[i]->frequency;
			if(i+1<digitNum)
				tree[i]->sibling=tree[i+1];
		}
		tree.erase(tree.begin(),tree.begin()+digitNum);
		tree.push_front(combine);
	}
	Coding(tree.front(),"");
	double average=0.0;
	for(int i=0;i<letterNum;i++)
		average+=letter[i]->frequency*letter[i]->code.length();
	average/=tree.front()->frequency;
	printf("Set %d; average length %.2lf\n",ID,average);
	for(i=0;i<letterNum;i++)
		printf("    %c: %s\n",letter[i]->value,letter[i]->code.c_str());
	printf("\n");
	return true;
}
开发者ID:junzh0u,项目名称:poj-solutions,代码行数:29,代码来源:2952288_AC_62MS_120K.cpp

示例4: PickFilesToLoad

int PickFilesToLoad(deque<string>& files)
{   
    files = extrautility::ListFiles(WALLPAPER_DIR);
    
    if(extrautility::GetLastError() == extrautility::BAD_DIRECTORY)
    {
        ERROR_SYSTEM("The ~/.wallpapers/ directory does not exist."
                " Please create and populate it.");
        return -1;
    }
    //Inverse the set of all files with the following extensions and filter them
    //out.
    extrautility::RegexFilter filter(".+\\.jpg|.+\\.jpeg|.+\\.tiff|.+\\.gif|.+\\.bmp|.+\\.png");
    filter.invert(); 
    files.erase(std::remove_if(files.begin(), files.end(), filter), files.end());
    
    if(files.empty())
    {
        ERROR_SYSTEM("The ~/.wallpapers/ directory is empty.");
        return -1;
    }
    
    std::shuffle(files.begin(), files.end(), 
            std::default_random_engine());
    
    return 0;
}
开发者ID:DavidYoung1995,项目名称:X11BgChanger,代码行数:27,代码来源:main.cpp

示例5: mythread_exit

void mythread_exit() {

    tcb *this_th = thread_list[this_th_th];
    while (!this_th->waiting.empty()) {
        queue.push_back(this_th->waiting.front());
        this_th->waiting.pop_front();
    }
    deque<tcb*>::iterator it = find(queue.begin(), queue.end(), this_th);
    if (it != queue.end())
        queue.erase(it, it+1);
    if (queue.empty()) {
        exit(0); // no other thread remaining
    }
    // run the next thread if availiable
    tcb *  thread = queue.front();
    queue.pop_front();

    tcb *th = thread_list[this_th_th];
    delete th;
    thread_list.erase(this_th_th);



    this_th_th = thread->id;


    setcontext(&(thread->context));
    

    }
开发者ID:maligulzar,项目名称:projects,代码行数:30,代码来源:ult.cpp

示例6: breadth_first_search

// LOGIC: if there's still stuff on the queue,
// we pop one vertex*, then check it to see if it's the destination
// if yes, we are done (return true)
// if no, we push all its unvisited neighbor vertex* on the queue
// for each neighbor, we store a pointer to the vertex* we came from
// and then return the result of breadth first search again.
// If the queue is empty, we give up (return false)
bool graph::breadth_first_search(vertex* u, map<vertex*, bool>& visited, deque<vertex*>& yet_to_explore, map<vertex*, vertex*>& path)
{

    if (!yet_to_explore.empty()) {
        //grab the last item in the deque
        vertex* b = yet_to_explore.front(); //grab first entry use .front()
        //pop this item off
        yet_to_explore.erase(yet_to_explore.begin());
        //if that item is u, were' done (our base case)
        if(b->get_city_name() == u-> get_city_name()) {
            return true;
        }
        vector<vertex*>::iterator it;
        for(it = edges[b].begin(); it != edges[b].end(); ++it) {
            vertex* neighbor = *it;
            if(visited[neighbor] == false) {
                yet_to_explore.push_back(neighbor);
                visited[neighbor] = true;
                path[neighbor] = b; // we came from w to get to neighbor
            }
        }
        return depth_first_search(u, visited, yet_to_explore, path);
    }
    else return false;
}
开发者ID:Nishesh1412,项目名称:CU,代码行数:32,代码来源:graph.cpp

示例7: str2bin

//write bit stream to file
void str2bin(deque<char> & ss,ofstream & of)
{
	  while(ss.size()>0)
	  {
	    of<<bin2ascii(&ss[0]);
	    ss.erase(ss.begin(),ss.begin()+8);
	  }
}
开发者ID:AhmetHan,项目名称:Huffman-Encoding,代码行数:9,代码来源:huff.cpp

示例8: updateCache

 void updateCache(Node* node)
 {
     if (node == NULL) return;
     auto iter = find(queue.begin(), queue.end(), node);
     if (iter == queue.end() || iter == queue.end() - 1) return;
     queue.erase(iter);
     queue.push_back(node);
 }
开发者ID:PoundKey,项目名称:Algorithms,代码行数:8,代码来源:134.+LRU+Cache.cpp

示例9: assign

 void assign(int cur) {
   D.push_back(cur); ++res;
   if(D.front()<=cur-K) D.pop_front();
   if(SZ(D)>K/2) {
     for(int i=SZ(D)-1; i>=0; --i) if(is.count(D[i])==0) {
       D.erase(D.begin()+i); --res;
       break;
     }
   }
 }
开发者ID:k-ori,项目名称:topcoder-offline,代码行数:10,代码来源:ApplesAndOrangesHard.cpp

示例10: moveToFront

void moveToFront(int i, Xpp* xpp, Draw* draw) {
    xpp->resizeAndCenter(windows.front(), minW, minH);
    windows.push_front  (windows[i]);
    windows.erase       (windows.begin()+i+1);
    xpp->raise          (windows.front());
    xpp->focus          (windows.front());
    isBig               = false;
    draw->move          (windows.front(), 0);
    draw->update        ();
}
开发者ID:elbrook33,项目名称:Glass,代码行数:10,代码来源:main.cpp

示例11: sub

 void sub(Node &o){
     deque<string>::iterator it;
     while(!o.dq.empty()){
         it = find(dq.begin(), dq.end(), o.dq.front());
         if (it!=dq.end()){
             dq.erase(it);
         }
         o.dq.pop_front();
     }
 }
开发者ID:ZhouWeikuan,项目名称:zoj,代码行数:10,代码来源:3185.cpp

示例12: remove

void ofURLFileLoaderImpl::remove(int id){
	Poco::ScopedLock<ofMutex> lock(mutex);
	for(int i=0;i<(int)requests.size();i++){
		if(requests[i].getID()==id){
			requests.erase(requests.begin()+i);
			return;
		}
	}
	ofLogError("ofURLFileLoader") << "remove(): request " <<  id << " not found";
}
开发者ID:BonjourDpt,项目名称:openFrameworks,代码行数:10,代码来源:ofURLFileLoader.cpp

示例13: MontoCarloAI

int HexGame::MontoCarloAI(Color color) {
	// TODO Auto-generated constructor stub
	cout<<"computer is thinking..."<<endl;
    int pMax,nWinsMax=0;
    Color oppCol;
    if(color==Color::RED)  oppCol=Color::BLUE;
    else  oppCol=Color::RED;
	for(auto position:unoccupied){  // unsorted unoccupied
		int nwins=0;
		Graph cfgG=*G; //make a copy to current configuration
		if(cfgG.get_node_value(position)==Color::WHITE)
			cfgG.set_node_value(position,color);
		else cout<<"something wrong on unoccupied"<<endl;
		auto cfgUnoccupied=unoccupied;
		auto iter=find(cfgUnoccupied.begin(),cfgUnoccupied.end(),position);
		cfgUnoccupied.erase(iter);// removes the element in position
		if(winMC(color,cfgG)){
			pMax=position;
			break; // if wins
		}
		for(int i=0;i<MonteCarloTrials;i++){ // for all monte carlo trials
			Graph cpG=cfgG; //make a copy
			auto cpUnoccupied=cfgUnoccupied;
			random_shuffle(cpUnoccupied.begin(), cpUnoccupied.end());  // generate a random series
			while(!cpUnoccupied.empty()){
                // it's opponent's turn
				int pos=cpUnoccupied.front();
				cpUnoccupied.pop_front(); //removes the first element
				if(cpG.get_node_value(pos)==Color::WHITE) cpG.set_node_value(pos,oppCol);
				else {
					cout<<"pos is "<<pos<<" something wrong with unoccupied in oppCol"<<endl;
				    cout<<( (cpG.get_node_value(pos)==Color::BLUE)?"BLUE":"RED" )<<endl;
				    cout<<"oppCol is "<<( (oppCol==Color::BLUE)?"BLUE":"RED" )<<endl;
				}
				if(!cpUnoccupied.empty()){
					pos=cpUnoccupied.front();
					cpUnoccupied.pop_front(); //removes the first element
					if((cpG.get_node_value(pos)==Color::WHITE) )cpG.set_node_value(pos,color);
				}
			}
			if(winMC(color,cpG))nwins++;
			// after fill up the board
		}   // end of one trial

		if(nwins>nWinsMax){
			nWinsMax=nwins;
			pMax=position;
		}
	}  // for each next possible move
	auto iter=find(unoccupied.begin(),unoccupied.end(),pMax);
	unoccupied.erase(iter);   // remove the occupied one
	G->set_node_value(pMax,color);
	drawBoard();
	return pMax;
}
开发者ID:ktjones,项目名称:CPP4C_Programmers,代码行数:55,代码来源:HWFive.cpp

示例14: completeJob

void completeJob(string jobID)
{
    deque<JobStory>::iterator it;
    for(it = runningJobSet.begin(); it != runningJobSet.end(); it++) {
        if(it->jobID == jobID)
            break;
    }
    assert(it != runningJobSet.end());
    completedJobSet.push_back(*it);
    runningJobSet.erase(it);
}
开发者ID:Ahmed-Azri,项目名称:HadoopSim,代码行数:11,代码来源:TraceReader.cpp

示例15:

 virtual ~PhysicalObject()
 {
     for (long i = 0; i < objects.size(); i++)
     {
         if (objects[i] == this)
         {
             objects.erase(objects.begin() + i);
             break;
         }
     }
 }
开发者ID:timothyfee,项目名称:AmoebaServer,代码行数:11,代码来源:PhysicalObject.hpp


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