Library 3

container & iterator.hpp
This commit is contained in:
Alessandro Ferro
2021-04-24 18:39:57 +02:00
parent 31bf18d985
commit 0d599672c4
16 changed files with 1240 additions and 506 deletions

View File

@@ -14,382 +14,313 @@ namespace lasd {
/* ************************************************************************** */
class Container {
private:
// ...
protected:
// ...
ulong size = 0;
public:
// Destructor
// ~Container() specifiers
/* ************************************************************************ */
virtual ~Container() = default;
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
Container& operator=(const Container&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
Container& operator=(Container&&) noexcept = delete;; // Move assignment of abstract types should not be possible.
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types might not be possible.
// type operator!=(argument) specifiers; // Comparison of abstract types might not be possible.
bool operator==(const Container&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const Container&&) const noexcept = delete; // Comparison of abstract types might not be possible.
// Specific member functions
virtual bool Empty() const noexcept {
return (size == 0);
} // (concrete function should not throw exceptions)
virtual ulong Size() const noexcept {
return size;
} // (concrete function should not throw exceptions)
virtual void Clear() = 0;
};
template <typename Data>
class LinearContainer : virtual public Container{ // Must extend Container
private:
protected:
public:
// Destructor
virtual ~LinearContainer() = default;
// Copy assignment
LinearContainer& operator=(const LinearContainer&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
LinearContainer& operator=(LinearContainer&&) noexcept = delete; // Move assignment of abstract types should not be possible.
// Comparison operators
bool operator==(const LinearContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const LinearContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
virtual Data& Front() const = 0; // (concrete function must throw std::length_error when empty)
virtual Data& Back() const = 0; // (concrete function must throw std::length_error when empty)
// type Empty() specifiers; // (concrete function should not throw exceptions)
virtual Data& operator[](const ulong) const = 0; // (concrete function must throw std::out_of_range when out of range)
// type Size() specifiers; // (concrete function should not throw exceptions)
};
// type Clear() specifiers;
template <typename Data>
class TestableContainer : virtual public Container{ // Must extend Container
private:
protected:
public:
// Destructor
virtual ~TestableContainer() = default;
// Copy assignment
TestableContainer& operator=(const TestableContainer&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
TestableContainer& operator=(TestableContainer&&) noexcept = delete; // Move assignment of abstract types should not be possible.
// Comparison operators
bool operator==(const TestableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const TestableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
virtual bool Exists(const Data&) const noexcept = 0; // (concrete function should not throw exceptions)
};
template <typename Data>
class MappableContainer : virtual public Container { // Must extend Container
private:
protected:
public:
// Destructor
virtual ~MappableContainer() = default;
// Copy assignment
MappableContainer& operator=(const MappableContainer&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
MappableContainer& operator=(MappableContainer&&) noexcept = delete; // Move assignment of abstract types should not be possible.
// Comparison operators
bool operator==(const MappableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const MappableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
// Specific member functions
typedef std::function<void(Data&, void*)> MapFunctor;
virtual void MapPreOrder(const MapFunctor, void*) = 0;
virtual void MapPostOrder(const MapFunctor, void*) = 0;
};
template <typename Data>
class FoldableContainer : virtual public TestableContainer<Data>{ // Must extend TestableContainer
private:
protected:
public:
// Destructor
virtual ~FoldableContainer() = default;
// Copy assignment
FoldableContainer& operator=(const FoldableContainer&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
FoldableContainer& operator=(FoldableContainer&&) noexcept = delete; // Move assignment of abstract types should not be possible.
// Comparison operators
bool operator==(FoldableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(FoldableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
// Specific member functions
typedef std::function<void(const Data&, const void*, void*) noexcept> FoldFunctor;
virtual void FoldPreOrder(const FoldFunctor, const void*, void*) const = 0;
virtual void FoldPostOrder(const FoldFunctor, const void*, void*) const = 0;
virtual bool Exists(const Data&) const noexcept override; // Override TestableContainer member
};
/* ************************************************************************** */
template <typename Data>
class LinearContainer { // Must extend Container
class InOrderMappableContainer : virtual public MappableContainer<Data> { // Must extend MappableContainer
private:
// ...
protected:
// ...
public:
// Destructor
// ~LinearContainer() specifiers
virtual ~InOrderMappableContainer() = default;
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
InOrderMappableContainer& operator=(const InOrderMappableContainer&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
InOrderMappableContainer& operator=(InOrderMappableContainer&&) noexcept = delete; // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types is possible.
// type operator!=(argument) specifiers; // Comparison of abstract types is possible.
bool operator==(const InOrderMappableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const InOrderMappableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
// type Front() specifiers; // (concrete function must throw std::length_error when empty)
// type Back() specifiers; // (concrete function must throw std::length_error when empty)
using typename MappableContainer<Data>::MapFunctor;
// type operator[](argument) specifiers; // (concrete function must throw std::out_of_range when out of range)
virtual void MapInOrder(const MapFunctor, void*) = 0;
};
/* ************************************************************************** */
template <typename Data>
class TestableContainer { // Must extend Container
class InOrderFoldableContainer : public virtual FoldableContainer<Data> { // Must extend FoldableContainer
private:
// ...
protected:
// ...
public:
// Destructor
// ~TestableContainer() specifiers
virtual ~InOrderFoldableContainer() = default;
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
InOrderFoldableContainer& operator=(const InOrderFoldableContainer&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
InOrderFoldableContainer operator=(InOrderFoldableContainer&&) noexcept = delete; // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types might not be possible.
// type operator!=(argument) specifiers; // Comparison of abstract types might not be possible.
bool operator==(const InOrderFoldableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const InOrderFoldableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
// type Exists(argument) specifiers; // (concrete function should not throw exceptions)
using typename MappableContainer<Data>::MapFunctor;
virtual void FoldInOrder(const MapFunctor, const void*, void*) const = 0;
};
/* ************************************************************************** */
template <typename Data>
class MappableContainer { // Must extend Container
class BreadthMappableContainer : virtual public MappableContainer<Data> { // Must extend MappableContainer
private:
// ...
protected:
// ...
public:
// Destructor
// ~MappableContainer() specifiers
~BreadthMappableContainer() = default;
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
BreadthMappableContainer& operator=(const BreadthMappableContainer&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
BreadthMappableContainer& operator=(BreadthMappableContainer&&) noexcept = delete; // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types might not be possible.
// type operator!=(argument) specifiers; // Comparison of abstract types might not be possible.
bool operator==(const BreadthMappableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const BreadthMappableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
// typedef std::function<void(Data&, void*)> MapFunctor;
using typename MappableContainer<Data>::MapFunctor;
// type MapPreOrder(arguments) specifiers;
// type MapPostOrder(arguments) specifiers;
void MapBreadth(const MapFunctor, void*) = 0;
};
/* ************************************************************************** */
template <typename Data>
class FoldableContainer { // Must extend TestableContainer
class BreadthFoldableContainer : virtual public FoldableContainer<Data> { // Must extend FoldableContainer
private:
// ...
protected:
// ...
public:
// Destructor
// ~FoldableContainer() specifiers
virtual ~BreadthFoldableContainer() = default;
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
BreadthFoldableContainer& operator=(const BreadthFoldableContainer&) = delete; // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
BreadthFoldableContainer& operator=(BreadthFoldableContainer&&) noexcept = delete; // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types might not be possible.
// type operator!=(argument) specifiers; // Comparison of abstract types might not be possible.
bool operator==(const BreadthFoldableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const BreadthFoldableContainer&) const noexcept = delete; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
// typedef std::function<void(const Data&, const void*, void*) noexcept> FoldFunctor;
using typename FoldableContainer<Data>::FoldFunctor;
// type FoldPreOrder(arguments) specifiers;
// type FoldPostOrder(arguments) specifiers;
// type Exists(argument) specifiers; // Override TestableContainer member
};
/* ************************************************************************** */
template <typename Data>
class InOrderMappableContainer { // Must extend MappableContainer
private:
// ...
protected:
// ...
public:
// Destructor
// ~InOrderMappableContainer() specifiers
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types might not be possible.
// type operator!=(argument) specifiers; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
// using typename MappableContainer<Data>::MapFunctor;
// type MapInOrder(arguments) specifiers;
};
/* ************************************************************************** */
template <typename Data>
class InOrderFoldableContainer { // Must extend FoldableContainer
private:
// ...
protected:
// ...
public:
// Destructor
// ~InOrderFoldableContainer() specifiers
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types might not be possible.
// type operator!=(argument) specifiers; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
// using typename MappableContainer<Data>::MapFunctor;
// type FoldInOrder(arguments) specifiers;
};
/* ************************************************************************** */
template <typename Data>
class BreadthMappableContainer { // Must extend MappableContainer
private:
// ...
protected:
// ...
public:
// Destructor
// ~BreadthMappableContainer() specifiers
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types might not be possible.
// type operator!=(argument) specifiers; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
// using typename MappableContainer<Data>::MapFunctor;
// type MapBreadth(arguments) specifiers;
};
/* ************************************************************************** */
template <typename Data>
class BreadthFoldableContainer { // Must extend FoldableContainer
private:
// ...
protected:
// ...
public:
// Destructor
// ~BreadthFoldableContainer() specifiers
/* ************************************************************************ */
// Copy assignment
// type operator=(argument); // Copy assignment of abstract types should not be possible.
// Move assignment
// type operator=(argument); // Move assignment of abstract types should not be possible.
/* ************************************************************************ */
// Comparison operators
// type operator==(argument) specifiers; // Comparison of abstract types might not be possible.
// type operator!=(argument) specifiers; // Comparison of abstract types might not be possible.
/* ************************************************************************ */
// Specific member functions
// using typename FoldableContainer<Data>::FoldFunctor;
// type FoldBreadth(arguments) specifiers;
virtual void FoldBreadth(const FoldFunctor, const void*, void*) const = 0;
};