2021-05-25 22:19:44 +02:00
|
|
|
|
|
|
|
#ifndef VECTOR_HPP
|
|
|
|
#define VECTOR_HPP
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#include "../container/container.hpp"
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
namespace lasd {
|
|
|
|
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
template <typename Data>
|
|
|
|
class Vector : virtual public LinearContainer<Data>,
|
|
|
|
virtual public MappableContainer<Data>,
|
|
|
|
virtual public FoldableContainer<Data>{ // Must extend LinearContainer<Data>, MappableContainer<Data>, and FoldableContainer<Data>
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
using LinearContainer<Data>::size;
|
|
|
|
Data* Elements = nullptr;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Vector() = default;
|
|
|
|
|
|
|
|
// Specific constructors
|
|
|
|
Vector(const ulong); // A vector with a given initial dimension
|
|
|
|
Vector(const LinearContainer<Data>&); // A vector obtained from a LinearContainer
|
|
|
|
|
|
|
|
// Copy constructor
|
|
|
|
Vector(const Vector&);
|
|
|
|
|
|
|
|
// Move constructor
|
|
|
|
Vector(Vector&&)noexcept;
|
|
|
|
|
|
|
|
// Destructor
|
2021-05-25 23:06:28 +02:00
|
|
|
virtual ~Vector();
|
2021-05-25 22:19:44 +02:00
|
|
|
|
|
|
|
// Copy assignment
|
|
|
|
Vector& operator=(const Vector&);
|
|
|
|
|
|
|
|
// Move assignment
|
|
|
|
Vector& operator=(Vector&&) noexcept;
|
|
|
|
|
|
|
|
// Comparison operators
|
|
|
|
bool operator==(const Vector&) const noexcept;
|
|
|
|
bool operator!=(const Vector&) const noexcept;
|
|
|
|
|
|
|
|
void Resize(const ulong); // Resize the vector to a given size
|
|
|
|
|
|
|
|
void Clear() override; // Override Container member
|
|
|
|
|
|
|
|
Data& Front() const override; // Override LinearContainer member (must throw std::length_error when empty)
|
|
|
|
Data& Back() const override; // Override LinearContainer member (must throw std::length_error when empty)
|
|
|
|
|
|
|
|
Data& operator[](const ulong) const override; // Override LinearContainer member (must throw std::out_of_range when out of range)
|
|
|
|
|
|
|
|
using typename MappableContainer<Data>::MapFunctor;
|
|
|
|
|
|
|
|
void MapPreOrder(const MapFunctor, void*) override; // Override MappableContainer member
|
|
|
|
void MapPostOrder(const MapFunctor, void*) override; // Override MappableContainer member
|
|
|
|
|
|
|
|
using typename FoldableContainer<Data>::FoldFunctor;
|
|
|
|
|
|
|
|
void FoldPreOrder(const FoldFunctor, const void*, void*) const override; // Override FoldableContainer member
|
|
|
|
void FoldPostOrder(const FoldFunctor, const void*, void*) const override; // Override FoldableContainer member
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "vector.cpp"
|
|
|
|
|
|
|
|
#endif
|