Skip to the content.

:heavy_check_mark: data-structure/simple-queue.hpp

Required by

Verified with

Code

#pragma once

template <class T>
struct SimpleQueue {
 private:
  vector<T> a;
  int p;

 public:
  SimpleQueue() {}
  SimpleQueue(int n) { a.reserve(n); }
  void reserve(int n) { a.reserve(n); }
  int size() { return a.size() - p; }
  bool empty() { return a.size() == p; }
  void push(const T& v) { a.push_back(v); }
  T& front() { return a[p]; }
  void pop() { p++; }
  void clear() {
    a.clear();
    p = 0;
  }
};
#line 2 "data-structure/simple-queue.hpp"

template <class T>
struct SimpleQueue {
 private:
  vector<T> a;
  int p;

 public:
  SimpleQueue() {}
  SimpleQueue(int n) { a.reserve(n); }
  void reserve(int n) { a.reserve(n); }
  int size() { return a.size() - p; }
  bool empty() { return a.size() == p; }
  void push(const T& v) { a.push_back(v); }
  T& front() { return a[p]; }
  void pop() { p++; }
  void clear() {
    a.clear();
    p = 0;
  }
};
Back to top page