feat(08 ex01): adding the multiple numbers in single call
This commit is contained in:
parent
59e5b448f2
commit
eb1cebe50b
2 changed files with 33 additions and 2 deletions
|
|
@ -40,6 +40,21 @@ Span::~Span() {
|
|||
std::cout << CLR_MAGENTA << "[Span] Destructor called" << CLR_RESET << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add a number at the end of the vector
|
||||
*
|
||||
* @param number the number to add
|
||||
*/
|
||||
void Span::addNumbers(std::vector<int>::iterator start, std::vector<int>::iterator end) {
|
||||
size_t count = std::distance(start, end);
|
||||
if (_max < _size + count) {
|
||||
throw std::out_of_range("Span is full");
|
||||
}
|
||||
_size += count;
|
||||
|
||||
_vec.insert(_vec.end(), start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add a number at the end of the vector
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue