ex01
This commit is contained in:
52
ex01/Span/Span.hpp
Normal file
52
ex01/Span/Span.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Span.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/04/21 10:29:07 by aortigos #+# #+# */
|
||||
/* Updated: 2026/04/21 10:29:07 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SPAN_HPP
|
||||
# define SPAN_HPP
|
||||
|
||||
# include <iostream>
|
||||
# include <vector>
|
||||
# include <algorithm>
|
||||
# include <stdexcept>
|
||||
# include <climits>
|
||||
|
||||
class Span
|
||||
{
|
||||
private:
|
||||
std::vector<int> data;
|
||||
unsigned int n;
|
||||
public:
|
||||
Span();
|
||||
Span(const Span &other);
|
||||
Span& operator=(const Span &other);
|
||||
~Span();
|
||||
|
||||
Span(unsigned int n);
|
||||
|
||||
void addNumber(int nb);
|
||||
|
||||
int shortestSpan();
|
||||
int longestSpan();
|
||||
|
||||
template <typename iter>
|
||||
void addNumbers(iter it, iter itt)
|
||||
{
|
||||
while (it != itt)
|
||||
{
|
||||
this->data.push_back(*it);
|
||||
// std::cout << "addNumbers: adding " << *it << std::endl;
|
||||
it++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user