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


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

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


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

示例1: bfs

void bfs(int y, int x)
{  
	q.push_back(make_pair(make_pair(y,x),0)); 
	v[y][x]=1;
	while(!q.empty())
	{
		int deqh=q.front().first.first;
		int deqw=q.front().first.second;
		int deqc=q.front().second;
		q.pop_front();
		for(int i=0;i<4;i++)
		{
			int nx=deqw+dx[i];
			int ny=deqh+dy[i];
			if(nx>=0&&nx<w&&ny>=0&&ny<h&&!v[ny][nx])
			{ 
				if(!arr[ny][nx]) 
					// 0을 모두 방문해야하니, 앞으로 넣어준다. 그래야 다음 deq값도 0이 나오기 때문.
				{
					q.push_front(make_pair(make_pair(ny,nx),deqc));
					arr2[ny][nx]=deqc; // 배열을 하나 더 써야 원본맵 정보가 섞이지 않는다.
					v[ny][nx]=1;
				}
				else // 벽에 막혀 못 가는 경우라면 뒤로 넣어준다. 그래야 그 값을 새로 열린 길이라 여기고 bfs하기 때문.
				{ 
					q.push_back(make_pair(make_pair(ny,nx),deqc+1));
					arr2[ny][nx]=deqc+1;
					v[ny][nx]=1;
				}
			}
		}
	}   
}
开发者ID:imgosari,项目名称:acm,代码行数:33,代码来源:완전탐색_알고스팟.cpp

示例2: main

int main()
{
	
	cout << "enter frame size";
	int n, i, s, fault = 1;
	cin >> n;
	int *arr = new int[n];
	cout << "enter elemnets" << endl;
	for (i = 0; i < n; i++)
		cin >> arr[i];
	cout << "enter page size" << endl;
	cin >> s;
	mem.push_back(arr[0]);
	for (i = 1; i < n; i++)
	{
		if (mem.size() == s)
		{
			int ex = found(arr[i]);
			if (ex == -1)
			{
				fault++;
				mem.pop_front();
				mem.push_back(arr[i]);
			}
		}
		else
		{
			fault++;
			mem.push_back(arr[i]);
		}
		
	}
	cout <<  "no of faults is" << fault;
    return 0;
}
开发者ID:architb361,项目名称:os_fifo,代码行数:35,代码来源:fifo.cpp

示例3: BackgroundDef

BackgroundDef BackgroundImpl::Layer::CreateRandomBGA( const Song *pSong, const RString &sEffect, deque<BackgroundDef> &RandomBGAnimations, Actor *pParent )
{
	if( g_RandomBackgroundMode == BGMODE_OFF )
		return BackgroundDef();

	// Set to not show any BGChanges, whether scripted or random
	if( GAMESTATE->m_SongOptions.GetCurrent().m_bStaticBackground )
		return BackgroundDef();

	if( RandomBGAnimations.empty() )
		return BackgroundDef();

	/* XXX: every time we fully loop, shuffle, so we don't play the same sequence
	 * over and over; and nudge the shuffle so the next one won't be a repeat */
	BackgroundDef bd = RandomBGAnimations.front();
	RandomBGAnimations.push_back( RandomBGAnimations.front() );
	RandomBGAnimations.pop_front();

	if( !sEffect.empty() )
		bd.m_sEffect = sEffect;

	map<BackgroundDef,Actor*>::const_iterator iter = m_BGAnimations.find( bd );

	// create the background if it's not already created
	if( iter == m_BGAnimations.end() )
	{
		bool bSuccess = CreateBackground( pSong, bd, pParent );
		ASSERT( bSuccess );	// we fed it valid files, so this shouldn't fail
	}
	return bd;
}
开发者ID:KingMew,项目名称:stepmania,代码行数:31,代码来源:Background.cpp

示例4: main

int main (void)
{
#ifndef ONLINE_JUDGE
	freopen ("T1053.in", "r", stdin);
	freopen ("T1053.out", "w", stdout);
#endif

	cin >> n;

	for (int i=1; i<=n; ++i)
	{
		int a;
		cin >> a; 
		v.push_back(a);
	}

	while (v.size()!=1)
	{
		v[1]=gcd(v[0], v[1]);
		v.pop_front();
	}

	cout << v[0];
	
	return 0;
}
开发者ID:DrhF,项目名称:ACM,代码行数:26,代码来源:T1053.cpp

示例5: spfa

bool spfa() {
	dist[0] = 0;
	isInQ[0] = true;
	que.emplace_back(0);

	while (!que.empty()) {
		size_t here = que.front();
		que.pop_front();
		isInQ[here] = false;

		visits[here]++;
		if (visits[here] > n) return true;

		for (auto edge : G[here]) {
			int next = edge.second;
			int weight = edge.first;

			if (dist[next] > dist[here] + weight) {
				dist[next] = dist[here] + weight;

				if (isInQ[next] == false) {
					que.emplace_back(next);
					isInQ[next] = true;
				}
			}
		}
	}

	return false;
}
开发者ID:isac322,项目名称:BOJ,代码行数:30,代码来源:1865.cpp14.cpp

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

示例7: sub

  int sub(deque<pair<int,pair<long long, long long> > > price_and_mask, long long signature, int sum) {//, int cut=0) {
	int size = price_and_mask.size();
	if (size == 0) return 0;
	if (size == 1) return -(price_and_mask.front().first);
	if (m.find( signature ) != m.end()) return m[ signature ];
	
	long long sold_out = price_and_mask.front().second.second;
	//	vector< pair<int,long long> > price_sub1;
	deque< pair<int,pair<long long, long long> > > price_sub1;
	long long new_signature = 0;
	int sum1 = 0;
	tr(price_and_mask,it) {
	  if ((sold_out & it->second.second) == 0) {
		price_sub1.push_back( *it );
		new_signature |= it->second.first;
		sum1 -= it->first;
	  }
	}
	int amount1 = - price_and_mask.front().first + sub(price_sub1, new_signature, sum1);

	sum -= price_and_mask.front().first;
	if (sum < amount1) {
	  m[ signature ] = amount1;
	  return amount1;
	} 

	new_signature = signature - price_and_mask.front().second.first;
	price_and_mask.pop_front();

	int amount = max(amount1, sub(price_and_mask, new_signature, sum));
	m[ signature ] = amount;
	return amount;
  }
开发者ID:naoyat,项目名称:topcoder,代码行数:33,代码来源:StampsCollection_4a.cpp

示例8: main

int main(int argc, char *argv[])
{
    for (int i=0;i<size;i++)
    {
        cin>>frequency[i];                  //?入10??值
        ptr=new node;
        ptr->key=frequency[i];
        ptr->lchild=NULL;
        ptr->rchild=NULL;
        forest.push_back(ptr);
    }//形成森林,森林中的每一棵?都是一???
 
    //?森林?建霍夫曼?
    for (int i=0;i<size-1;i++)
    {
                sort(forest.begin(),forest.end(),compare);
                ptr=new node;
                //以下代?使用下?索引?列元素,具有?在危?,使用??注意
                ptr->key=forest[0]->key+forest[1]->key;
                ptr->lchild=forest[0];
                ptr->rchild=forest[1];
                forest.pop_front();
                forest.pop_front();
                forest.push_back(ptr);
        }
    ptr=forest.front();//ptr是一?指向根的指?
    printCode(code);
    //system("pause");
   
    while (1);
    return EXIT_SUCCESS;
}
开发者ID:cinderelladlw,项目名称:billwawa,代码行数:32,代码来源:huffmanwiki.cpp

示例9: operation

inline void operation(deque<string> &operationDeque, map<string, bool> &visitedMap, string &goalMatrix, int maxDepth) {

    while (true) {
        string currentMatrix = operationDeque.front();
        operationDeque.pop_front();
        if (currentMatrix.length() > MATRIX_SIZE + maxDepth) {
            cout << "-1" << endl;
            return;
        }

        if (currentMatrix.find(goalMatrix) != string::npos) {
            if (currentMatrix.length() == MATRIX_SIZE) {
                cout << "0 " << endl;
                return;
            }

            string answer = currentMatrix.substr(MATRIX_SIZE);
            cout << answer.length() << " " << answer << endl;
            return;
        }
        AOperation(operationDeque, visitedMap, currentMatrix);
        BOperation(operationDeque, visitedMap, currentMatrix);
        COperation(operationDeque, visitedMap, currentMatrix);
    }
}
开发者ID:ekuri,项目名称:Sicily,代码行数:25,代码来源:main.cpp

示例10: vecDiff

void vecDiff(const deque<unsigned int>& first, const deque<unsigned int>& second, deque<unsigned int>& result){

  result.clear();
  /* Assumption: the first argument is larger than the second one */
  int carry = 0;
  bool finished = false;
  deque<unsigned int>::const_reverse_iterator secondItr = second.rbegin(), secondItrEnd = second.rend();
  for (deque<unsigned int>::const_reverse_iterator itr = first.rbegin(), endItr = first.rend(); itr != endItr; itr++){
    int sec  = 0;
    if(secondItr != secondItrEnd){
      sec = *secondItr;
      secondItr++;
    }
    int sub =  carry + sec;
    if (*itr >= sub){
      result.push_front(*itr - sub);
      carry = 0;
    }

    else {
      result.push_front(*itr + 10 - sub);
      carry = 1;
    }
  }
  
  while (!result.empty() && result.front() == 0)
    result.pop_front();

  if (result.empty())
    result.push_back(0);
}
开发者ID:bhrzslm,项目名称:practice,代码行数:31,代码来源:test2.cpp

