Template Class sequence#

Class Documentation#

template<class T, size_t nFixedSize = 0>
class sequence#

Managed sequence class.

Sequence management class. A sequence provides a dynamic vector based on a buffer implementation of the ptr-class. There are two versions of buffer management, fixed buffer management (nFixedSize template parameter larger than 0) and dynamic buffer management (nFixedSize template parameter is 0). The functions of this class are similar to the functions of the std::vector class.

Template Parameters:
  • T – Type to use for the buffer allocation.

  • nFixedSize – Size of the fixed size buffer or 0 for a dynamic sized buffer.

Public Types

using value_type = T#

Value type for this sequence class.

using iterator = internal::index_iterator<sequence<T, nFixedSize>, false, false>#

Forward iterator class used by this sequence class.

using reverse_iterator = internal::index_iterator<sequence<T, nFixedSize>, false, true>#

Backward iterator class used by this sequence class.

using const_iterator = internal::index_iterator<sequence<T, nFixedSize>, true, false>#

Const forward iterator class used by this sequence class.

using const_reverse_iterator = internal::index_iterator<sequence<T, nFixedSize>, true, true>#

Const backward iterator class used by this sequence class.

using reference = T&#

Reference type of the element.

using const_reference = const T&#

Const reference type of the element.

Public Functions

sequence() noexcept#

Default constructor.

~sequence()#

Destructor.

sequence(size_t nCount, const T &rtValue)#

Construct a sequence with a certain amount of values.

Parameters:
  • nCount[in] The amount of values to create.

  • rtValue[in] Reference to the value to use for the initialization.

explicit sequence(size_t nCount)#

Construct a sequence with a certain amount of values.

Parameters:

nCount[in] The amount of values to create.

template<class TIterator>
sequence(TIterator itFirst, TIterator itLast)#

Construct a sequence from a range of values accessible through iterators.

Template Parameters:

TIterator – Type of iterator.

Parameters:
  • itFirst[in] The iterator pointing to the itFirst value.

  • itLast[in] The iterator pointing to the value past the itLast value.

sequence(const sequence &rseq)#

Copy constructor of same sequence type.

Parameters:

rseq[in] Reference to the sequence containing the values to copy.

template<size_t nFixedSize2>
sequence(const sequence<T, nFixedSize2> &rseq)#

Copy constructor of other sequence types.

Template Parameters:

nFixedSize2 – The fixed size of the provided sequence.

Parameters:

rseq[in] Reference to the sequence containing the values to copy.

sequence(sequence &&rseq) noexcept#

Move constructor of same sequence type.

Parameters:

rseq[in] Reference to the sequence to move the values from.

template<size_t nFixedSize2>
sequence(sequence<T, nFixedSize2> &&rseq) noexcept#

Move constructor of other sequence types.

Template Parameters:

nFixedSize2 – The fixed size of the provided sequence.

Parameters:

rseq[in] Reference to the sequence to move the values from.

sequence(std::vector<T> &rvec)#

Construct a sequence from a vector.

Parameters:

rvec[in] Reference to the sequence.

sequence(std::initializer_list<T> ilist)#

Construct a sequence from an initializer list.

Parameters:

ilist[in] Initializer list.

sequence &operator=(const sequence &rseq)#

Assignment operator of same sequence type.

Parameters:

rseq[in] Reference to the sequence.

Returns:

Reference to this sequence.

template<size_t nFixedSize2>
sequence &operator=(const sequence<T, nFixedSize2> &rseq)#

Assignment operator of other sequence types.

Template Parameters:

nFixedSize2 – The fixed size of the provided sequence.

Parameters:

rseq[in] Reference to the sequence.

Returns:

Reference to this sequence.

sequence &operator=(sequence &&rseq) noexcept#

Move operator of same sequence type.

Parameters:

rseq[in] Reference to the sequence.

Returns:

Reference to this sequence.

template<size_t nFixedSize2>
sequence &operator=(sequence<T, nFixedSize2> &&rseq) noexcept#

Move operator of other sequence types.

Template Parameters:

nFixedSize2 – The fixed size of the provided sequence.

Parameters:

rseq[in] Reference to the sequence.

Returns:

Reference to this sequence.

sequence &operator=(const std::vector<T> &rvec)#

Assignment operator for vector.

Parameters:

rvec[in] Reference to the vector.

Returns:

Reference to this sequence.

sequence &operator=(std::initializer_list<T> ilist)#

Assignment operator for initializer list.

