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:
69
librerie/exercise5/matrix/matrix.hpp
Normal file
69
librerie/exercise5/matrix/matrix.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
#ifndef MATRIX_HPP
|
||||
#define MATRIX_HPP
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../container/container.hpp"
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
namespace lasd {
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
template <typename Data>
|
||||
class Matrix : virtual public MappableContainer<Data>,
|
||||
virtual public FoldableContainer<Data>{ // Must extend MappableContainer<Data> and FoldableContainer<Data>
|
||||
|
||||
private:
|
||||
|
||||
protected:
|
||||
|
||||
//using MappableContainer<Data>::size;
|
||||
ulong rows = 0;
|
||||
ulong columns = 0;
|
||||
|
||||
public:
|
||||
|
||||
// Destructor
|
||||
virtual ~Matrix() = default;
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Copy assignment
|
||||
Matrix& operator=(const Matrix&) = delete; // Copy assignment of abstract types should not be possible.
|
||||
|
||||
// Move assignment
|
||||
Matrix& operator=(Matrix&&) noexcept = delete; // Move assignment of abstract types should not be possible.
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Comparison operators
|
||||
bool operator==(const Matrix&) const noexcept = delete; // Comparison of abstract types might not be possible.
|
||||
bool operator!=(const Matrix&) const noexcept = delete; // Comparison of abstract types might not be possible.
|
||||
|
||||
/* ************************************************************************ */
|
||||
|
||||
// Specific member functions
|
||||
|
||||
ulong RowNumber() noexcept; // (concrete function should not throw exceptions)
|
||||
ulong ColumnNumber() noexcept; // (concrete function should not throw exceptions)
|
||||
|
||||
virtual void RowResize(const ulong&) = 0;
|
||||
virtual void ColumnResize(const ulong&) = 0;
|
||||
|
||||
virtual bool ExistsCell(const ulong&, const ulong&) noexcept = 0; // (concrete function should not throw exceptions)
|
||||
|
||||
virtual Data& operator()(const ulong&, const ulong&) = 0; // Mutable access to the element (concrete function should throw exceptions only when out of range)
|
||||
virtual const Data& operator()(const ulong&, const ulong&) const = 0; // Immutable access to the element (concrete function should throw exceptions when not present)
|
||||
|
||||
};
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
}
|
||||
|
||||
#include "matrix.cpp"
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user