示例11: print

	void print(deque<double>& q1, deque<double>& q2) {
		double t1=q1.back();
		while (t1-q2.front()>1) q2.pop_front();
		for (int i=0; i<q2.size(); i++) {
			cout << q2[i] << " " << t1 << endl;
		}
	}
开发者ID:jtliames2013,项目名称:src,代码行数:7,代码来源:twosigma_print_timestamp_two_queue.cpp

示例12: dfs

void dfs(int v) {

    vector<int> l1, l2;
    while (dq.size() and deep[dq.back()] < deep[v]) {
        l1.PB(dq.back());
        dq.pop_back();
    }
    dq.push_back(v);
    ans[v] = dq[0];
    //cout << v << ' ' << dq[0] << endl;
    for (auto x: el[v]) {
        while (dq.size() and deep[dq[0]] < x) {
            l2.PB(dq[0]);
            dq.pop_front();
        }
        dfs(x);
        while (l2.size()) {
            dq.push_front(l2.back());
            l2.pop_back();
        }
    }
    dq.pop_back();
    while (l1.size()) {
        dq.push_back(l1.back());
        l1.pop_back();
    }
}
开发者ID:CoderINusE,项目名称:bcw_codebook,代码行数:27,代码来源:pE.cpp

示例13: ParseInput

void CcModelDonut::ParseInput(deque<string> &  tokenList)
{
//        string theString;
//Just read ID, LABEL,
// IX, IY, IZ,
// RED, GREEN, BLUE,
// OCC*1000,
// COVRAD, VDWRAD, SPARERAD
// FLAG,
// UISO or X11
      id        = atoi ( tokenList[0].c_str() );
      m_label     =        string(tokenList[1]);    //LABEL
      x         = atoi ( tokenList[2].c_str() );
      y         = atoi ( tokenList[3].c_str() );
      z         = atoi ( tokenList[4].c_str() );
      r         = atoi ( tokenList[5].c_str() );
      g         = atoi ( tokenList[6].c_str() );
      b         = atoi ( tokenList[7].c_str() );
      occ       = atoi ( tokenList[8].c_str() );
      covrad    = atoi ( tokenList[9].c_str() );
      vdwrad    = atoi ( tokenList[10].c_str() );
      sparerad  = atoi ( tokenList[11].c_str() );
      x11       = atoi ( tokenList[12].c_str() );
      rad       = atoi ( tokenList[13].c_str() );
      dec       = atoi ( tokenList[14].c_str() );
      az        = atoi ( tokenList[15].c_str() );
      for ( int i = 0; i<16; i++ ) tokenList.pop_front();
}
开发者ID:richardicooper,项目名称:Crystals,代码行数:28,代码来源:ccmodeldonut.cpp

示例14: SPFA

int SPFA(int s,int t)
{
    Q.clear();
    Q.push_back(s);
    memset(visit,127,sizeof(visit));
    memset(use,false,sizeof(use));
    use[s] = true;
    visit[s] = 0;
    while (!Q.empty())
    {
        int now = Q.front();
        Q.pop_front();
        use[now] = false;
        if (now == t)   return visit[now];
        for (int i = 1;i <= 100;i++)
        if (visit[now]+map[now][i] < visit[i])
        {
            visit[i] = visit[now]+map[now][i];
            if (use[i] == false)
            {
                Q.push_back(i);
            }
        }
    }
}
开发者ID:mzry1992,项目名称:workspace,代码行数:25,代码来源:XXX.cpp

示例15: GetAllPath

 void GetAllPath(string& start, string& end, unordered_map<string, list<string> >& DirGraph) {
     if(start == end) {
         oneSol.push_front(end);
         sols.push_back(vector<string>());
         copy(oneSol.begin(), oneSol.end(), back_inserter(sols.back()));
         oneSol.pop_front();
         return;
     }
     
     unordered_map<string, list<string> >::iterator it = DirGraph.find(start);
     oneSol.push_front(start);
     for(list<string>::iterator lit = it->second.begin(); lit != it->second.end(); ++lit)
             GetAllPath(*lit, end, DirGraph);
     oneSol.pop_front();
     
 }
开发者ID:tommengdel,项目名称:Leetcode,代码行数:16,代码来源:WordLadderII-2.cpp


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