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

104 lines
2.8 KiB
C++
Executable File

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