A C++ template library for embedded applications
Designed and maintained by
Aster Consulting Ltd

vector

A fixed capacity vector.
STL equivalent: std::vector

etl::vector<typename T, const size_t SIZE>

Inherits from etl::ivector<T>
etl::ivector may be used as a size independent pointer or reference type for any etl::vector instance.

The size of the instance will be (SIZE * sizeof(T)) + (2 * sizeof(size_t)) + sizeof(T*)
For a 32 bit environment the overhead (compared to an array) will usually be 12 bytes.

Member types

value_type              T
size_type               std::size_t
difference_type         std::ptrdiff_t
reference               value_type&
const_reference         const value_type&
pointer                 value_type*
const_pointer           const value_type*
iterator                Random access iterator
const_iterator          Constant random access iterator
reverse_iterator        std::reverse_iterator<iterator>
const_reverse_iterator  std::reverse_iterator<const_iterator>

Constructor

etl::vector<typename T, const size_t SIZE>();
etl::vector<typename T, const size_t SIZE>(size_t initialSize);
etl::vector<typename T, const size_t SIZE>(size_t initialSize, parameter_t value);
template <typename TIterator>
etl::vector<typename T, const size_t SIZE>(TIterator begin, TIterator end);

Element access

T& at(size_t i)
const T& at(size_t i) const
Returns a reference or const reference to the indexed element. Emits an etl::vector_out_of_range if the index is out of
range of the array.

T& operator[](size_t i)
const T& operator[](size_t i) const
Returns a reference or const reference to the indexed element.

T& front()
const T& front() const
Returns a reference or const reference to the first element.

T& back()
const T& back() const
Returns a reference or const reference to the last element.

T* data()
const T* data() const
Returns a pointer or const pointer to the internal buffer.

Iterators

iterator begin()
const_iterator begin() const
const_iterator cbegin() const
Returns an iterator to the beginning of the vector.

iterator end()
const_iterator end() const
const_iterator cend() const
Returns an iterator to the end of the vector.

iterator rbegin()
const_reverse_iterator rbegin() const
const_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning of the vector.

iterator rend()
const_reverse_iterator rend() const
const_reverse_iterator crend() const
Returns a reverse iterator to the end of the vector.


Capacity

bool empty() const
Returns true if the size of the vector is zero, otherwise false.

bool full() const
Returns true if the size of the vector is SIZE, otherwise false.

size_t size() const
Returns the size of the vector.

void resize(size_t new_size, T value - T())
Resizes the vector, up to the maximum capacity. Emits an etl::vector_full if the vector does not have the capacity.

size_t max_size() const
Returns the maximum possible size of the vector.

size_t capacity() const
Returns the maximum possible size of the vector.

size_t available() const
Returns the remaining available capacity in the vector.

Modifiers

template <typename TIterator>
void assign(TIterator begin, TIterator end);
void assign(size_t n, parameter_t value);
Fills the vector with the values. Emits etl::vector_iterator if the distance between begin and end is illegal.

void push_back(parameter_t value);
void push_back();
Pushes a value to the back of the vector. The first pushes a value, the second allocates the new element but does not
initialise it.
If the vector is full then emits an etl::vector_full.

void pop_back();
Pop a value from the back of the vector.

template <typename TIterator>
void insert(iterator position, TIterator begin, TIterator end);
iterator insert(iterator position, parameter_t value);
void insert(iterator position, size_t n, parameter_t value);
Inserts values in to the vector. If the vector is full then emits an etl::vector_full exception.

template <typename TIterator>
iterator erase(TIterator begin, TIterator end);
iterator erase(iterator position);
Erases values in the vector.

void clear();
Clears the vector to a size of zero.

Non-member functions

==  true if the contents of the vectors are equal, otherwise false.
!=  true if the contents of the vectors are not equal, otherwise false.
<   true if the contents of the lhs are lexicographically less than the contents of the rhs,  otherwise false.
<=  true if the contents of the lhs are lexicographically less than or equal to the contents of the rhs, otherwise false.
>   true if the contents of the lhs are lexicographically greater than the contents of the rhs,  otherwise false.
>=  true if the contents of the lhs are lexicographically greater than or equal to the contents of the rhs, otherwise
false.

vector.h