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


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

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


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

示例1: Check

inline bool Check(int D) {
    deque <int>().swap(dq);
    for(int i = 1 ; i <= N ; ++ i)
        for(int j = 0 ; j <= d[N] ; ++ j)
            dp[i][j] = oo;
    dp[1][0] = 0;
    for(int i = 2 ; i <= N ; ++ i) {
        for(int j = 0 ; j <= d[N] ; ++ j) {
            while(!dq.empty() && abs(j - dq.front()) > D)
                dq.pop_front();
            while(!dq.empty() && dp[i - 1][dq.back()] >= dp[i - 1][j])
                dq.pop_back();
            dq.push_back(j);
            dp[i][j] = dp[i - 1][dq.front()] + abs(d[i] - j);
        }
    }
    return dp[N][d[N]] <= E;
}
开发者ID:rusucosmin,项目名称:cplusplus,代码行数:18,代码来源:main.cpp

示例2: main

int main() {
	int	X,	Y,	T = 0;
	char	input[2];
	while( scanf( "%d%d", &M, &N ) != EOF ) {
		if( T++ ) putchar( '\n' );
		for( int i = 0; i < M; i++ )
			scanf( "%s", grid[i] );
		scanf( "%d%d%s", &X, &Y, input );
		Force.resize( 0 );
		Force.push_back( oper( X - 1, Y - 1, *input ) );
		while( !Force.empty() ) {
			knockDown( Force[0].x, Force[0].y, Force[0].c );
			Force.pop_front();
		}
		for( int i = 0; i < M; i++ )
			printf( "%s\n", grid[i] );
	}
}
开发者ID:3013216027,项目名称:zoj-solutions-fish_ball,代码行数:18,代码来源:p2925.cpp

示例3: help

	void help(vector<int> &num, int step) {
		int size = (int)num.size() - step;
		if (size == 0) {
			result.push_back(path);
			return;
		}
		int prev = q.front() - 1;
		for (int i = 0; i < size; i++) {
			int x = q.front();
			q.pop_front();
			if (x != prev) {
				path[step] = x;
				help(num, step + 1);
			}
			q.push_back(x);
			prev = x;
		}
	}
开发者ID:Rand3,项目名称:leetcode,代码行数:18,代码来源:permutations-ii.cpp

示例4: contract

void contract(int u,int v,int n)
{
        int anc=findancestor(u,v);
        SET(inblossom,0);
        reset(u,anc);reset(v,anc);
        if(base[u]!=anc)pre[u]=v;
        if(base[v]!=anc)pre[v]=u;
        for(int i=1;i<=n;i++)
                if(inblossom[base[i]])
                {
                        base[i]=anc;
                        if(!inque[i])
                        {
                                Q.push_back(i);
                                inque[i]=1;
                        }
                }
}
开发者ID:RunningTime,项目名称:algorithm,代码行数:18,代码来源:blossom_algorithm.cpp

示例5: inorder

    void inorder(TreeNode* &root, stack<pair<int, int>> &stk, int &cnt, deque<int> &dq) {
        if (!root) return; 

        inorder(root->left, stk, cnt, dq);
        dq.push_back(root->val);
        if (dq.size() > 2) dq.pop_front(); // trim deque when its length goes beyong 2     

        if (dq.front() == root->val) cnt++;
        else {
            if (dq.front() != INT_MIN && dq.front() != root->val && (stk.empty() || cnt >= stk.top().second)) {
                if (!stk.empty() && cnt > stk.top().second) while (!stk.empty()) stk.pop(); // when we meet better solution, clear the old one
                stk.push(pair<int, int>(dq.front(), cnt));
            }
            cnt = 1; // put it outside the above loop
        }

        inorder(root->right, stk, cnt, dq);
    }
开发者ID:WayneDW,项目名称:leetCode,代码行数:18,代码来源:501_Find_Mode_In_Binary_Search_Tree.cpp

示例6: process

    void process(int u, int p) {
        while (u != p) {
            int a = match[u];
            int b = link[a];

            if (uf.find(b) != p)
                link[b] = a;

            if (type[a] == ODD) {
                type[a] = EVEN;
                q.push_back(a);
            }

            uf.link(u, a);
            uf.link(a, b);
            u = b;
        }
    }
开发者ID:riteme,项目名称:test,代码行数:18,代码来源:copy1.cpp

示例7: restart

    void restart() {
        // clean data
        data.clear();
        snake.clear();

        game_state = PLAYING;

        // construct data
        for (int i = 0; i < N; i++) {
            data.push_back(vector<int>(N, EMPTY));
        }

        // find some random, non-overlapping position
        vector<pii> v;
        for (int r = 0; r < N; r++) {
            for (int c = 0; c < N; c++) {
                v.push_back(pii(r, c));
            }
        }
        for (int i = 1; i < N * N; i++) { // shuffle
            int idx = randint(0, i);
            swap(v[i], v[idx]);
        }

        // init stones
        int stones_num = randint(0, 3);
        for (int i = 0; i < stones_num; i++) {
            int r = v.back().first;
            int c = v.back().second;
            data[r][c] = STONE;
            v.pop_back();
        }

        // init snake
        this->dir = randint(0, 3);
        int snake_init_r = v.back().first;
        int snake_init_c = v.back().second;
        data[snake_init_r][snake_init_c] = BODY;
        snake.push_back(pii(snake_init_r, snake_init_c));
        v.pop_back();

        // init first food
        this->generate_thing(FOOD);
    }
开发者ID:amoshyc,项目名称:sfml-snake,代码行数:44,代码来源:main.cpp

示例8: sendToServer

  bool sendToServer(const std::string& a) 
  {
    cout<<endl<<"Request for -- "<<a<<"\t";
    unordered_map<string,string>::iterator it_map=FIFO_cache.find(a); 
    valueToReturn.clear();

    if(it_map==FIFO_cache.end()) /*Entry doesn't exist*/
    {
        valueToReturn=getBody(a);
        if (valueToReturn.length()>maximumCacheSize_FIFO)
        {
          cout<<"The requested content is much larger than cache size!"<<endl;
          valueToReturn="";
          return false;
        }

        cout<<"Cache Miss!"<<endl;

        int requiredSize=valueToReturn.length()+currentCacheSize_FIFO;

        if(requiredSize>=maximumCacheSize_FIFO)
          cout<<endl<<"Cache requires flushing now!"<<endl;

        for(deque<string>::iterator it_deque=FIFOref.begin();it_deque!=FIFOref.end() && requiredSize>=maximumCacheSize_FIFO;it_deque=FIFOref.begin())
          {
                cout<<"Removing "<<*it_deque<<endl;
                int temp=FIFO_cache[*it_deque].length();
                currentCacheSize_FIFO-=temp;
                requiredSize-=temp;
                FIFO_cache.erase(*it_deque);
                FIFOref.pop_front();
          }

        FIFO_cache.insert(pair<string,string>(a,valueToReturn));
        FIFOref.push_back(a);
        currentCacheSize_FIFO+=valueToReturn.length();
    }
    else
    {
      cout<<"Cache Hit!"<<endl;
      valueToReturn=FIFO_cache[it_map->first];
    }
    return true;
  }
开发者ID:rohit-jamuar,项目名称:RPC-Based-Proxy-Server,代码行数:44,代码来源:simpleTests_server_FIFO.cpp

示例9: GetSubScopeIntervals

void Styler_Syntax::GetSubScopeIntervals(unsigned int pos, unsigned int offset, const submatch& sm, deque<interval>& scopes) const {
	for (auto_vector<stxmatch>::const_iterator p = sm.matches.begin(); p != sm.matches.end(); ++p) {
		const stxmatch& m = *(*p);

		if (pos >= m.start && pos < m.end) {
			if (!m.m_name.empty()) {
				scopes.push_back(interval(offset+m.start, offset+m.end));
			}

			// Check if there are submatches
			if (m.subMatch.get()) {
				wxASSERT(pos >= m.start);
				GetSubScopeIntervals(pos - m.start, offset+m.start, *m.subMatch, scopes);
			}
			return;
		}
		else if (m.start > pos) break;
	}
}
开发者ID:baguatuzi,项目名称:e,代码行数:19,代码来源:styler_syntax.cpp

示例10: appendTxtToOutput

