lasd/librerie/exercise3/queue/vec/queuevec.hpp

104 lines
2.8 KiB
C++
Raw Normal View History

2021-04-24 16:58:05 +02:00
#ifndef QUEUEVEC_HPP
#define QUEUEVEC_HPP
/* ************************************************************************** */
#include "../queue.hpp"
#include "../../vector/vector.hpp"
/* ************************************************************************** */
namespace lasd {
/* ************************************************************************** */
template <typename Data>
2021-04-24 18:39:57 +02:00
class QueueVec : virtual public Queue<Data>,
virtual protected Vector<Data>{ // Must extend Queue<Data> and Vector<Data>
2021-04-24 16:58:05 +02:00
private:
protected:
2021-04-24 18:39:57 +02:00
using Vector<Data>::Elements;
using Vector<Data>::size; // dimension of the array
ulong front = 0;
ulong rear = 0;
2021-04-24 16:58:05 +02:00
public:
// Default constructor
2021-04-24 18:39:57 +02:00
QueueVec();
2021-04-24 16:58:05 +02:00
/* ************************************************************************ */
// Specific constructor
2021-04-24 18:39:57 +02:00
QueueVec(const LinearContainer<Data>&); // A queue obtained from a LinearContainer
2021-04-24 16:58:05 +02:00
/* ************************************************************************ */
// Copy constructor
2021-04-24 18:39:57 +02:00
QueueVec(const QueueVec&);
2021-04-24 16:58:05 +02:00
// Move constructor
2021-04-24 18:39:57 +02:00
QueueVec(QueueVec&&) noexcept;
2021-04-24 16:58:05 +02:00
/* ************************************************************************ */
// Destructor
2021-04-24 18:39:57 +02:00
virtual ~QueueVec();
2021-04-24 16:58:05 +02:00
/* ************************************************************************ */
// Copy assignment
2021-04-24 18:39:57 +02:00
QueueVec& operator=(const QueueVec&);
2021-04-24 16:58:05 +02:00
// Move assignment
2021-04-24 18:39:57 +02:00
QueueVec& operator=(QueueVec&&) noexcept;
2021-04-24 16:58:05 +02:00
/* ************************************************************************ */
// Comparison operators
2021-04-24 18:39:57 +02:00
bool operator==(const QueueVec&) const noexcept;
bool operator!=(const QueueVec&) const noexcept;
2021-04-24 16:58:05 +02:00
/* ************************************************************************ */
// Specific member functions (inherited from Queue)
2021-04-24 18:39:57 +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-24 16:58:05 +02:00
/* ************************************************************************ */
// Specific member functions (inherited from Container)
2021-04-24 18:39:57 +02:00
bool Empty() const noexcept override; // Override Container member
2021-04-24 16:58:05 +02:00
2021-04-24 18:39:57 +02:00
ulong Size() const noexcept override; // Override Container member
2021-04-24 16:58:05 +02:00
2021-04-24 18:39:57 +02:00
void Clear() override; // Override Container member
2021-04-24 16:58:05 +02:00
protected:
// Auxiliary member functions
2021-04-24 18:39:57 +02:00
void Expand();
void Reduce();
//void SwapVectors(arguments) specifiers;
2021-04-24 16:58:05 +02:00
};
/* ************************************************************************** */
}
#include "queuevec.cpp"
#endif