#include <bn_vector.h>
template<typename Type>
bn::ivector class

Base class of vector.

Template parameters
Type Element type.

Can be used as a reference type for all vector containers containing a specific type.

Derived classes

template<typename Type, int MaxSize>
class vector
Vector implementation that uses a fixed size buffer.

Public types

using value_type = Type
Value type alias.
using size_type = int
Size type alias.
using difference_type = int
Difference type alias.
using reference = Type&
Reference alias.
using const_reference = const Type&
Const reference alias.
using pointer = Type*
Pointer alias.
using const_pointer = const Type*
Const pointer alias.
using iterator = Type*
Iterator alias.
using const_iterator = const Type*
Const iterator alias.
using reverse_iterator = bn::reverse_iterator<iterator>
Reverse iterator alias.
using const_reverse_iterator = bn::reverse_iterator<const_iterator>
Const reverse iterator alias.

Public functions

auto operator=(const ivector& other) -> ivector&
Copy assignment operator.
auto operator=(ivector&& other) -> ivector& noexcept
Move assignment operator.
auto data() const -> const_pointer
Returns a const pointer to the beginning of the ivector data.
auto data() -> pointer
Returns a pointer to the beginning of the ivector data.
auto size() const -> size_type
Returns the current elements count.
auto max_size() const -> size_type
Returns the maximum possible elements count.
auto available() const -> size_type
Returns the remaining element capacity.
auto empty() const -> bool
Indicates if it doesn't contain any element.
auto full() const -> bool
Indicates if it can't contain any more elements.
auto begin() const -> const_iterator
Returns a const iterator to the beginning of the ivector.
auto begin() -> iterator
Returns an iterator to the beginning of the ivector.
auto end() const -> const_iterator
Returns a const iterator to the end of the ivector.
auto end() -> iterator
Returns an iterator to the end of the ivector.
auto cbegin() const -> const_iterator
Returns a const iterator to the beginning of the ivector.
auto cend() const -> const_iterator
Returns a const iterator to the end of the ivector.
auto rbegin() const -> const_reverse_iterator
Returns a const reverse iterator to the end of the ivector.
auto rbegin() -> reverse_iterator
Returns a reverse iterator to the end of the ivector.
auto rend() const -> const_reverse_iterator
Returns a const reverse iterator to the beginning of the ivector.
auto rend() -> reverse_iterator
Returns a reverse iterator to the beginning of the ivector.
auto crbegin() const -> const_reverse_iterator
Returns a const reverse iterator to the end of the ivector.
auto crend() const -> const_reverse_iterator
Returns a const reverse iterator to the beginning of the ivector.
auto operator[](size_type index) const -> const_reference
Returns a const reference to the value stored at the specified index.
auto operator[](size_type index) -> reference
Returns a reference to the value stored at the specified index.
auto at(size_type index) const -> const_reference
Returns a const reference to the value stored at the specified index.
auto at(size_type index) -> reference
Returns a reference to the value stored at the specified index.
auto front() const -> const_reference
Returns a const reference to the first element.
auto front() -> reference
Returns a reference to the first element.
auto back() const -> const_reference
Returns a const reference to the last element.
auto back() -> reference
Returns a reference to the last element.
void push_back(const_reference value)
Inserts a copy of a value at the end of the ivector.
void push_back(value_type&& value)
Inserts a moved value at the end of the ivector.
template<typename... Args>
auto emplace_back(Args && ... args) -> reference
Constructs and inserts a value at the end of the ivector.
void pop_back()
Removes the last element of the ivector.
auto insert(const_iterator position, const_reference value) -> iterator
Inserts a copy of a value at the specified position.
auto insert(const_iterator position, value_type&& value) -> iterator
Inserts a moved value at the specified position.
template<typename... Args>
auto emplace(const_iterator position, Args && ... args) -> iterator
Constructs and inserts a value at the specified position.
auto erase(const_iterator position) -> iterator
Erases an element.
auto erase(const_iterator first, const_iterator last) -> iterator
Erases a range of elements.
void resize(size_type count)
Resizes the ivector.
void resize(size_type count, const_reference value)
Resizes the ivector.
void shrink(size_type count)
Resizes the ivector to a size less or equal than the previous one.
void assign(size_type count, const_reference value)
Assigns values to the ivector, removing the previous ones.
template<typename Iterator>
void assign(const Iterator& first, const Iterator& last)
Assigns values to the ivector, removing the previous ones.
void clear()
Removes all elements.
void clear()
Removes all elements.
void swap(ivector& other)
Exchanges the contents of this ivector with those of the other one.

Friends

auto erase(ivector& vector, const_reference value) -> size_type
Erases all elements that are equal to the specified value.
template<class Pred>
auto erase_if(ivector& vector, const Pred& pred) -> size_type
Erases all elements that satisfy the specified predicate.
void swap(ivector& a, ivector& b)
Exchanges the contents of a ivector with those of another one.
auto operator==(const ivector& a, const ivector& b) -> bool
Equal operator.
auto operator!=(const ivector& a, const ivector& b) -> bool
Not equal operator.
auto operator<(const ivector& a, const ivector& b) -> bool
Less than operator.
auto operator>(const ivector& a, const ivector& b) -> bool
Greater than operator.
auto operator<=(const ivector& a, const ivector& b) -> bool
Less than or equal operator.
auto operator>=(const ivector& a, const ivector& b) -> bool
Greater than or equal operator.