bool appendTxtToOutput(string content){
	if (outputPath.compare("") == 0){
		MessageBox(hWnd, "Save log failed. Please set up output file and try to save again!", "WARNING", MB_OK);
		return false;
	}

	outputStream << content << endl;
	outputLog.push_back(content);
	while (outputLog.size() > SHOW_LOG_SIZE){
		outputLog.pop_front();
	}

	string log = "";
	for (int i = 0; i < outputLog.size(); i++){
		log += " " + outputLog.at(i) + "\n";
	}
	Set_Text(result_handle, (char*)log.c_str());
	return true;
}
开发者ID:liuruilinspy,项目名称:vehicleTrackingReview,代码行数:19,代码来源:UsingOpenCV.cpp

示例11: addToHPRQueue

/**
 * Method name: addToHPRQueue
 * Description: goes through the processes vector and adds all unstarted processes to ready queue 
 * and sorts the queue by penalty ratio.
 * Parameters: processes vector, cpu object, and ready deque
 */
deque<int> addToHPRQueue(cpu cpu, deque<int> deque){
    
    vector<process> processesCopy = processes;
    sort(processesCopy.begin(), processesCopy.end(), comparePenalty);
    
    for(int i = 0; i < processesCopy.size(); i++){
        
        if(processesCopy[i].A <= cpu.time &&
           (processesCopy[i].state == process::UNSTARTED || processesCopy[i].state == process::READY) &&
           processesCopy[i].onQueue == false){
            
            int x = processesCopy[i].processID - 1;
            processes[x].onQueue = true;
            processes[x].state = process::READY;
            deque.push_back(x);
        }
    }
    return deque;
}
开发者ID:meghamadan,项目名称:Operating-Systems,代码行数:25,代码来源:scheduler.cpp

示例12: main

 int main(int argc, char *argv[])
 {
     while(cin>>ica>>icb>>cr)
     {
         travel.clear();
         result.clear();
         minStepNum=-1;
         
         seach(0,0);
         output.push_back(success);
         
         for(Iter iter=output.begin();iter!=output.end();++iter)
         {
             cout<<def[*iter]<<endl;      
         }                     
     }
   //  system("PAUSE");
     return EXIT_SUCCESS;
}
开发者ID:gemire,项目名称:code,代码行数:19,代码来源:1005_1.cpp

示例13: set

 void set(int key, int value) {
     if (dict.count(key) != 0) {// found
         touch(key);
         dict[key] = value;
         ht[key] = keys.end();
         return;
     }
     
     //if not found
     if (keys.size() == cap) {
         //remove oldest one
         dict.erase(keys.front());
         ht.erase(keys.front());
         keys.pop_front();
     }
     keys.push_back(key);
     ht[key] = keys.end();
     dict[key] = value;
 }
开发者ID:wxn7,项目名称:Leetcode,代码行数:19,代码来源:146.LRU.cpp

示例14: BOperation

inline void BOperation(deque<string> &operationDeque, map<string, bool> &visitedMap, string currentMatrix) {
    char row1temp1 = currentMatrix[MATRIX_SIZE / 2 - 1];
    char row2temp1 = currentMatrix[MATRIX_SIZE - 1];
    char row1temp2, row2temp2;
    for (int count = 0; count < MATRIX_SIZE / 2; count++) {
        row1temp2 = currentMatrix[count];
        row2temp2 = currentMatrix[count + (MATRIX_SIZE / 2)];
        currentMatrix[count] = row1temp1;
        currentMatrix[count + (MATRIX_SIZE / 2)] = row2temp1;
        row1temp1 = row1temp2;
        row2temp1 = row2temp2;
    }
    string currentState = currentMatrix.substr(0, MATRIX_SIZE);
    if (visitedMap.find(currentState) != visitedMap.end()) {
        return;
    }
    visitedMap[currentState] = true;
    operationDeque.push_back(currentMatrix + 'B');
}
开发者ID:ekuri,项目名称:Sicily,代码行数:19,代码来源:main.cpp

示例15: contains

bool contains(deque<T> &q, T sent) {
    deque<T> hold;
    bool holder = false;
    
    while(!q.empty()) {
        T t = q.front();
        hold.push_front(t);
        
        if(hold.front() == sent) {
            holder = true;
            while(!hold.empty()) {
                q.push_back(hold.back());
                hold.pop_back();
            }
            return holder;
        } else
            q.pop_front();
    
}
}
开发者ID:sean-broomfield,项目名称:data_structures_3130,代码行数:20,代码来源:deque_demo.cpp


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