本文整理汇总了C++中MyQueue::dequeue方法的典型用法代码示例。如果您正苦于以下问题:C++ MyQueue::dequeue方法的具体用法?C++ MyQueue::dequeue怎么用?C++ MyQueue::dequeue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyQueue
的用法示例。
在下文中一共展示了MyQueue::dequeue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
MyQueue<int> queue;
queue.enqueue(1);
queue.enqueue(2);
queue.enqueue(3);
if (!queue.empty()) {
std::cout << queue.front() << std::endl;
std::cout << queue.back() << std::endl;
}
queue.dequeue();
queue.enqueue(4);
if (!queue.empty()) {
std::cout << queue.front() << std::endl;
std::cout << queue.back() << std::endl;
}
queue.enqueue(5);
queue.dequeue();
if (!queue.empty()) {
std::cout << queue.front() << std::endl;
std::cout << queue.back() << std::endl;
}
queue.dequeue();
queue.dequeue();
queue.dequeue();
if (!queue.empty()) {
std::cout << queue.front() << std::endl;
std::cout << queue.back() << std::endl;
}
queue.dequeue();
queue.dequeue();
return 0;
}
示例2:
TEST(D_QueueViaStacksTest, Test2)
{
std::string output;
testing::internal::CaptureStdout();
MyQueue<int> mq;
try
{
mq.enqueue(1);
mq.dequeue();
mq.enqueue(2);
mq.dequeue();
mq.enqueue(3);
mq.dequeue();
mq.enqueue(4);
mq.dequeue();
mq.enqueue(5);
std::cout << "\n Front element in queue is " << mq.front();
mq.dequeue();
mq.enqueue(6);
std::cout << "\n Front element in queue is " << mq.front();
}
catch (std::exception e)
{
std::cout << e.what();
}
output = testing::internal::GetCapturedStdout();
EXPECT_EQ(1, 1);
}
示例3: main
int main() {
MyQueue queue;
queue.enqueue(1);
queue.enqueue(2);
queue.dequeue();
queue.enqueue(3);
printf("Values in queue: ");
while (!queue.empty()) {
printf("%d ", queue.dequeue());
}
printf("\n");
return 0;
}
示例4: main
int main(int argc, char** argv)
{
MyQueue<int> myQ;
myQ.enqueue(1);
myQ.enqueue(2);
myQ.enqueue(3);
myQ.enqueue(4);
while (myQ.size() > 2) {
cout << "Front of MyQueue object: " << myQ.front() << endl;
myQ.dequeue();
}
myQ.enqueue(5);
myQ.enqueue(6);
while (myQ.size() > 0) {
cout << "Front of MyQueue object: " << myQ.front() << endl;
myQ.dequeue();
}
return 0;
}
示例5: main
int main() {
MyQueue testQueue;
for (int i = 0; i < 10; i++) {
testQueue.enqueue(i);
std::cout << i << " ";
}
std::cout << std::endl;
for (int i = 0; i < 10; i++) {
std::cout << testQueue.dequeue() << " ";
}
}
示例6: main
int main()
{
MyQueue myqueue = *new MyQueue();
myqueue.enqueue(10);
myqueue.enqueue(20);
myqueue.enqueue(30);
myqueue.enqueue(40);
myqueue.enqueue(50);
cout<<"NOW SERVING: "<<myqueue.dequeue()<<endl;
cout<<"NEXT IN LINE: "<<myqueue.outbox.top()<<endl;
return 0;
}
示例7: main
int main(){
MyStack<int> a;
MyQueue<int> c;
a.push(4);
a.push(5);
cout << a.top() << endl;
a.pop();
cout << a.top() << endl;
c.enqueue(4);
c.enqueue(5);
cout << c.front() << endl;
c.dequeue();
cout << c.front() << endl;
}
示例8: main
int main(void)
{
MyQueue<int> list;
list.enqueue(1);
list.enqueue(2);
cout << "Size = " << list.size() << endl;
cout << "Dequeue => " << list.dequeue() << endl;
cout << "Peek => " << list.peek() << endl;
list.clear();
if (list.isEmpty())
list.enqueue(3);
return 0;
}
示例9: status
void Graph<Tv, Te>::BFS(int v, int &clock){
MyQueue<int> Q; //引入辅助队列
status(v) = DISCOVERED;
Q.enqueue(v); //初始化起点
while(!Q.empty()){ //在Q变空之前,不断
int v = Q.dequeue(); dTime(v) = ++clock; //取出队首顶点v
for(int u = firstNbr(v); -1 < u; u = nextNbr(v, u)) //枚举v的所有邻居
if(UNDISCOVERED == status(u)){ //尚未被发现,则
status(u) = DISCOVERED; //设置为已发现
Q.enqueue(u); //并且将该顶点入队
type(v, u) = TREE;
parent(u) = v; //引入树边拓展支撑树
}else{
type(v, u) = CROSS; //将(v,u)归类于跨边
}
status(v) = VISITED; //至此,当前节点访问完毕
}
}
示例10: main
int main()
{
MyQueue myqueue;
//myqueue.enqueue(0);
myqueue.enqueue(1);
myqueue.enqueue(2);
myqueue.enqueue(3);
myqueue.enqueue(4);
myqueue.enqueue(5);
myqueue.enqueue(6);
myqueue.enqueue(7);
myqueue.enqueue(8);
myqueue.enqueue(9);
int val;
while(myqueue.dequeue(val) == 0) {
std::cout << val << std::endl;
}
return 0;
}