Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <deque>
- using std::cin;
- using std::cout;
- using std::vector;
- using std::ostream;
- using std::deque;
- template <typename T, typename Container = deque<T>>
- class Queue {
- private:
- Container body;
- public:
- Queue(const Container& c = {})
- : body(c)
- {}
- T front() const {
- return body.front();
- }
- T& front() {
- return body.front();
- }
- void pop() {
- body.pop_front();
- }
- void push(const T& elem) {
- body.push_back(elem);
- }
- size_t size() const {
- return body.size();
- }
- bool empty() const {
- return body.empty();
- }
- bool operator == (const Queue<T>& other) const {
- if (other.body.size() != body.size()) {
- return false;
- } else {
- for (size_t i = 0; i != body.size(); ++i) {
- if (body[i] != other.body[i])
- return false;
- }
- }
- return true;
- }
- bool operator != (const Queue<T>& other) const {
- if (other.body.size() != body.size()) {
- return true;
- } else {
- for (size_t i = 0; i != body.size(); ++i) {
- if (body[i] != other.body[i])
- return true;
- }
- }
- return false;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment