lasd/librerie/exercise2/queue/lst/queuelst.hpp

91 lines
2.5 KiB
C++
Raw Normal View History

2021-04-10 13:34:50 +02:00
#ifndef QUEUELST_HPP
#define QUEUELST_HPP
/* ************************************************************************** */
#include "../queue.hpp"
#include "../../list/list.hpp"
/* ************************************************************************** */
namespace lasd {
/* ************************************************************************** */
template <typename Data>
2021-04-14 08:42:18 +02:00
class QueueLst : virtual public Queue<Data>,
virtual protected List<Data>{ // Must extend Queue<Data> and List<Data>
2021-04-10 13:34:50 +02:00
private:
protected:
2021-04-14 08:42:18 +02:00
using List<Data>::head;
using List<Data>::tail;
using List<Data>::size;
using typename List<Data>::Node;
2021-04-10 13:34:50 +02:00
public:
// Default constructor
2021-04-14 08:42:18 +02:00
QueueLst() = default;
2021-04-10 13:34:50 +02:00
/* ************************************************************************ */
// Specific constructor
2021-04-14 08:42:18 +02:00
QueueLst(const LinearContainer<Data>&); // A queue obtained from a LinearContainer
2021-04-10 13:34:50 +02:00
/* ************************************************************************ */
// Copy constructor
2021-04-14 08:42:18 +02:00
QueueLst(const QueueLst&);
2021-04-10 13:34:50 +02:00
// Move constructor
2021-04-14 08:42:18 +02:00
QueueLst(QueueLst&&) noexcept;
2021-04-10 13:34:50 +02:00
/* ************************************************************************ */
// Destructor
2021-04-14 08:42:18 +02:00
~QueueLst();
2021-04-10 13:34:50 +02:00
/* ************************************************************************ */
// Copy assignment
2021-04-14 08:42:18 +02:00
QueueLst& operator=(const QueueLst&);
2021-04-10 13:34:50 +02:00
// Move assignment
2021-04-14 08:42:18 +02:00
QueueLst& operator=(QueueLst&&) noexcept;
2021-04-10 13:34:50 +02:00
/* ************************************************************************ */
// Comparison operators
2021-04-14 08:42:18 +02:00
bool operator==(const QueueLst&) const noexcept;
bool operator!=(const QueueLst&) const noexcept;
2021-04-10 13:34:50 +02:00
/* ************************************************************************ */
// Specific member functions (inherited from Queue)
2021-04-14 08:42:18 +02:00
void Enqueue(const Data&) override; // Override Queue member (copy of the value)
void Enqueue(Data&&) override; // Override Queue member (move of the value)
Data& Head() const override; // Override Queue member (must throw std::length_error when empty)
void Dequeue() override; // Override Queue member (must throw std::length_error when empty)
Data HeadNDequeue() override; // Override Queue member (must throw std::length_error when empty)
2021-04-10 13:34:50 +02:00
/* ************************************************************************ */
// Specific member functions (inherited from Container)
2021-04-14 08:42:18 +02:00
void Clear() override; // Override Container member
2021-04-10 13:34:50 +02:00
};
/* ************************************************************************** */
}
#include "queuelst.cpp"
#endif