stdex Additional custom or not Standard C++ covered algorithms

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
stdex::vector_queue< T > Class Template Reference

Helper class to allow limited size FIFO queues implemented as vector of elements. More...

`#include <stdex/vector_queue.hpp>`

## Public Types
typedef size_t | size_type
| Type to measure element count and indices in.
typedef T | value_type
| Element type.
typedef T & | reference
| Reference to element type.
typedef const T & | const_reference
| Constant reference to element type.
typedef T * | pointer
| Pointer to element.
typedef const T * | const_pointer
| Constant pointer to element.

## Public Member Functions
| vector_queue (size_type size_max)
| Construct queue of fixed size.
| vector_queue (const vector_queue< value_type > &other)
| Copies existing queue.
virtual | ~vector_queue ()
| Destroys the queue.
| vector_queue (vector_queue< value_type > &&other)
| Moves existing queue.
vector_queue< value_type > & | operator= (const vector_queue< value_type > &other)
| Copies existing queue.
vector_queue< value_type > & | operator= (vector_queue< value_type > &&other)
| Moves existing queue.
size_type | size () const
| Returns the number of elements in the vector.
size_type | capacity () const
| Returns the number of elements that the queue can contain before overwriting head ones.
void | clear ()
| Erases the elements of the queue.
bool | empty () const
| Tests if the queue is empty.
reference | at (size_type pos)
| Returns a reference to the element at a specified location in the queue.
reference | operator[] (size_type pos)
| Returns a reference to the element at a specified location in the queue.
const_reference | at (size_type pos) const
| Returns a constant reference to the element at a specified location in the queue.
const_reference | operator[] (size_type pos) const
| Returns a constant reference to the element at a specified location in the queue.
reference | at_abs (size_type pos)
| Returns a reference to the element at the absolute location in the queue.
const_reference | at_abs (size_type pos) const
| Returns a constant reference to the element at the absolute location in the queue: measured from the beginning of the storage.
size_type | push_back (const value_type &v)
| Copies an existing element to the end of the queue, overriding the first one when queue is out of space.
size_type | push_back (value_type &&v)
| Moves the element to the end of the queue, overriding the first one when queue is out of space.
void | pop_back ()
| Removes (dequeues) the last element of the queue.
size_type | push_front (const value_type &v)
| Copies an existing element to the head of the queue, overriding the last one when queue is out of space and moving all others one place right.
size_type | push_front (value_type &&v)
| Moves the element to the head of the queue, overriding the last one when queue is out of space and moving all others one place right.
void | pop_front ()
| Removes (dequeues) the head element of the queue.
reference | front ()
| Returns a reference to the head element in the queue.
const_reference | front () const
| Returns a constant reference to the head element in the queue.
reference | back ()
| Returns a reference to the last element in the queue.
const_reference | back () const
| Returns a constant reference to the last element in the queue.
size_type | head () const
| Returns absolute subscript or position number of the head element in the queue. The element does not need to exist.
size_type | tail () const
| Returns absolute subscript or position number of the last element in the queue. The element must exist.
size_type | abs (size_type pos) const
| Returns absolute subscript or position number of the given element in the queue.

## Protected Attributes
value_type * | m_data
| Underlying data container.
size_type | m_head
| Index of the first element.
size_type | m_count
| Number of elements.
size_type | m_size_max
| Maximum size.

## Detailed Description

template<class T>
class stdex::vector_queue< T >

Helper class to allow limited size FIFO queues implemented as vector of elements.

## Constructor & Destructor Documentation

## ◆ vector_queue() [1/3]

template<class T >

stdex::vector_queue< T >::vector_queue | ( | size_type | size_max | ) |
| inline

Construct queue of fixed size.

Parameters

  [in] | size_max | Maximum number of elements. Please note this cannot be changed later.

## ◆ vector_queue() [2/3]

template<class T >

stdex::vector_queue< T >::vector_queue | ( | const vector_queue< value_type > & | other | ) |
| inline

Copies existing queue.

Parameters

  [in] | other | Queue to copy from

## ◆ vector_queue() [3/3]

template<class T >

