42_CPP08/ex01/Span.cpp
2023-09-26 15:14:25 +02:00

44 lines
668 B
C++

#include "Span.hpp"
#include <bits/stdc++.h>
Span::Span()
{}
Span::Span(unsigned int N):
_size(N)
{
}
Span::Span(const Span& src)
{
*this = src;
}
Span::~Span()
{
}
Span& Span::operator=(const Span& src)
{
this->_size = src._size;
this->_vector = src._vector;
return *this;
}
int Span::shortestSpan() const
{
return *std::min_element(_vector.begin(), _vector.end());
}
int Span::longestSpan() const
{
return *std::max_element(_vector.begin(), _vector.end());
}
void Span::addNumber(const int nb)
{
if (this->_vector.size() == this->_size)
throw std::exception();
this->_vector[this->_size] = nb;
this->_size++;
}