Span.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* Span.hpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2026/01/13 18:18:53 by bchanot #+# #+# */
  9. /* Updated: 2026/01/16 14:56:20 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #ifndef SPAN_HPP
  13. # define SPAN_HPP
  14. # include <iostream>
  15. # include <string>
  16. #include <vector>
  17. #include <iterator>
  18. class Span
  19. {
  20. public:
  21. Span( unsigned int const & src );
  22. Span( Span const & src );
  23. ~Span();
  24. Span & operator=( Span const & rhs );
  25. class isFullException : public std::exception {
  26. public :
  27. virtual const char * what() const throw() {
  28. return ("The Span container is full");
  29. }
  30. };
  31. void addNumber(int const & add);
  32. unsigned int shortestSpan(void) const;
  33. unsigned int longestSpan(void) const;
  34. void fullFillSpan(void);
  35. void rangeFillSpan(size_t start, size_t end);
  36. void fillSpan(size_t n);
  37. unsigned int getSize(void) const;
  38. private:
  39. std::vector<int> _values;
  40. unsigned int _max;
  41. Span();
  42. };
  43. std::ostream & operator<<( std::ostream & o, Span const & i );
  44. #endif /* ************************************************************ SPAN_H */