Parameters:

ilist[in] Initializer list.

Returns:

Reference to this sequence.

void assign(size_t nCount, const T &rtValue)#

Assign an amount of values to the sequence replacing the values existing before.

Parameters:
  • nCount[in] Amount of values to assign.

  • rtValue[in] Reference to the value to assign.

template<class TIterator>
void assign(TIterator itFirst, TIterator itLast)#

Assign an amount of values pointed to by itFirst and itLast iterators replacing the values existing before.

Template Parameters:

TIterator – Type of iterator.

Parameters:
  • itFirst[in] The iterator pointing to the itFirst value.

  • itLast[in] The iterator pointing to the value past the itLast value.

void assign(std::initializer_list<T> ilist)#

Assign the values from an initializer list.

Parameters:

ilist[in] Initializer list.

reference at(size_t nPos)#

Return a reference to the value at the specified position.

Parameters:

nPos[in] The specified position.

Returns:

Reference to the value.

const_reference at(size_t nPos) const#

Return a reference to the value at the specified position.

Parameters:

nPos[in] The specified position.

Returns:

Reference to the value.

reference operator[](size_t nPos)#

Return a reference to the value at the specified position.

Parameters:

nPos[in] The specified position.

Returns:

Reference to the value.

const_reference operator[](size_t nPos) const#

Return a reference to the value at the specified position.

Parameters:

nPos[in] The specified position.

Returns:

Reference to the value.

T &front()#

Return a reference to the itFirst value.

Returns:

Reference to the value.

const T &front() const#

Return a reference to the itFirst value.

Returns:

Reference to the value.

T &back()#

Return a reference to the itLast value.

Returns:

Reference to the value.

const T &back() const#

Return a reference to the itLast value.

Returns:

Reference to the value.

operator std::vector<T>() const#

Cast operator for C++ vector.

Returns:

Returns a C++ vector object containing a copy of the sequence.

const T *data() const noexcept#

Access to the underlying data.

Returns:

Pointer to the data.

pointer<T, nFixedSize> &buffer() noexcept#

Access to the buffer.

Returns:

Return a reference to the internal buffer.

iterator begin() noexcept#

Return an iterator to the itFirst value of the sequence.

Returns:

Iterator to the itFirst value of te sequence.

const_iterator begin() const noexcept#

Return an iterator to the itFirst value of the sequence.

Returns:

Iterator to the itFirst value of te sequence.

const_iterator cbegin() const noexcept#

Return a const iterator to the itFirst value of the sequence.

Returns:

Const iterator to the itFirst value of te sequence.

reverse_iterator rbegin() noexcept#

Return a reverse-iterator to the itLast value of the sequence.

Returns:

Reverse iterator to the itLast value of te sequence.

const_reverse_iterator rbegin() const noexcept#

Return a reverse-iterator to the itLast value of the sequence.

Returns:

Reverse iterator to the itLast value of te sequence.

const_reverse_iterator crbegin() const noexcept#

Return a const reverse iterator to the itLast value of the sequence.

Returns:

Const reverse iterator to the itLast value of te sequence.

iterator end() noexcept#

Return an iterator beyond the itLast value of the sequence.

Returns:

Iterator beyond the itLast value of te sequence.

const_iterator end() const noexcept#

Return an iterator beyond the itLast value of the sequence.

Returns:

Iterator beyond the itLast value of te sequence.

const_iterator cend() const noexcept#

Return a const beyond the itLast value of the sequence.

Returns:

Const iterator beyond the itLast value of te sequence.

reverse_iterator rend() noexcept#

Return a reverse iterator before the itFirst value of the sequence.

Returns:

Reverse iterator before the itLast value of te sequence.

const_reverse_iterator rend() const noexcept#

Return a reverse iterator before the itFirst value of the sequence.

Returns:

Reverse iterator before the itLast value of te sequence.

const_reverse_iterator crend() const noexcept#

Return a const reverse iterator before the itFirst value of the sequence.

Returns:

Const reverse iterator before the itLast value of te sequence.

bool empty() const#

Is the sequence empty?

Returns:

Returns ‘true’ when the sequence is empty; ‘false’ when not.

size_t size() const#

Get the size of the sequence.

Remark

The length and the size for the sequence are equal.

Returns:

The size of the sequence buffer.

size_t length() const#

Get the length of the sequence.

Remark

The length and the size for the sequence are equal.

Returns:

The length of the sequence.

void reserve(size_t nNewCap = 0)#

Reserve capacity for the sequence buffer. Additional buffer will be filled with zeros.

Remark

Reducing the capacity will have no effect.

Parameters:

nNewCap[in] The new capacity.

size_t capacity() const noexcept#

Get the current sequence capacity.

Remark

This will be the same as the length and size of the sequence.

Returns:

The capacity of the current sequence.

void shrink_to_fit()#

Reduce the buffer to fit the sequence.

Remark

This function will have no effect.

void clear()#

Clear the sequence.

iterator insert(const_iterator itPos, const T &rtValue)#

Insert a value rtValue at the position itPos.

Parameters:
  • itPos[in] Iterator pointing to the position to insert the value.

  • rtValue[in] Reference to the value to insert.

Returns:

The iterator pointing to the inserted value.

iterator insert(const_iterator itPos, T &&rtValue)#

Insert a value rtValue at the position itPos.

Parameters:
  • itPos[in] Iterator pointing to the position to insert the value.

  • rtValue[in] Reference to the value to insert.

Returns:

The iterator pointing to the inserted value.

iterator insert(const_iterator itPos, size_t nCount, const T &rtValue)#

Insert an amount of values rtValue at the position itPos.

Parameters:
  • itPos[in] Iterator pointing to the position to insert the value.

  • nCount[in] The amount of values to insert.

  • rtValue[in] Reference to the value to insert.

Returns:

The iterator pointing to the itFirst inserted value.

template<class TIterator>
iterator insert(const_iterator itPos, TIterator itFirst, TIterator itLast)#

Insert a range of vvalues identified by the supplied iterators.

Template Parameters:

TIterator – Iterator type to use.

Parameters:
  • itPos[in] Iterator pointing to the position to insert the value.

  • itFirst[in] The iterator pointing to the itFirst value.

  • itLast[in] The iterator pointing to the value past the itLast value.

Returns:

The iterator pointing to the itFirst inserted value.

iterator insert(const_iterator itPos, std::initializer_list<T> ilist)#

Insert an initializer list at the position itPos.

Parameters:
  • itPos[in] Iterator pointing to the position to insert the value.

  • ilist[in] Initializer list.

Returns:

The iterator pointing to the itFirst inserted value.

iterator erase(iterator itPos)#

Remove a value at the provided position.

Remark

The iterator must point to this sequence.

Parameters:

itPos[in] Iterator pointing to the position to erase the value from.

Returns:

Iterator to the value following the erase value or end() when no more values are available.

iterator erase(const_iterator itPos)#

Remove a value at the provided position.

Remark

The iterator must point to this sequence.

Parameters:

itPos[in] Iterator pointing to the position to erase the value from.

Returns:

Iterator to the value following the erase value or end() when no more values are available.

iterator erase(iterator itFirst, iterator itLast)#

Remove al values starting at itFirst until but not including itLast.

Remark

Both iterators must point to this sequence.

Parameters:
  • itFirst[in] The iterator pointing to the itFirst value.

  • itLast[in] The iterator pointing to the value past the itLast value.

Returns:

Iterator to the value following the erased values or end() when no more values are available.

iterator erase(const_iterator itFirst, const_iterator itLast)#

Remove al values starting at itFirst until but not including itLast.

Remark

Both iterators must point to this sequence.

Parameters:
  • itFirst[in] The iterator pointing to the itFirst value.

  • itLast[in] The iterator pointing to the value past the itLast value.

Returns:

Iterator to the value following the erased values or end() when no more values are available.

void push_back(const T &rtValue)#

Appends the given value to the end of the sequence.

Parameters:

rtValue[in] Reference to the value to append.

void push_back(T &&rtValue)#

Appends the given value to the end of the sequence.

Parameters:

rtValue[in] Reference to the value to append.

void pop_back()#

Removes the itLast value from the sequence.

void resize(size_t nCount)#

Set the new size of the sequence.

Parameters:

nCount[in] The size of the sequence buffer.

void resize(size_t nCount, const value_type &rtValue)#

Set the new size of the sequence. Additional values will be filled with rtValue.

Parameters:
  • nCount[in] The size of the sequence buffer.

  • rtValue[in] Reference to the value to use for initialization.

template<size_t nFixedSize2>
void swap(sequence<T, nFixedSize2> &rseq) noexcept#

Exchange the content of provided sequence with this sequence.

Template Parameters:

nFixedSize2 – The fixed size of the provided sequence.

Parameters:

rseq[in] Reference to the sequence to swap with.