GCSIM
Public Member Functions | Private Types | Private Attributes | List of all members
queue< T > Class Template Reference

implementation of the queue. More...

#include <queue.hpp>

Public Member Functions

 queue ()
 creates the instance of the queue.
 
 ~queue ()
 deletes the instance of the queue.
 
 queue (const queue &)=delete
 deleted copy constructor.
 
queueoperator= (const queue &)=delete
 deleted assignment operator.
 
 queue (queue &&other) noexcept
 creates the instance of the queue from an existing queue.
 
queueoperator= (queue &&other) noexcept
 assigns the instance of the queue from an existing queue.
 
template<typename TT >
requires std::is_constructible_v<T, TT&&>
void push (TT &&value)
 enqueues an element at the end of the queue.
 
pop ()
 pops the element from the front of the queue.
 
T & front ()
 peeks at the front element.
 
const T & front () const
 peeks at the front element.
 
bool empty () const noexcept
 checks if the queue is empty.
 
size_t get_size () const noexcept
 getter for the size of the queue.
 
void clear ()
 clears all elements from the queue.
 

Private Types

using queue_entry = queue_entry< T >
 

Private Attributes

queue_entryhead
 pointer to the front of the queue.
 
queue_entrytail
 pointer to the back of the queue.
 
size_t size
 size of the queue.
 

Detailed Description

template<typename T>
class queue< T >

implementation of the queue.

Template Parameters
T- type of the elements in the queue.

Member Typedef Documentation

◆ queue_entry

template<typename T >
using queue< T >::queue_entry = queue_entry<T>
private

Constructor & Destructor Documentation

◆ queue() [1/3]

template<typename T >
queue< T >::queue ( )
inline

creates the instance of the queue.

◆ ~queue()

template<typename T >
queue< T >::~queue ( )
inline

deletes the instance of the queue.

frees all the elements from the queue.

◆ queue() [2/3]

template<typename T >
queue< T >::queue ( const queue< T > &  )
delete

deleted copy constructor.

◆ queue() [3/3]

template<typename T >
queue< T >::queue ( queue< T > &&  other)
inlinenoexcept

creates the instance of the queue from an existing queue.

Parameters
other- rvalue of the existing queue.

Member Function Documentation

◆ clear()

template<typename T >
void queue< T >::clear ( )
inline

clears all elements from the queue.

◆ empty()

template<typename T >
bool queue< T >::empty ( ) const
inlinenoexcept

checks if the queue is empty.

Returns
true if queue is empty, false otherwise.

◆ front() [1/2]

template<typename T >
T & queue< T >::front ( )
inline

peeks at the front element.

Returns
reference to the front element.
Exceptions
std::out_of_rangeif queue is empty.

◆ front() [2/2]

template<typename T >
const T & queue< T >::front ( ) const
inline

peeks at the front element.

Returns
const reference to the front element.
Exceptions
std::out_of_rangeif queue is empty.

◆ get_size()

template<typename T >
size_t queue< T >::get_size ( ) const
inlinenoexcept

getter for the size of the queue.

Returns
size of the queue.

◆ operator=() [1/2]

template<typename T >
queue & queue< T >::operator= ( const queue< T > &  )
delete

deleted assignment operator.

◆ operator=() [2/2]

template<typename T >
queue & queue< T >::operator= ( queue< T > &&  other)
inlinenoexcept

assigns the instance of the queue from an existing queue.

Parameters
other- rvalue of the existing queue.

◆ pop()

template<typename T >
T queue< T >::pop ( )
inline

pops the element from the front of the queue.

Returns
T - the value of the popped element.
Exceptions
std::out_of_rangeif queue is empty.

◆ push()

template<typename T >
template<typename TT >
requires std::is_constructible_v<T, TT&&>
void queue< T >::push ( TT &&  value)
inline

enqueues an element at the end of the queue.

Template Parameters
TT- type of the element.
Parameters
value- value of the element.

Member Data Documentation

◆ head

template<typename T >
queue_entry* queue< T >::head
private

pointer to the front of the queue.

◆ size

template<typename T >
size_t queue< T >::size
private

size of the queue.

◆ tail

template<typename T >
queue_entry* queue< T >::tail
private

pointer to the back of the queue.


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