nlib
nn::nlib::Nqueue< T, AL > Class Template Referencefinal

A container-like class similar to std::queue that can store objects that do not have copy constructors. More...

#include "nn/nlib/Nqueue.h"

Public Member Functions

size_t size () const noexcept
 Returns the number of stored elements.
 
size_t capacity () const noexcept
 Returns the number of allocated elements. More...
 
bool empty () const noexcept
 Returns true if the number of stored elements is 0, or returns false otherwise.
 
T * push_back () noexcept
 Adds an element to the end and initializes it with the default constructor. More...
 
T * push_back (T &&rhs) noexcept
 Moves a temporary object rhs and adds it to the end. More...
 
bool pop_front () noexcept
 Removes the first element from the front of the queue. More...
 
bool push_back_swap (T *v) noexcept
 Adds an element to the queue, and then swaps that element with v using std:: swap. More...
 
bool pop_front_swap (T *v) noexcept
 Uses std::swap to store the first element in v and then takes the first element from the queue. More...
 
Constructor, Destructor, and Initialization
constexpr Nqueue () noexcept
 Instantiates the object with default parameters (default constructor). Creates an empty queue.
 
 ~Nqueue () noexcept
 Destructor.
 
 Nqueue (Nqueue &&rhs) noexcept
 Instantiates the object (move constructor).
 
Nqueueoperator= (Nqueue &&rhs) noexcept
 Move assignment operator.
 
 Nqueue (Nqueue &rhs, move_tag) noexcept
 Corresponds to a move constructor.
 
Nqueueassign (Nqueue &rhs, move_tag) noexcept
 Corresponds to a move assignment operator.
 

Detailed Description

template<class T, class AL = std::allocator<char>>
class nn::nlib::Nqueue< T, AL >

A container-like class similar to std::queue that can store objects that do not have copy constructors.

Template Parameters
TElement type.
ALThe allocator type. The default is std::allocator<char>.
Description
Implemented internally using Nlist<T>.

Definition at line 30 of file Nqueue.h.

Member Function Documentation

◆ capacity()

template<class T , class AL = std::allocator<char>>
nn::nlib::Nqueue< T, AL >::capacity ( ) const
inlinenoexcept

Returns the number of allocated elements.

Returns
The number of elements.

Definition at line 69 of file Nqueue.h.

◆ pop_front()

template<class T , class AL = std::allocator<char>>
nn::nlib::Nqueue< T, AL >::pop_front ( )
inlinenoexcept

Removes the first element from the front of the queue.

Returns
Returns true if it succeeds, and false if the queue is empty.

Definition at line 75 of file Nqueue.h.

◆ pop_front_swap()

template<class T , class AL >
bool nn::nlib::Nqueue< T, AL >::pop_front_swap ( T *  v)
noexcept

Uses std::swap to store the first element in v and then takes the first element from the queue.

Parameters
[out]vThe pointer to where the first element in the queue is stored.
Returns
Returns true if it succeeds, and false if the queue is empty.

Definition at line 153 of file Nqueue.h.

◆ push_back() [1/2]

template<class T , class AL >
T * nn::nlib::Nqueue< T, AL >::push_back ( void  )
noexcept

Adds an element to the end and initializes it with the default constructor.

Returns
Returns the pointer to the added element. NULL if process fails.

Definition at line 98 of file Nqueue.h.

◆ push_back() [2/2]

template<class T , class AL >
T * nn::nlib::Nqueue< T, AL >::push_back ( T &&  rhs)
noexcept

Moves a temporary object rhs and adds it to the end.

Parameters
[in]rhsThe element to be added to the end.
Returns
Returns the pointer to the added element. NULL if process fails.

Definition at line 122 of file Nqueue.h.

◆ push_back_swap()

template<class T , class AL = std::allocator<char>>
nn::nlib::Nqueue< T, AL >::push_back_swap ( T *  v)
inlinenoexcept

Adds an element to the queue, and then swaps that element with v using std:: swap.

Parameters
[out]vThe pointer to the element to add to the end of the queue.
Returns
Returns true if successful. Returns false on failure due to insufficient memory.

Definition at line 79 of file Nqueue.h.


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