Function documentation

template<typename Type>
ivector& bn::ivector<Type>::operator=(const ivector& other)

Copy assignment operator.

Parameters
other ivector to copy.
Returns Reference to this.

template<typename Type>
ivector& bn::ivector<Type>::operator=(ivector&& other) noexcept

Move assignment operator.

Parameters
other ivector to move.
Returns Reference to this.

template<typename Type>
void bn::ivector<Type>::push_back(const_reference value)

Inserts a copy of a value at the end of the ivector.

Parameters
value Value to insert.

template<typename Type>
void bn::ivector<Type>::push_back(value_type&& value)

Inserts a moved value at the end of the ivector.

Parameters
value Value to insert.

template<typename Type> template<typename... Args>
reference bn::ivector<Type>::emplace_back(Args && ... args)

Constructs and inserts a value at the end of the ivector.

Parameters
args Parameters of the value to insert.
Returns Reference to the new value.

template<typename Type>
iterator bn::ivector<Type>::insert(const_iterator position, const_reference value)

Inserts a copy of a value at the specified position.

Parameters
position The given value is inserted before this position.
value Value to insert.
Returns Iterator pointing to the inserted value.

template<typename Type>
iterator bn::ivector<Type>::insert(const_iterator position, value_type&& value)

Inserts a moved value at the specified position.

Parameters
position The given value is inserted before this position.
value Value to insert.
Returns Iterator pointing to the inserted value.

template<typename Type> template<typename... Args>
iterator bn::ivector<Type>::emplace(const_iterator position, Args && ... args)

Constructs and inserts a value at the specified position.

Parameters
position The new value is inserted before this position.
args Parameters of the value to insert.
Returns Iterator pointing to the new value.

template<typename Type>
iterator bn::ivector<Type>::erase(const_iterator position)

Erases an element.

Parameters
position Iterator to the element to erase.
Returns Iterator following the erased element.

template<typename Type>
iterator bn::ivector<Type>::erase(const_iterator first, const_iterator last)

Erases a range of elements.

Parameters
first Iterator to the first element to erase.
last Iterator to the last element to erase.
Returns Iterator following the last erased element.

The range includes all the elements between first and last, including the element pointed by first, but not the one pointed by last.

template<typename Type>
void bn::ivector<Type>::resize(size_type count)

Resizes the ivector.

Parameters
count New size.

template<typename Type>
void bn::ivector<Type>::resize(size_type count, const_reference value)

Resizes the ivector.

Parameters
count New size.
value Value to fill new elements with.

template<typename Type>
void bn::ivector<Type>::shrink(size_type count)

Resizes the ivector to a size less or equal than the previous one.

Parameters
count New size.

template<typename Type>
void bn::ivector<Type>::assign(size_type count, const_reference value)

Assigns values to the ivector, removing the previous ones.

Parameters
count Number of elements to insert.
value Value to fill new elements with.

template<typename Type> template<typename Iterator>
void bn::ivector<Type>::assign(const Iterator& first, const Iterator& last)

Assigns values to the ivector, removing the previous ones.

Parameters
first Iterator to the first element to insert.
last Iterator following to the last element to insert.

template<typename Type>
void bn::ivector<Type>::swap(ivector& other)

Exchanges the contents of this ivector with those of the other one.

Parameters
other ivector to exchange the contents with.

template<typename Type>
size_type erase(ivector& vector, const_reference value)

Erases all elements that are equal to the specified value.

Parameters
vector ivector from which to erase.
value Element to erase.
Returns Number of erased elements.

template<typename Type> template<class Pred>
size_type erase_if(ivector& vector, const Pred& pred)

Erases all elements that satisfy the specified predicate.

Parameters
vector ivector from which to erase.
pred Unary predicate which returns true if the element should be erased.
Returns Number of erased elements.

template<typename Type>
void swap(ivector& a, ivector& b)

Exchanges the contents of a ivector with those of another one.

Parameters
a First ivector to exchange the contents with.
b Second ivector to exchange the contents with.

template<typename Type>
bool operator==(const ivector& a, const ivector& b)

Equal operator.

Parameters
a First ivector to compare.
b Second ivector to compare.
Returns true if the first ivector is equal to the second one, otherwise false.

template<typename Type>
bool operator!=(const ivector& a, const ivector& b)

Not equal operator.

Parameters
a First ivector to compare.
b Second ivector to compare.
Returns true if the first ivector is not equal to the second one, otherwise false.

template<typename Type>
bool operator<(const ivector& a, const ivector& b)

Less than operator.

Parameters
a First ivector to compare.
b Second ivector to compare.
Returns true if the first ivector is lexicographically less than the second one, otherwise false.

template<typename Type>
bool operator>(const ivector& a, const ivector& b)

Greater than operator.

Parameters
a First ivector to compare.
b Second ivector to compare.
Returns true if the first ivector is lexicographically greater than the second one, otherwise false.

template<typename Type>
bool operator<=(const ivector& a, const ivector& b)

Less than or equal operator.

Parameters
a First ivector to compare.
b Second ivector to compare.
Returns true if the first ivector is lexicographically less than or equal to the second one, otherwise false.

template<typename Type>
bool operator>=(const ivector& a, const ivector& b)

Greater than or equal operator.

Parameters
a First ivector to compare.
b Second ivector to compare.
Returns true if the first ivector is lexicographically greater than or equal to the second one, otherwise false.