problemscpp
A collection of my answers to algorithm problems in c++.
载入中...
搜索中...
未找到
acwing::acwing20::MyQueue类 参考

#include <acwing.h>

Public 成员函数

 MyQueue ()
 Initialize your data structure here
 
bool empty () const
 Returns whether the queue is empty
 
int peek ()
 Get the front element
 
int pop ()
 Removes the element from in front of queue and returns that element
 
void push (int x)
 Push element x to the back of queue
 

Private 属性

vector< int > main
 
vector< int > tmp
 

详细描述

在文件 acwing.h1711 行定义.

构造及析构函数说明

◆ MyQueue()

acwing::acwing20::MyQueue::MyQueue ( )

Initialize your data structure here

在文件 acwing.cpp5234 行定义.

5234 {
5235 main = vector<int>();
5236 tmp = vector<int>();
5237 }

引用了 MyQueue(), main , 以及 tmp.

被这些函数引用 MyQueue().

成员函数说明

◆ empty()

bool acwing::acwing20::MyQueue::empty ( ) const
nodiscard

Returns whether the queue is empty

返回
Whether the queue is empty

在文件 acwing.cpp5268 行定义.

5268{ return main.empty(); }

引用了 empty() , 以及 main.

被这些函数引用 empty().

◆ peek()

int acwing::acwing20::MyQueue::peek ( )

Get the front element

返回
The front element

在文件 acwing.cpp5255 行定义.

5255 {
5256 while(main.size() != 1) {
5257 tmp.push_back(main.back());
5258 main.pop_back();
5259 }
5260 const auto ret = main.back();
5261 while(!tmp.empty()) {
5262 main.push_back(tmp.back());
5263 tmp.pop_back();
5264 }
5265 return ret;
5266 }

引用了 main, peek() , 以及 tmp.

被这些函数引用 peek().

◆ pop()

int acwing::acwing20::MyQueue::pop ( )

Removes the element from in front of queue and returns that element

返回
The element from in front of queue

在文件 acwing.cpp5241 行定义.

5241 {
5242 while(main.size() != 1) {
5243 tmp.push_back(main.back());
5244 main.pop_back();
5245 }
5246 const auto ret = main.back();
5247 main.pop_back();
5248 while(!tmp.empty()) {
5249 main.push_back(tmp.back());
5250 tmp.pop_back();
5251 }
5252 return ret;
5253 }

引用了 main, pop() , 以及 tmp.

被这些函数引用 pop().

◆ push()

void acwing::acwing20::MyQueue::push ( int x)

Push element x to the back of queue

参数
xThe element to be pushed back into the queue

在文件 acwing.cpp5239 行定义.

5239{ main.push_back(x); }

引用了 main , 以及 push().

被这些函数引用 push().

类成员变量说明

◆ main

vector<int> acwing::acwing20::MyQueue::main
private

在文件 acwing.h1713 行定义.

被这些函数引用 MyQueue(), empty(), peek(), pop() , 以及 push().

◆ tmp

vector<int> acwing::acwing20::MyQueue::tmp
private

在文件 acwing.h1714 行定义.

被这些函数引用 MyQueue(), peek() , 以及 pop().


该类的文档由以下文件生成: