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. More...
 
size_t capacity () const noexcept
 Returns the number of allocated elements. More...
 
bool empty () const noexcept
 Checks whether the container is empty. More...
 
T * push_back () noexcept
 Adds an element to the end and initializes it with the default constructor. 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...
 
void swap (Nqueue &rhs) noexcept
 Swaps the container. More...
 
Basic Member Functions
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). This function is useful when using C++11.
 
Nqueueoperator= (Nqueue &&rhs) noexcept
 Move assignment operator. This function is useful when using C++11.
 
 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 65 of file Nqueue.h.

◆ empty()

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

Checks whether the container is empty.

Returns
Returns true if empty.

Definition at line 66 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 71 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 157 of file Nqueue.h.

◆ push_back()

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. Returns NULL on failure due to insufficient memory.

Definition at line 102 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 75 of file Nqueue.h.

◆ size()

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

Returns the number of stored elements.

Returns
The number of elements.

Definition at line 64 of file Nqueue.h.

◆ swap()

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

Swaps the container.

Deprecated:
This function will be deleted in a future release.

Definition at line 83 of file Nqueue.h.


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