queue
队列提供先进先出功能,从尾部添加元素,从头部取出元素。其实是基于list的功能进行封装
#ifndef TQUEUE_H
#define TQUEUE_H
#include <stdlib.h>
#include <string.h>
#include <list>
#include <queue>
using namespace std;
template <class T>
class TQueue
{
public:
TQueue(){}
T& back()
{
return myList.back();
}
bool empty()
{
return myList.size() == 0;
}
T& first()
{
return myList.front();
}
void pop()
{
myList.pop_front();
}
void push(const T& val)
{
myList.push_back(val);
}
unsigned int size()
{
return myList.size();
}
private:
std::list<T> myList;
};
#endif // TQUEUE_H