0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-18 06:31:59 +00:00
OI-codes/AcWing/20/20.cpp

41 lines
792 B
C++
Raw Normal View History

class MyQueue {
2022-05-20 01:23:27 +00:00
private:
queue<int> q;
2022-05-20 01:23:27 +00:00
public:
/** Initialize your data structure here. */
MyQueue() {
}
2022-05-20 01:23:27 +00:00
/** Push element x to the back of queue. */
void push(int x) {
q.push(x);
}
2022-05-20 01:23:27 +00:00
/** Removes the element from in front of queue and returns that element. */
int pop() {
int ret = q.front();
q.pop();
return ret;
}
2022-05-20 01:23:27 +00:00
/** Get the front element. */
int peek() {
return q.front();
}
2022-05-20 01:23:27 +00:00
/** Returns whether the queue is empty. */
bool empty() {
return q.empty();
}
};
/**
* Your MyQueue object will be instantiated and called as such:
* MyQueue* obj = new MyQueue();
* obj->push(x);
* int param_2 = obj->pop();
* int param_3 = obj->peek();
* bool param_4 = obj->empty();
*/