2021-04-10 13:34:50 +02:00
|
|
|
|
|
|
|
#ifndef QUEUE_HPP
|
|
|
|
#define QUEUE_HPP
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#include "../container/container.hpp"
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
namespace lasd {
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
template <typename Data>
|
2021-04-14 08:42:18 +02:00
|
|
|
class Queue : virtual public Container{ // Must extend Container
|
2021-04-10 13:34:50 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Destructor
|
2021-04-14 08:42:18 +02:00
|
|
|
~Queue() = default;
|
2021-04-10 13:34:50 +02:00
|
|
|
|
|
|
|
/* ************************************************************************ */
|
|
|
|
|
|
|
|
// Copy assignment
|
2021-04-14 08:42:18 +02:00
|
|
|
Queue& operator=(const Queue&) = delete; // Copy assignment of abstract types should not be possible.
|
2021-04-10 13:34:50 +02:00
|
|
|
|
|
|
|
// Move assignment
|
2021-04-14 08:42:18 +02:00
|
|
|
Queue& operator=(Queue&&) = delete; // Move assignment of abstract types should not be possible.
|
2021-04-10 13:34:50 +02:00
|
|
|
|
|
|
|
/* ************************************************************************ */
|
|
|
|
|
|
|
|
// Comparison operators
|
2021-04-14 08:42:18 +02:00
|
|
|
bool operator==(const Queue&) const noexcept = delete; // Comparison of abstract types might not be possible.
|
|
|
|
bool operator!=(const Queue&) const noexcept = delete; // Comparison of abstract types might not be possible.
|
2021-04-10 13:34:50 +02:00
|
|
|
|
|
|
|
/* ************************************************************************ */
|
|
|
|
|
|
|
|
// Specific member functions
|
|
|
|
|
2021-04-14 08:42:18 +02:00
|
|
|
virtual void Enqueue(const Data&) = 0; // Copy of the value
|
|
|
|
virtual void Enqueue(Data&&) = 0; // Move of the value
|
|
|
|
virtual Data& Head() const = 0; // (concrete function must throw std::length_error when empty)
|
|
|
|
virtual void Dequeue() = 0; // (concrete function must throw std::length_error when empty)
|
|
|
|
virtual Data HeadNDequeue() = 0; // (concrete function must throw std::length_error when empty)
|
2021-04-10 13:34:50 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|