Advertisement
LilChicha174

Untitled

Jun 2nd, 2022
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <queue>
  2. #include <string>
  3. #include <iostream>
  4. #include <sstream>
  5.  
  6. using namespace std;
  7.  
  8. class MyType{
  9.     // этот класс можно оставить пустым
  10. };
  11.  
  12. template <typename T> class Queue {
  13. public:
  14.     // конструктор
  15.     Queue() {
  16.         current = 0;
  17.         first = 0;
  18.     }
  19.  
  20.     ~Queue() = default;
  21.  
  22.     void push(T elem) {
  23.         array[current++] = elem;
  24.     }
  25.  
  26.     T front() {
  27.         return array[first];
  28.     }
  29.  
  30.     void pop() {
  31.         first++;
  32.     }
  33.  
  34.     bool empty() {
  35.         return current == first;
  36.     }
  37.  
  38. private:
  39.     int current, first;
  40.     T array[100000];
  41. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement