39 lines
No EOL
505 B
C++
39 lines
No EOL
505 B
C++
#ifndef _QUEUE_
|
|
#define _QUEUE_
|
|
|
|
#include <iostream>
|
|
#include "list.hpp"
|
|
template <class T>
|
|
class Queue
|
|
{
|
|
private:
|
|
List<T> q;
|
|
public:
|
|
int size()
|
|
{
|
|
return q.size();
|
|
}
|
|
bool empty()
|
|
{
|
|
return size() ? false : true;
|
|
}
|
|
T enqueue(T e)
|
|
{
|
|
return q.firstInsert(e);
|
|
}
|
|
T dequeue()
|
|
{
|
|
return q.removeLast();
|
|
}
|
|
T front()
|
|
{
|
|
return q.last()->data;
|
|
}
|
|
|
|
T back()
|
|
{
|
|
return q.first()->data;
|
|
}
|
|
|
|
};
|
|
#endif |