Skip to content

Instantly share code, notes, and snippets.

@erming
Created June 16, 2020 17:12
Show Gist options
  • Save erming/c0305fa6991a60344b4e5bf15f4695a7 to your computer and use it in GitHub Desktop.
Save erming/c0305fa6991a60344b4e5bf15f4695a7 to your computer and use it in GitHub Desktop.
#ifndef _QUEUE_H
#define _QUEUE_H
#undef min
#undef max
#include <queue>
template <class T>
class Queue {
private:
std::queue<T> q;
int max;
public:
Queue(int max) {
this->max = max;
}
public:
void push(T &value) {
if (isFull()) {
q.pop();
}
q.push(value);
}
T pop() {
T value = q.front();
q.pop();
return value;
}
int size() {
return q.size();
}
bool isFull() {
return size() == max;
}
bool isEmpty() {
return size() == 0;
}
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment