lasd/librerie/exercise4/iterator/iterator.hpp

172 lines
4.9 KiB
C++
Raw Normal View History

2021-05-11 06:51:06 +02:00
#ifndef ITERATOR_HPP
#define ITERATOR_HPP
/* ************************************************************************** */
namespace lasd {
/* ************************************************************************** */
template <typename Data>
class Iterator {
private:
protected:
public:
// Destructor
2021-05-11 06:52:44 +02:00
virtual ~Iterator() = default;
2021-05-11 06:51:06 +02:00
/* ************************************************************************ */
// Copy assignment
2021-05-11 06:52:44 +02:00
Iterator& operator=(const Iterator&) = delete; // Copy assignment of abstract types should not be possible.
2021-05-11 06:51:06 +02:00
// Move assignment
2021-05-11 06:52:44 +02:00
Iterator& operator=(Iterator&&) noexcept = delete; // Move assignment of abstract types should not be possible.
2021-05-11 06:51:06 +02:00
/* ************************************************************************ */
// Comparison operators
2021-05-11 06:52:44 +02:00
bool operator==(const Iterator&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const Iterator&) const noexcept = delete; // Comparison of abstract types might not be possible.
2021-05-11 06:51:06 +02:00
/* ************************************************************************ */
// Specific member functions
2021-05-11 06:52:44 +02:00
virtual Data& operator*() const = 0; // (concrete function must throw std::out_of_range when terminated)
2021-05-11 06:51:06 +02:00
2021-05-11 06:52:44 +02:00
virtual bool Terminated() const noexcept = 0; // (concrete function should not throw exceptions)
2021-05-11 06:51:06 +02:00
};
/* ************************************************************************** */
template <typename Data>
2021-05-11 06:52:44 +02:00
class ForwardIterator : virtual public Iterator<Data> { // Must extend Iterator
2021-05-11 06:51:06 +02:00
private:
protected:
public:
// Destructor
2021-05-11 06:52:44 +02:00
virtual ~ForwardIterator() = default;
2021-05-11 06:51:06 +02:00
/* ************************************************************************ */
// Copy assignment
2021-05-11 06:52:44 +02:00
ForwardIterator& operator=(const ForwardIterator&) = delete; // Copy assignment of abstract types should not be possible.
2021-05-11 06:51:06 +02:00
// Move assignment
2021-05-11 06:52:44 +02:00
ForwardIterator& operator=(ForwardIterator&&) noexcept = delete; // Move assignment of abstract types should not be possible.
2021-05-11 06:51:06 +02:00
/* ************************************************************************ */
// Comparison operators
2021-05-11 06:52:44 +02:00
bool operator==(const ForwardIterator&) const noexcept = delete; // Comparison of abstract types might not be possible.
bool operator!=(const ForwardIterator&) const noexcept = delete; // Comparison of abstract types might not be possible.
2021-05-11 06:51:06 +02:00
/* ************************************************************************ */
// Specific member functions
2021-05-11 06:52:44 +02:00
virtual void operator++() = 0; // (concrete function must throw std::out_of_range when terminated)
2021-05-11 06:51:06 +02:00
};
/* ************************************************************************** */
template <typename Data>
class BackwardIterator { // Must extend Iterator
private:
// ...
protected:
// ...
public:
// Destructor
// ~BackwardIterator() 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
// type operator--() specifiers; // (concrete function must throw std::out_of_range when terminated)
};
/* ************************************************************************** */
template <typename Data>
class BidirectionalIterator { // Must extend ForwardIterator and BackwardIterator
private:
// ...
protected:
// ...
public:
// Destructor
// ~BidirectionalIterator() 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
// type Terminated() specifiers; // Override Iterator member
// type ForwardTerminated() specifiers; // (concrete function should not throw exceptions)
// type BackwardTerminated() specifiers; // (concrete function should not throw exceptions)
};
/* ************************************************************************** */
}
#endif