Compare commits

...

1 Commits
main ... deque

Author SHA1 Message Date
Glence 8325b7e2be base class for deque 2022-10-19 10:17:34 +08:00
1 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
#pragma once
#include "SH_API.h"
#include <deque>
namespace SHADE
{
template<typename T>
class SH_API SHDeque
{
public:
SHDeque(int n) : max_size(n) {}
std::deque<T> GetDeque() const
{
return deque;
}
void InsertFront(T const& obj)
{
if (deque.size() < max_size)
deque.push_front(std::move(obj));
else
{
deque.pop_back();
deque.push_front(std::move(obj));
}
}
bool IsEmpty()
{
return deque.empty();
}
void Pop()
{
deque.pop_front();
}
T const& Top()
{
return deque.front();
}
private:
int max_size;
std::deque<T> deque;
};
}