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


C++ Queue::Delete方法代码示例

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


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

示例1: PrintQueue

void PrintQueue(Queue<T> &queue)
{
	std::cout<<"Current Element: ";
	while(!queue.isEmpty())
		std::cout<<queue.Delete()<<" ";
	std::cout<<std::endl;
}
开发者ID:deliangyang,项目名称:Data-Structure,代码行数:7,代码来源:QueueTest.cpp

示例2: Next

char* LevelIterator::Next()
{
   if (CurrentNode) {
       char temp =  CurrentNode->data;
       if (CurrentNode->LeftChild) q.Add(CurrentNode->LeftChild);
       if (CurrentNode->RightChild) q.Add(CurrentNode->RightChild);
       CurrentNode = *q.Delete(CurrentNode);
       return &temp;
   }
   return 0;
}
开发者ID:ChenBoTang,项目名称:fds,代码行数:11,代码来源:leviter.cpp

示例3: LevelOrder

void Tree::LevelOrder()
// Traverse the binary tree in level order
{
    Queue<TreeNode*>  q;
     TreeNode *CurrentNode = root;
    while (CurrentNode) {
	cout << CurrentNode->data << endl;
	if (CurrentNode->LeftChild) q.Add(CurrentNode->LeftChild);
	if (CurrentNode->RightChild) q.Add(CurrentNode->RightChild);
	CurrentNode = *q.Delete(CurrentNode);
    }
}
开发者ID:ChenBoTang,项目名称:fds,代码行数:12,代码来源:leviter.cpp

示例4: Run

void Airport::Run(){ 
	int pri;
	airplane p;
	for(nowtime=1;nowtime<=endtime;nowtime++){
		cout<<"\nThe "<<nowtime<<" Minutes";
		pri=PRand(expectland);
		for(int i=1;i<=pri;i++){
			p=*Newairplane(p,ARRIVE);
		if(airland.IsFull())NoServe(p,ARRIVE);else {airland.Add(p);if(1!=airland.Size())cout<<" waiting on runway.";}
		}

		pri=PRand(expectfly);
		for(int i1=1;i1<=pri;i1++){
			p=*Newairplane(p,FLY);
 if(airfly.IsFull())NoServe(p,FLY);else {airfly.Add(p);if(1!=airland.Size()+airfly.Size())cout<<" waiting on runway.";}
		}

		if(airland.IsEmpty())Freeplane();
		if(!airland.IsEmpty()){p=*airland.Delete(p);Land(p,3);}
		else if(!airfly.IsEmpty()){p=*airfly.Delete(p);Fly(p,3);}
	}
	GetCalculate();
}
开发者ID:3588,项目名称:au-cs230,代码行数:23,代码来源:8.cpp

示例5: FindPath

bool FindPath(Position start, Position finish,
             int& PathLen, Position * &path)
{// Find a path from start to finish.
 // Return true if successful, false if impossible.
 // Throw NoMem exception if inadequate space.

   if ((start.row == finish.row) &&
      (start.col == finish.col))
         {PathLen = 0; return true;} // start = finish

   // initialize wall of blocks around grid
   for (int i = 0; i <= m+1; i++) {
      grid[0][i] = grid[m+1][i] = 1; // bottom & top
      grid[i][0] = grid[i][m+1] = 1; // left & right
      }

   // initialize offsets
   Position offset[4];
   offset[0].row = 0; offset[0].col = 1; // right
   offset[1].row = 1; offset[1].col = 0; // down
   offset[2].row = 0; offset[2].col = -1; // left
   offset[3].row = -1; offset[3].col = 0; // up

   int NumOfNbrs = 4; // neighbors of a grid position
   Position here, nbr;
   here.row = start.row;
   here.col = start.col;
   grid[start.row][start.col] = 2; // block
   
   // label reachable grid positions
   Queue<Position> Q;
   do 
   {// label neighbors of here
      for (int i = 0; i < NumOfNbrs; i++) 
      {
         nbr.row = here.row + offset[i].row;
         nbr.col = here.col + offset[i].col;
         if (grid[nbr.row][nbr.col] == 0) 
         {
             // unlabeled nbr, label it
             grid[nbr.row][nbr.col] = grid[here.row][here.col] + 1;

             if ((nbr.row == finish.row) && (nbr.col == finish.col)) 
                 break; // done
             Q.Add(nbr);
         } // end of if
      } // end of for
      
      // have we reached finish?
      if ((nbr.row == finish.row) &&
          (nbr.col == finish.col)) break; // done

      // finish not reached, can we move to a nbr?
      if (Q.IsEmpty()) return false; // no path
      here = Q.First();// get next position
      Q.Delete(); 
   } while(true);
            
   // construct path
   PathLen = grid[finish.row][finish.col] - 2;
   path = new Position [PathLen];

   // trace backwards from finish
   here = finish;
   for (int j = PathLen-1; j >= 0; j--) {
      path[j] = here;
      // find predecessor position
      for (int i = 0; i < NumOfNbrs; i++) {
         nbr.row = here.row + offset[i].row;
         nbr.col = here.col + offset[i].col;
         if (grid[nbr.row][nbr.col] == j+2) break;
         }
      here = nbr;  // move to predecessor
      }

   return true;
}
开发者ID:psachin,项目名称:MyPublic,代码行数:77,代码来源:wire.cpp

示例6: main

int main(void)
{
	int *data;														  // 用來接收一副牌的資料
    int times = 1,total = 0;										  
	int faceu[SIZE][7] = {0};										  // 7 plies of face-up cards

	Queue stockcards;											      // storage facedown stock cards
	Stack wastecards;									              // storage face-up waste plie cards
	Stack faced[7];												      // 7 piles of facedown cards
	int Spade, Heart, Diamond, Club;						          // output plies
	Number num[7] = {0};											  // record faceu's status

    while(times <= 100)
	{
		int i = 0, j = 0, k = 0, action = 0;						  // counter, action是動作計數器
		int counter = 0;											  // 判斷步驟用的變數
		int score = -52;											  // 分數
		Club = Diamond = Heart = Spade = 0;							  // output plies initial
        data = new_set_of_cards(times);								  // 要一副洗好的牌資料 , times為100次中的第幾次

		for(i = 1; i <= 28 ;)										  // 發牌到下面七個row裡
		{
			for(j = k; j < 7; j++ ,i++)
			{
				faced[j].Push(data[i-1]);
				num[j].fst = num[j].nth = (data[i-1] - 1) % 13;
				num[j].fstcardno = num[j].cardno = data[i-1];
			}
			k++;
		}

		for(i = 28 ; i < 52 ; i++)									  // 發剩下的牌到牌堆裡
		{
			stockcards.Add(data[i]);
		}

		for(i = 0 ; i < 7 ; i++)									  // 翻開playing plie最下面的牌
		{
			faceu[0][i] = faced[i].Pop();	
			num[i].sheets = 1;
		}

		wastecards.Push(stockcards.Delete());						  // 從牌堆翻一張牌到waste plie

		while(counter == 0)
		{
			counter = 1;			
//(a)從wasteplie和playing plie把最上方的牌移至output區                      ( counter = 1 )
//   如果wasteplie空了,就從牌堆翻開一張牌放到wasteplie	
/*-------------------------------------------------------------------------------------------------------*/		
			while(counter == 1)
			{	 /*----------wastecards part----------*/
				if((wastecards.Top() - 1) == (13 * 0) + Spade   ||(wastecards.Top() - 1) == (13 * 1) + Heart 
				 ||(wastecards.Top() - 1) == (13 * 2) + Diamond ||(wastecards.Top() - 1) == (13 * 3) + Club)
				{/*----------可以放上去的狀況---------*/
					score += 5;
					switch((wastecards.Top() - 1) / 13)
					{
						case 0:
							Spade++;
							break;
						case 1:
							Heart++;
							break;
						case 2:
							Diamond++;
							break;
						case 3:
							Club++;
							break;
					}
					wastecards.Pop();
					
					action++;
					if(wastecards.IsEmpty())
					{
						wastecards.Push(stockcards.Delete());
					}
					counter = 0;
					break;
				}	
				/*------playing plies part-------*/
				for(i = 0 ; i < 7 ; i++)
				{
					if((num[i].cardno - 1) == (13 * 0) + Spade   || (num[i].cardno - 1) == (13 * 1) + Heart 
				    || (num[i].cardno - 1) == (13 * 2) + Diamond || (num[i].cardno - 1) == (13 * 3) + Club)
					{/*-------可以放上去的狀況-------*/
						score += 5;
						switch((num[i].cardno - 1) / 13)
						{
							case 0:
								Spade++;
								break;
							case 1:
								Heart++;
								break;
							case 2:
								Diamond++;
								break;
							case 3:
//.........这里部分代码省略.........
开发者ID:kevingyc,项目名称:Homework,代码行数:101,代码来源:496470516_2.cpp

示例7: getFrontCustomerId

/** Fungsi yang mengembalikan customer id dari customer yang menempati barisan terdepan dari Teller tersebut */
int Teller::getFrontCustomerId(){
	Queue* temp = new Queue();
	*temp = *customers;
	return temp->Delete();

}
开发者ID:GilangJulianS,项目名称:Bank,代码行数:7,代码来源:Teller.cpp


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