This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/DataStructure/Code/ex9/queue.hpp
2021-12-19 22:25:07 +08:00

45 lines
No EOL
572 B
C++

#ifndef _QUEUE_HPP_
#define _QUEUE_HPP_
#include <iostream>
#include "list.hpp"
template <class T>
class Queue
{
private:
List<T> q;
public:
T operator[](int i)
{
return q[i];
}
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