本文整理汇总了C++中Queue::Pop方法的典型用法代码示例。如果您正苦于以下问题:C++ Queue::Pop方法的具体用法?C++ Queue::Pop怎么用?C++ Queue::Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue::Pop方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main()
{
Queue queue;
queue.Push(Point(99,55),0);
queue.Push(Point(88,55),1);
queue.Push(Point(77,55),2);
queue.Push(Point(66,55),1);
queue.Push(Point(55,55),2);
queue.Push(Point(44,55),4);
queue.Push(Point(33,55),3);
Point p = queue.Pop();
p = queue.Pick();
queue.Push(Point(22,55),5);
p = queue.Pick();
p = queue.Pop();
p = queue.Pop();
p = queue.Pop();
p = queue.Pop();
p = queue.Pop();
p = queue.Pop();
}
示例2: main
int main()
{
Queue qu;
char* str1 = "push1";
char* str2 = "push2";
char* str3 = "push3";
char* str4 = "push4";
char* str5 = "push5";
//Push
qu.Push(str1);
qu.Push(str2);
qu.Push(str3);
qu.Push(str4);
qu.Push(str5);
//Pop
#if 1
int count = qu.GetSize();
cout << "size : " << count << endl;
for(int i=0; i<count; i++){
cout << (char*)qu.Pop() << endl;
}
#else
qu.ShowAllData();
#endif
return 0;
}
示例3: TestQueue
void TestQueue()
{
Queue<int> q;
q.Push(1);
q.Push(2);
q.Push(3);
q.Push(4);
q.Print();
q.Pop();
q.Pop();
q.Pop();
q.Print();
}
示例4: menuQueue
void menuQueue()
{
Queue *queue = new Queue;
char c;
do
{
printf("1: Push\n");
printf("2: Pop\n");
printf("3: IsEmpty\n");
printf("\nEsc: Exit\n");
c = getch();
switch(c)
{
case '1':
cout << "Push:";
int val;
cin >> val;
queue->Push(val);
cout << endl; break;
case '2':
cout << "Pop:";
int v;
v = queue->Pop();
cout << v << endl; break;
case '3':
cout << "IsEmpty:";
bool flag = queue->IsEmpty();
cout << ( flag == true ? "true" : "false") << endl; break;
}
} while(c != 27);
delete queue;
}
示例5: main
int main(int argc,char *argv[])
{
srand(time(NULL));
signal(SIGTERM,SIGTERMHandler);
GLOBAL_PROCESS_IDS *GPI = (GLOBAL_PROCESS_IDS*)
GetSHM(sizeof(GLOBAL_PROCESS_IDS),GLOBAL_MEM);
//Put values in global shared memory for other process to see
GPI->CarUnload = getpid();
Queue *Q = (Queue *) GetSHM(SHMSIZE,TOURISTS_Q);
int size = GPI->CarCapacity*sizeof(TouristInfo);
Queue *CarTable = (Queue *) GetSHM(size+sizeof(Queue),CAR_TABLE);
Queue *TouristStatus = (Queue *) GetSHM(SHMSIZE,TOURISTS_STAT);
TouristStatus->Queue_INIT(SHMSIZE-sizeof(Queue),TOURISTS_STAT);
SignalHandler::WaitForSignal(SIGCONT);
while(flag)
{
CarTable->Lock();
cout<<"Locked";
while(CarTable->Size() > 0)
{
sleep(1);
int elem = CarTable->Pop(true);
kill(elem,SIGCONT);
cout<<RED<<"\nRemoving User:"<<elem<<DEFAULT<<flush;
//if(false)
if( R(100) < GPI->Probabilty)
{
Q->Push(elem);
kill(elem,SIGCONT);
cout<<GREEN<<"\nInserting User:"<<elem<<" back to Queue."<<DEFAULT<<flush;
}
else kill(elem,SIGTERM);
TouristStatus->Push(elem);
}
CarTable->Unlock();
//sleep(2);//simulate working....
GPI->CarMode = CARMODES::READY;
cout<<GREEN<<"\nCarMode READY\n"<<DEFAULT<<flush;
SignalHandler::WaitForSignal(SIGCONT);
}
cout<<RED<<endl<<argv[0]<<" Exiting..\n"<<DEFAULT<<flush;
//shmdt(Q);
//shmdt(GPI);
//shmdt(CarTable);
//shmdt(TouristStatus);
return 0;
}
示例6: Test
void Test()
{
Queue<int> q;
q.Push(1);
q.Push(2);
q.Push(3);
q.Push(4);
cout<<q.Front()<<endl<<endl;
cout<<q.Back()<<endl<<endl;
cout<<q.Empty()<<endl<<endl;
cout<<q.Size()<<endl<<endl;
q.Pop();
q.Pop();
q.Pop();
q.Pop();
q.Pop();
cout<<endl<<q.Empty()<<endl<<endl;
}
示例7: src
TEST_F(TestDownloader, DownloaderShouldPushDataToQueue)
{
const std::string data(CHUNK_SIZE, '$');
FakeSource src(data, CHUNK_DELAY);
Queue q;
Downloader dl(src, q);
dl.Start();
dl.Wait();
ASSERT_EQ(MakeChunk(data), q.Pop(CHUNK_SIZE));
}
示例8: main
int main()
{
Queue<int> numStack;
cout << endl << "PUSH" << endl;
for ( int i = 0; i < 5; i++ )
{
numStack.Push( i * 3 );
}
cout << endl << "POP" << endl;
while ( numStack.Size() != 0 )
{
numStack.Pop();
}
return 0;
}
示例9: move
std::string bt<T>::BFTraverse() const
{
if (_tree == nullptr)
return "";
std::stringstream ss;
Queue<Node> queue;
queue.Push(*_tree);
while (queue.Peek() != nullptr)
{
auto front = queue.Pop()->m_data;
ss << front.data << "|";
if (front.left != nullptr)
queue.Push(*front.left);
if (front.right != nullptr)
queue.Push(*front.right);
}
return std::move(ss.str());
}
示例10: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
Queue<int> q;
for (int i = 0; i < 10; ++i)
{
int* p = new int(i);
q.Push(p);
}
std::cout << "Queue's size: " << q.Size() << std::endl;
int* p;
for (int i = 0; i < 10; ++i)
{
bool ret = q.Pop(p);
if (ret)
{
std::cout << *p << std::endl;
}
}
//q.print();
return 0;
}
示例11: main
int main()
{
Queue<string> myStringQueue;
myStringQueue.Push( "Hello" );
myStringQueue.Push( "Saluton" );
myStringQueue.Push( "Konnichiwa" );
myStringQueue.Push( "Bonjour" );
myStringQueue.Push( "Hola" );
Stack<string> myStringStack;
myStringStack.Push( "Hello" );
myStringStack.Push( "Saluton" );
myStringStack.Push( "Konnichiwa" );
myStringStack.Push( "Bonjour" );
myStringStack.Push( "Hola" );
int count = 0;
while ( myStringStack.GetSize() != 0 )
{
cout << "Loop " << count << endl;
cout << "\t Stack: " << myStringStack.Top() << endl;
cout << "\t Queue: " << myStringQueue.Front() << endl;
cout << endl;
count++;
myStringStack.Pop();
myStringQueue.Pop();
}
cout << "Press a key to continue..." << endl;
cin.get();
Queue<int> myIntQueue;
myIntQueue.Push( 1 );
myIntQueue.Push( 1 );
myIntQueue.Push( 2 );
myIntQueue.Push( 3 );
myIntQueue.Push( 5 );
Stack<int> myIntStack;
myIntStack.Push( 1 );
myIntStack.Push( 1 );
myIntStack.Push( 2 );
myIntStack.Push( 3 );
myIntStack.Push( 5 );
count = 0;
while ( myIntStack.GetSize() != 0 )
{
cout << "Loop " << count << endl;
cout << "\t Stack: " << myIntStack.Top() << endl;
cout << "\t Queue: " << myIntQueue.Front() << endl;
cout << endl;
count++;
myIntStack.Pop();
myIntQueue.Pop();
}
cout << "Press a key to exit..." << endl;
cin.get();
return 0;
}
示例12: proc
//获取消息队列消息
void proc(void *arg)
{
HWND hMain = (HWND)arg;
USE_JSONCODER_DOC(document);
while(1)
{
Sleep(1);
CAutoLock lock(&g_TGetLock);
char *msg = NULL;
try
{
msg = reinterpret_cast<char *>(msg_queue.Pop());
//msg = (&doublebuffer_queue)->Popup();
if(!msg)
{
continue;
}
}
catch(...){
//Log("proc : msg_queue.Pop() fialed.");
}
#ifdef DEBUG_MODE
std::cout << msg << std::endl;
#endif
//解码
LOAD_JSONCODER_STR(document, msg);
JsonCoder jc_decoder;
if(!jc_decoder.CheckPacket(document))
{
//cout << "error packet" << endl;
PostMessage(hMain, WM_ERRORPCK, 0, 0);
continue;
}
//获取消息
uint32 cmd = jc_decoder.GetInt(JC_KEY::JC_MSGTYPE, document);
//服务端发送过来的回应包
if(cmd == MESSAGE_TYPE::cmdLoginRep)
{
//返回的客户列表
std::string user_list = jc_decoder.GetString(JC_KEY::JC_USERLISTREP, document);
//上线提示
std::string onlineUser = jc_decoder.GetString(JC_KEY::JC_ONLINEREP, document);
//发送上线提醒消息
std::string *olUser = new std::string(onlineUser);
PostMessage(hMain, WM_ONLINEWARN, (WPARAM)olUser, 0);
#ifdef DEBUG_MODE
cout << "user_list" << user_list << endl;
#endif
//发送列表消息
std::string *uList = new std::string(user_list);
//上线的用户提示
std::string *warn = new std::string(onlineUser);
PostMessage(hMain, WM_UPDATELIST, (WPARAM)uList, (LPARAM)warn);
}
else if(cmd == MESSAGE_TYPE::cmdLogoutRep)
{
//客户端离线提示
std::string logoutUser = jc_decoder.GetString(JC_KEY::JC_LOGOUTUSER, document);
//列表删除
ClientMap::iterator ite = cmap.begin();
ite = cmap.find(logoutUser);
if(ite != cmap.end())
{
cmap.erase(ite);
}
std::string *ss = new std::string(logoutUser);
PostMessage(hMain, WM_DELUSERLIST, (WPARAM)ss, 0);
}
else if(cmd == MESSAGE_TYPE::cmdPublicMsgRep)
{
//发送者id
std::string user_identify = jc_decoder.GetString(JC_KEY::JC_IDENTIFY, document);
//谁发送的
std::string sender = jc_decoder.GetString(JC_KEY::JC_SENDER, document);
//发送了什么
std::string pubmsg = jc_decoder.GetString(JC_KEY::JC_PUBMSG, document);
//发送时间
std::string pubtime = jc_decoder.GetString(JC_KEY::JC_PUBTIME, document);
if(strcmp(user_identify.c_str(), g_Identify.c_str()) != 0)
{
std::wstring tmp = PublicTool::string2wstring(sender);
tmp.append(STR_OTHER_SAY);
tmp.append(PublicTool::string2wstring(pubmsg));
tmp.append(L"[");
tmp.append(PublicTool::string2wstring(pubtime));
tmp.append(L"]");
std::wstring *ss = new std::wstring(tmp);
PostMessage(hMain, WM_PUBMSG, (WPARAM)ss, 0);
}
}
//内存归还到内存池
MsgPool.Release(msg);
}
}