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


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

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


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

示例1: getCurrent

 T getCurrent() override {
    if (_node == nullptr) {
       while (1) {
          DequeNode &dNode = v.front();
          BSTNode *node = dNode.node;
          if (dNode.descendNode == false ||
              (!node->right && !node->left)) {
             _node = node;
             //cout << "Popping "<< _node->val << endl;
             v.pop_front();
             break;
          } else {
             if (node->right) {
                v.push_front(DequeNode(node->right));
                //cout << "Pushing "<< node->right->val << endl;
             }
             if (node->left) {
                v.push_front(DequeNode(node->left));
                //cout << "Pushing "<< node->left->val << endl;
             }
             dNode.descendNode = false;
          }
       }
    }
    return _node->val;
 }
开发者ID:mnv104,项目名称:hackerrank,代码行数:26,代码来源:binarySearchTree.cpp

示例2: melkman

//Realiza el algoritmo de Melkman para hallar el convex hull de un poligono simple
// La entrada Q debe ser un poligono simple ordenado 
void melkman(std::list<Point2D> & Q, std::deque<Point2D> & D){
    bool volar_b = false;
    bool volar_t = false;
    unsigned int m = 0;
    unsigned int b = 0;
    unsigned int t = 0;
    std::vector<Point2D> V;
    std::list<Point2D>::iterator p = Q.begin();
    while(p != Q.end()){
        V.push_back(*p);
        p++;
    }
    //Inicializa la deque con los primeros 3 en CCW
    if(right(V[0], V[1], V[2])){
        D.push_front(V[2]);
        D.push_front(V[1]);
        D.push_front(V[0]);
        D.push_front(V[2]);
    } else {
        D.push_front(V[2]);
        D.push_front(V[0]);
        D.push_front(V[1]);
        D.push_front(V[2]);
    }

    unsigned int n = Q.size();
    unsigned int i = 2;
    while((++i) < n){
        m = D.size();
        b = 0;
        t = D.size()-1;
        volar_b = right(V[i], D.at(b), D.at(b+1));
        volar_t = right(D.at(t-1), D.at(t), V[i]);
        
        if(!volar_b && !volar_t) //En el cono interno, no se agrega
            continue;

        while(volar_b){             
            D.pop_front();
            volar_b = right(V[i], D.at(b), D.at(b+1));
        }
        D.push_front(V[i]);//Dentro segun el primer segmento
        
        t = D.size()-1;
        volar_t = right(D.at(t-1), D.at(t), V[i]);
        while(volar_t){
            t--;
            D.pop_back();
            volar_t = right(D.at(t-1), D.at(t), V[i]);
        }
        D.push_back(V[i]); //Dentro segun el ultimo segmento
    }
}
开发者ID:fern17,项目名称:geometriacomputacionalFICH,代码行数:55,代码来源:melkman.cpp

示例3: getPath

unsigned char CSceneData::getPath(int sx,int sy,int tx,int ty, std::deque<char>& path)
{
	m_SearchedFlag++;
	m_nNodeCount=0;
	m_nAllNodeCount=0;
	m_nMinH = 1000;
	m_nMinHNode = 0;

	m_tx = tx;
	m_ty = ty;

	int dir = 0;
	addNode(sx,sy,-1,0,0);

	for(;m_nNodeCount>0;)
	{
		Node a = getNode(); // 取出一个节点
		if ((a.x == m_tx) && (a.y == m_ty)) // 目标
		{
			dir = m_allnode[a.n].dir;
			path.clear();
			m_nAllNodeCount = a.n;
			while(m_allnode[m_nAllNodeCount].dir != -1)
			{
				path.push_front(m_allnode[m_nAllNodeCount].dir);
				m_nAllNodeCount = m_allnode[m_nAllNodeCount].father;
			}
			return dir;
			break;
		}
		for (int i = 0; i<DIR_COUNT; i++)
		{
			addNode(a.x+DX[i], a.y+DY[i], i, a.level+ASTAR_F[i], a.n); // 扩展此节点
			if (m_nAllNodeCount>=MAX_ALLNODE || m_nNodeCount>=MAX_NODE)
			{
				break;
			}
		}
	}
	m_nAllNodeCount = m_nMinHNode;
	dir = m_allnode[m_nAllNodeCount].dir;
	path.clear();
	while(m_allnode[m_nAllNodeCount].dir != -1)
	{
		path.push_front(m_allnode[m_nAllNodeCount].dir);
		m_nAllNodeCount = m_allnode[m_nAllNodeCount].father;
	}
	return dir;
}
开发者ID:constantinbogdan,项目名称:node3d,代码行数:49,代码来源:SceneData.cpp

示例4: getCallSite

/*
 * Obtain some details of a given call site.
 */
void COptimiser::getCallSite(int required, POS &i, POS begin, std::deque<CALL_PARAM> &params) const
{
	do
	{
		if (i->udt & UDT_LINE)
		{
			++i;
			break;
		}
		else
		{
			POS j = i;
			if ((i->udt & UDT_FUNC) && i->params)
			{
				// Another function!
				std::deque<CALL_PARAM> reparams;
				getCallSite(i->params, --j, begin, reparams);
			}
			params.push_front(std::pair<POS, POS>(j, i));
			i = j;
			if (!--required) break;
		}

	} while (i-- != begin);
}
开发者ID:LameAss-Studio,项目名称:trans3,代码行数:28,代码来源:COptimiser.cpp

示例5: set_neighbor_tex_coord_data

//Assuming this is already textured, 
//set all the neighboring rect's texture coordinates data
//invoking compute_texture_by_triangles().
bool mgTLRect::set_neighbor_tex_coord_data(
	mgTLData& tldata,
	std::deque<mgTLRect*>& rects	//modified rects will be prepended.
){
	//if(m_u1<.251&& m_v1<.5626 &&m_v0>.499)
	//	m_u1=m_u1;//****************************
	bool textured=false;
	int level=m_textured+1;
	for(size_t i=0; i<4; i++){
		std::list<mgTLRect*> neibors=neighbours(i);
		std::list<mgTLRect*>::iterator j=neibors.begin(), je=neibors.end();
		for(; j!=je; j++){
			mgTLRect* rectj=*j;
			if(rectj->status()==MGRECT_OUT)
				continue;
			if(rectj->is_textured())
				continue;
			rectj->compute_texture_from_neighbor(tldata,*this,i);
			//rectj->compute_texture_by_triangles(tldata);
			rectj->set_texture_level(level);
			rects.push_front(rectj);
			textured=true;
		}
	}
	return textured;
}
开发者ID:zephyrer,项目名称:mgcl,代码行数:29,代码来源:TLRect.cpp

示例6: ScanDir

void CArchiveScanner::ScanDir(const std::string& curPath, std::deque<std::string>& foundArchives)
{
	std::deque<std::string> subDirs = {curPath};

	while (!subDirs.empty()) {
		const std::string& subDir = FileSystem::EnsurePathSepAtEnd(subDirs.front());
		const std::vector<std::string>& foundFiles = dataDirsAccess.FindFiles(subDir, "*", FileQueryFlags::INCLUDE_DIRS);

		subDirs.pop_front();

		for (const std::string& fileName: foundFiles) {
			const std::string& fileNameNoSep = FileSystem::EnsureNoPathSepAtEnd(fileName);
			const std::string& lcFilePath = StringToLower(FileSystem::GetDirectory(fileNameNoSep));

			// Exclude archive files found inside directory archives (.sdd)
			if (lcFilePath.find(".sdd") != std::string::npos)
				continue;

			// Is this an archive we should look into?
			if (archiveLoader.IsArchiveFile(fileNameNoSep)) {
				foundArchives.push_front(fileNameNoSep); // push in reverse order!
				continue;
			}
			if (FileSystem::DirExists(fileNameNoSep)) {
				subDirs.push_back(fileNameNoSep);
			}
		}
	}
}
开发者ID:nixtux,项目名称:spring,代码行数:29,代码来源:ArchiveScanner.cpp

示例7: sio_readexpect

// MT safe
int sio_readexpect(std::string &msg, const char * prefix, int * preflen, int timeout) {

  std::deque<std::string> rejected;

  // true timeout
  int64 stoptime = time64() + timeout*1000;

  int rv;
  while (stoptime > time64()) {
	int delta = (int)( (stoptime - time64()) / 1000 );
	rv=sio_read(msg, (delta>0)?delta:0);
	if (rv <= 0) break; //  error or timeout
	rv = sio_matchpref(msg.c_str(), prefix, preflen);
	if (rv > 0) break; // found it
	rejected.push_back(msg); 
	//printf("rejected: [%s] (%d)\n", msg.c_str(), rejected.size());
  };

  // push back the unanswered messages...
  std::string tmp;
  while (!rejected.empty()) {
	tmp = rejected.back();
	rejected.pop_back();
	postponed.push_front(tmp);
	//printf("postponed: [%s] (%d)\n", tmp.c_str(), postponed.size());
  };

  //printf("MESSAGE [%s] is number %d in list of\n%s\n", msg.c_str(), rv, prefix);
  return rv;
};
开发者ID:chezbob,项目名称:chezbob,代码行数:31,代码来源:servio.cpp

示例8: FindMazePathRecursive

bool FindMazePathRecursive(int **maze, int x, int y, int w, int h, std::deque<Direction>& path)
{
    static Direction direction[4] = {{1, 0},{0, 1},{-1, 0}, {0, -1}};

    if(x == w-1 && y == h-1) return true;
    for(int i=0; i<4; ++i)
    {
        int xx = x + direction[i].x;
        int yy = y + direction[i].y;

        if(xx >=0 && yy >=0 &&
                yy < h && xx < w &&
                maze[yy][xx] == 0)
        {
            maze[yy][xx] = 1;
            if(FindMazePathRecursive(maze, xx, yy, w, h, path))
            {
                Direction dir;
                dir.x = xx;
                dir.y = yy;
                path.push_front(dir);
                return true;
            }
            maze[yy][xx] = 0;
        }
    }
    return false;
}
开发者ID:renshengqiang,项目名称:Algorithm,代码行数:28,代码来源:Maze.cpp

示例9: main

int main(){
	scanf("%hd%hd%hd\n",&n.x,&n.y,&t);
	for(i.x=1;i.x<=n.x;scanf("\n"),i.x++)
		for(i.y=1;i.y<=n.y;map[i.x][i.y]=getchar()=='1',i.y++);
	short ans=0;
	for(i.x=1;i.x<=n.x;i.x++)
		for(i.y=1;i.y<=n.y;i.y++){
			for(j.x=1;j.x<=n.x;j.x++)
				for(j.y=1;j.y<=n.y;j.y++)
					dist[j.x][j.y]=t+1;
			dist[i.x][i.y]=map[i.x][i.y];
			q.push_back(i);
			while(!q.empty()){
				vec u=q.front(); q.pop_front();
				for(int d=0;d<4;d++){
					vec v(u.x+dir[d].x,u.y+dir[d].y);
					if(dist[u.x][u.y]+map[v.x][v.y]<dist[v.x][v.y]){
						dist[v.x][v.y]=dist[u.x][u.y]+map[v.x][v.y];
						if(map[v.x][v.y])
							q.push_back(v);
						else
							q.push_front(v);
					}
				}
			}
			for(j.x=i.x;j.x<=n.x;j.x++)
				for(j.y=1;j.y<=n.y;j.y++)
					if(dist[j.x][j.y]<t+1&&sqr(j.x-i.x)+sqr(j.y-i.y)>ans)
						ans=sqr(j.x-i.x)+sqr(j.y-i.y);
		}
	printf("%.6lf\n",sqrt((double)ans));
}
开发者ID:wwt17,项目名称:BZOJ,代码行数:32,代码来源:1295+[SCOI2009]最长距离(01边权最短路).cpp

示例10: postOrderIterator

 postOrderIterator(BinarySearchTree<T> *tree) :
    iteratorInt(tree, BST_POSTORDER), _node(nullptr) {
    if (tree != nullptr) {
       BSTNode *node = tree->root;
       //cout << "Pushing "<< node->val << endl;
       v.push_front(DequeNode(node));
    }
 }
开发者ID:mnv104,项目名称:hackerrank,代码行数:8,代码来源:binarySearchTree.cpp

示例11: mouseDrag

void LineRenderingSampleApp::mouseDrag(MouseEvent event)
{
    mMousePositions.push_front(vec3(event.getPos(), 0.0f));
    if (mMousePositions.size() > mMaxMousePositions)
    {
        mMousePositions.pop_back();
    }
}
开发者ID:sansumbrella,项目名称:Pockets,代码行数:8,代码来源:LineRenderingSampleApp.cpp

示例12: EventTriggered

void EventTriggered(Event *e, EventParams params) {
	lock_guard guard(mutex_);

	DispatchQueueItem item;
	item.e = e;
	item.params = params;
	g_dispatchQueue.push_front(item);
}
开发者ID:m45t3r,项目名称:native,代码行数:8,代码来源:view.cpp

示例13: BuildPath

void GraphSearchWrigglerGrid::BuildPath(GraphSearchWrigglerGrid* pFinalNode, std::deque<GraphSearchWrigglerGrid*>& path)
{
	while((pFinalNode != nullptr) && (pFinalNode->m_pPrevious != nullptr))
	{
	   path.push_front(pFinalNode);
	   pFinalNode = pFinalNode->m_pPrevious;
	}
}
开发者ID:BryceMehring,项目名称:TJ-Wriggle-solver,代码行数:8,代码来源:GraphSearchWrigglerGrid.cpp

示例14: setup_players

	void setup_players(std::deque<player_t *> &tournament_players) {
		tournament_players.assign(this->players.begin(), this->players.end());
		std::random_shuffle(tournament_players.begin(), tournament_players.end());

		/** Define o 1o elemento como "bye", se necessário" */
		if(tournament_players.size() % 2)
			tournament_players.push_front(nullptr);
	}
开发者ID:gnramos,项目名称:CIC-IIA,代码行数:8,代码来源:RoundRobinTournament.hpp

示例15: getPointerTy

void Mips16TargetLowering::
getOpndList(SmallVectorImpl<SDValue> &Ops,
            std::deque< std::pair<unsigned, SDValue> > &RegsToPass,
            bool IsPICCall, bool GlobalOrExternal, bool InternalLinkage,
            CallLoweringInfo &CLI, SDValue Callee, SDValue Chain) const {
  SelectionDAG &DAG = CLI.DAG;
  const char* Mips16HelperFunction = 0;
  bool NeedMips16Helper = false;

  if (getTargetMachine().Options.UseSoftFloat && Mips16HardFloat) {
    //
    // currently we don't have symbols tagged with the mips16 or mips32
    // qualifier so we will assume that we don't know what kind it is.
    // and generate the helper
    //
    bool LookupHelper = true;
    if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(CLI.Callee)) {
      if (NoHelperNeeded.find(S->getSymbol()) != NoHelperNeeded.end()) {
        LookupHelper = false;
      }
    }
    if (LookupHelper) Mips16HelperFunction =
      getMips16HelperFunction(CLI.RetTy, CLI.Args, NeedMips16Helper);

  }

  SDValue JumpTarget = Callee;

  // T9 should contain the address of the callee function if
  // -reloction-model=pic or it is an indirect call.
  if (IsPICCall || !GlobalOrExternal) {
    unsigned V0Reg = Mips::V0;
    if (NeedMips16Helper) {
      RegsToPass.push_front(std::make_pair(V0Reg, Callee));
      JumpTarget = DAG.getExternalSymbol(Mips16HelperFunction, getPointerTy());
      JumpTarget = getAddrGlobal(JumpTarget, DAG, MipsII::MO_GOT);
    } else
      RegsToPass.push_front(std::make_pair((unsigned)Mips::T9, Callee));
  }

  Ops.push_back(JumpTarget);

  MipsTargetLowering::getOpndList(Ops, RegsToPass, IsPICCall, GlobalOrExternal,
                                  InternalLinkage, CLI, Callee, Chain);
}
开发者ID:8l,项目名称:emscripten-fastcomp,代码行数:45,代码来源:Mips16ISelLowering.cpp


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