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/14 13:38:57 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #ifndef SPAN_HPP
  13. # define SPAN_HPP
  14. # include <iostream>
  15. # include <string>
  16. #include <vector>
  17. class Span
  18. {
  19. public:
  20. Span( unsigned int const & src );
  21. Span( Span const & src );
  22. ~Span();
  23. Span & operator=( Span const & rhs );
  24. class isFullException : public std::exception {
  25. public :
  26. virtual const char * what() const throw() {
  27. return ("The Span container is full");
  28. }
  29. };
  30. void addNumber(int const & add);
  31. unsigned int shortestSpan(void) const;
  32. unsigned int longestSpan(void) const;
  33. void fullFillSpan(void);
  34. void rangeFillSpan(size_t start, size_t end);
  35. void fillSpan(size_t n);
  36. unsigned int getSize(void) const;
  37. private:
  38. int *_value;
  39. unsigned int _max;
  40. unsigned int _size;
  41. Span();
  42. };
  43. std::ostream & operator<<( std::ostream & o, Span const & i );
  44. #endif /* ************************************************************ SPAN_H */