48 lines
941 B
C++
48 lines
941 B
C++
#pragma once
|
|
|
|
#include <exception>
|
|
#include <iterator>
|
|
#include <vector>
|
|
|
|
class Span
|
|
{
|
|
public:
|
|
Span() = delete;
|
|
Span(unsigned int size);
|
|
Span(const Span &other);
|
|
Span(Span &&other) noexcept;
|
|
Span &operator=(const Span &other);
|
|
Span &operator=(Span &&other) noexcept;
|
|
~Span() noexcept;
|
|
|
|
void addNumber(int number);
|
|
|
|
unsigned int shortestSpan() const;
|
|
unsigned int longestSpan() const;
|
|
|
|
template <typename Iterator>
|
|
void addRange(Iterator begin, Iterator end)
|
|
{
|
|
for (Iterator it = begin; it != end; ++it)
|
|
{
|
|
addNumber(*it);
|
|
}
|
|
}
|
|
|
|
class OutOfSpaceException : public std::exception
|
|
{
|
|
public:
|
|
const char *what() const throw();
|
|
};
|
|
|
|
class NoSpanFoundException : public std::exception
|
|
{
|
|
public:
|
|
const char *what() const throw();
|
|
};
|
|
|
|
private:
|
|
unsigned int _size;
|
|
std::vector<int> _data;
|
|
};
|