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/ex8/queue.hpp

45 lines
572 B
C++
Raw Normal View History

2021-11-19 02:26:57 +00:00
#ifndef _QUEUE_HPP_
#define _QUEUE_HPP_
2021-11-18 12:44:57 +00:00
#include <iostream>
#include "list.hpp"
template <class T>
class Queue
{
private:
List<T> q;
public:
2021-11-18 12:54:44 +00:00
T operator[](int i)
{
return q[i];
}
2021-11-18 12:44:57 +00:00
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