34 unsigned int _maxSize;
45 explicit Span(
unsigned int N);
85 template <
typename InputIterator>
void addNumber(InputIterator first, InputIterator last) {
87 if (
static_cast<unsigned long>(
std::distance(first, last)) + _numbers.
size() > _maxSize) {
91 _numbers.
insert(_numbers.
end(), first, last);
114 virtual const char *
what()
const throw() {
return "Span is full, cannot add more numbers."; }
123 virtual const char *
what()
const throw() {
return "Not enough numbers in Span to find a span."; }
An exception thrown when there are insufficient numbers to calculate the span.
virtual const char * what() const
Exception thrown when Span is full.
virtual const char * what() const
A class that stores up to N integers and calculates the shortest and longest spans.
void addNumber(InputIterator first, InputIterator last)
Adds multiple numbers specifying the iterator range.
void swap(Span &other)
Swaps the contents of two Span objects.
int shortestSpan()
Calculates the shortest span between stored numbers.
int longestSpan()
Calculates the longest span between stored numbers.
Span & operator=(Span other)
Assignment operator (copy-and-swap idiom).
void addNumber(int number)
Adds a single number to the span.