CPP08 1.0
|
A class that stores up to N integers and calculates the shortest and longest spans. [詳解]
#include <Span.hpp>
クラス | |
class | NotEnoughNumbersException |
An exception thrown when there are insufficient numbers to calculate the span. [詳解] | |
class | SpanFullException |
Exception thrown when Span is full. [詳解] | |
公開メンバ関数 | |
Span (unsigned int N) | |
Constructs a Span object. | |
Span (const Span &other) | |
Copy constructor. | |
Span & | operator= (Span other) |
Assignment operator (copy-and-swap idiom). | |
~Span () | |
Destructor. | |
void | swap (Span &other) |
Swaps the contents of two Span objects. | |
void | addNumber (int number) |
Adds a single number to the span. | |
template<typename InputIterator > | |
void | addNumber (InputIterator first, InputIterator last) |
Adds multiple numbers specifying the iterator range. | |
int | shortestSpan () |
Calculates the shortest span between stored numbers. | |
int | longestSpan () |
Calculates the longest span between stored numbers. | |
A class that stores up to N integers and calculates the shortest and longest spans.
Span refers to the difference between any two numbers in the stored values.
|
explicit |
Span::Span | ( | const Span & | other | ) |
|
inline |
Adds multiple numbers specifying the iterator range.
InputIterator | Input iterator type. |
first | Iterator indicating the start of the range. |
last | Iterator indicating the end of the range. |
SpanFullException | Thrown when capacity is insufficient. |
void Span::addNumber | ( | int | number | ) |
Adds a single number to the span.
number | The integer to be added. |
SpanFullException | Thrown when the span is full. |
int Span::longestSpan | ( | ) |
Calculates the longest span between stored numbers.
NotEnoughNumbersException | Thrown when there are less than two numbers. |
int Span::shortestSpan | ( | ) |
Calculates the shortest span between stored numbers.
NotEnoughNumbersException | Thrown when there are less than two numbers. |
void Span::swap | ( | Span & | other | ) |