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

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.
 
Basic Member Functions
 Nqueue () noexcept
 Instantiates the object with default parameters (default constructor). Creates an empty queue.
 
 ~Nqueue () noexcept
 Destructor.
 
Nqueueassign (Nqueue &rhs, move_tag)
 Assigns the object by using swap for a move.
 
 Nqueue (Nqueue &rhs, move_tag)
 Instantiates the object by using swap for a move.
 
 Nqueue (Nqueue &&rhs)
 Instantiates the object (move constructor). This function is useful when using C++11.
 
Nqueueoperator= (Nqueue &&rhs)
 Move assignment operator. This function is useful when using C++11.
 

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 36 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 37 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 42 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 128 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 73 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 46 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 35 of file Nqueue.h.


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