mirror of
https://github.com/xfarrow/lasd.git
synced 2025-06-05 21:49:14 +02:00
Library 5
- Added template - Matrix & MatrixVec completed
This commit is contained in:
89
librerie/exercise5/stack/lst/stacklst.hpp
Executable file
89
librerie/exercise5/stack/lst/stacklst.hpp
Executable file
@ -0,0 +1,89 @@
|
||||
|
||||
#ifndef STACKLST_HPP
|
||||
#define STACKLST_HPP
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../stack.hpp"
|
||||
#include "../../list/list.hpp"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
namespace lasd {
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
template <typename Data>
|
||||
class StackLst : virtual public Stack<Data>,
|
||||
virtual protected List<Data> { // Must extend Stack<Data> and List<Data>
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
using List<Data>::head;
|
||||
using List<Data>::size;
|
||||
using typename List<Data>::Node;
|
||||
|
||||
public:
|
||||
|
||||
// Default constructor
|
||||
StackLst() = default;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Specific constructor
|
||||
StackLst(const LinearContainer<Data>&); // A stack obtained from a LinearContainer
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Copy constructor
|
||||
StackLst(const StackLst&);
|
||||
|
||||
// Move constructor
|
||||
StackLst(StackLst&&) noexcept;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Destructor
|
||||
virtual ~StackLst();
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Copy assignment
|
||||
StackLst& operator=(const StackLst&);
|
||||
|
||||
// Move assignment
|
||||
StackLst& operator=(StackLst&&) noexcept;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Comparison operators
|
||||
bool operator==(const StackLst&) const noexcept;
|
||||
bool operator!=(const StackLst&) const noexcept;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Specific member functions (inherited from Stack)
|
||||
|
||||
void Push(const Data&) override; // Override Stack member (copy of the value)
|
||||
void Push(Data&&) noexcept override; // Override Stack member (move of the value)
|
||||
Data& Top() const override; // Override Stack member (must throw std::length_error when empty)
|
||||
void Pop() override; // Override Stack member (must throw std::length_error when empty)
|
||||
Data TopNPop() override; // Override Stack member (must throw std::length_error when empty)
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Specific member functions (inherited from Container)
|
||||
|
||||
void Clear() override; // Override Container member
|
||||
|
||||
};
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
}
|
||||
|
||||
#include "stacklst.cpp"
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user