stdex::vector_queue< T >::vector_queue | ( | vector_queue< value_type > && | other | ) |
| inline

Moves existing queue.

Parameters

  [in,out] | other | Queue to move

## Member Function Documentation

## ◆ at() [1/2]

template<class T >

reference stdex::vector_queue< T >::at | ( | size_type | pos | ) |
| inline

Returns a reference to the element at a specified location in the queue.

Parameters

  [in] | pos | The subscript or position number of the element to reference in the queue.

## ◆ at() [2/2]

template<class T >

const_reference stdex::vector_queue< T >::at | ( | size_type | pos | ) | const
| inline

Returns a constant reference to the element at a specified location in the queue.

Parameters

  [in] | pos | The subscript or position number of the element to reference in the queue.

## ◆ at_abs() [1/2]

template<class T >

reference stdex::vector_queue< T >::at_abs | ( | size_type | pos | ) |
| inline

Returns a reference to the element at the absolute location in the queue.

Note
  Absolute means "measured from the beginning of the storage".

Parameters

  [in] | pos | The absolute subscript or position number of the element to reference in the queue.

## ◆ at_abs() [2/2]

template<class T >

const_reference stdex::vector_queue< T >::at_abs | ( | size_type | pos | ) | const
| inline

Returns a constant reference to the element at the absolute location in the queue: measured from the beginning of the storage.

Note
  Absolute means "measured from the beginning of the storage".

Parameters

  [in] | pos | The absolute subscript or position number of the element to reference in the queue.

## ◆ operator=() [1/2]

template<class T >

vector_queue< value_type > & stdex::vector_queue< T >::operator= | ( | const vector_queue< value_type > & | other | ) |
| inline

Copies existing queue.

Parameters

  [in] | other | Queue to copy from

## ◆ operator=() [2/2]

template<class T >

vector_queue< value_type > & stdex::vector_queue< T >::operator= | ( | vector_queue< value_type > && | other | ) |
| inline

Moves existing queue.

Parameters

  [in,out] | other | Queue to move

## ◆ operator[]() [1/2]

template<class T >

reference stdex::vector_queue< T >::operator[] | ( | size_type | pos | ) |
| inline

Returns a reference to the element at a specified location in the queue.

Parameters

  [in] | pos | The subscript or position number of the element to reference in the queue.

## ◆ operator[]() [2/2]

template<class T >

const_reference stdex::vector_queue< T >::operator[] | ( | size_type | pos | ) | const
| inline

Returns a constant reference to the element at a specified location in the queue.

Parameters

  [in] | pos | The subscript or position number of the element to reference in the queue.

## ◆ push_back() [1/2]

template<class T >

size_type stdex::vector_queue< T >::push_back | ( | const value_type & | v | ) |
| inline

Copies an existing element to the end of the queue, overriding the first one when queue is out of space.

Parameters

  [in] | v | Element to copy to the end of the queue.

Returns
  The absolute subscript or position number the element was copied to.

## ◆ push_back() [2/2]

template<class T >

size_type stdex::vector_queue< T >::push_back | ( | value_type && | v | ) |
| inline

Moves the element to the end of the queue, overriding the first one when queue is out of space.

Parameters

  [in] | v | Element to move to the end of the queue.

Returns
  The absolute subscript or position number the element was moved to.

## ◆ push_front() [1/2]

template<class T >

size_type stdex::vector_queue< T >::push_front | ( | const value_type & | v | ) |
| inline

Copies an existing element to the head of the queue, overriding the last one when queue is out of space and moving all others one place right.

Parameters

  [in] | v | Element to copy to the head of the queue.

Returns
  The absolute subscript or position number the element was copied to.

## ◆ push_front() [2/2]

template<class T >

size_type stdex::vector_queue< T >::push_front | ( | value_type && | v | ) |
| inline

Moves the element to the head of the queue, overriding the last one when queue is out of space and moving all others one place right.

Parameters

  [in] | v | Element to move to the head of the queue.

Returns
  The absolute subscript or position number the element was moved to.

The documentation for this class was generated from the following file:

- include/stdex/vector_queue.hpp