LAL: Linear Arrangement Library 23.01.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
lal::detail::linear_queue< T > Class Template Reference

Simple array-like fixed-size queue. More...

#include <linear_queue.hpp>

Public Member Functions

void init (std::size_t n) noexcept
 Initializes the queue to hold n elements.
 
void push (const T &v) noexcept
 Insert a new element to the queue.
 
void push (T &&v) noexcept
 Insert a new element to the queue.
 
T && pop () noexcept
 Pops the first element of the queue. More...
 
T & front () noexcept
 Returns a reference to the front element.
 
const T & front () const noexcept
 Returns a constant reference to the front element.
 
std::size_t size () const noexcept
 Returns the size of the queue.
 
void reset () noexcept
 Makes the queue usable again. More...
 
bool is_exhausted () const noexcept
 Has the queue exhausted its resources? More...
 
bool is_full () const noexcept
 Is the queue full? More...
 
T * begin () noexcept
 Pointer to begin.
 
const T * begin () const noexcept
 Constant pointer to begin.
 
T * end () noexcept
 Pointer to end.
 
const T * end () const noexcept
 Constant pointer to end.
 

Private Attributes

data_array< T > m_queue
 Data (array) of the queue.
 
std::size_t m_left
 Left pointer to m_queue.
 
std::size_t m_right
 Right pointer to m_queue.
 

Detailed Description

template<class T>
class lal::detail::linear_queue< T >

Simple array-like fixed-size queue.

This class implements functionalities similar to those of std::queue. This queue, however, can hold only at most a given, fixed amount of elements. If the size of the queue is n, then

Once the n push operations have been done, the queue has exhausted its resources (see is_exhausted) and must be reset (see reset).

Template Parameters
TType of the elements in the queue.

Member Function Documentation

◆ is_exhausted()

template<class T >
bool lal::detail::linear_queue< T >::is_exhausted ( ) const
inlinenoexcept

Has the queue exhausted its resources?

The queue has exhausted its resources if n pop operations have been performed. This happens when m_left is equal to the queue size.

Returns
A Boolean value (true or false).

◆ is_full()

template<class T >
bool lal::detail::linear_queue< T >::is_full ( ) const
inlinenoexcept

Is the queue full?

The queue is full if n push operations have been performed. This happens when m_right is equal to the queue size.

Returns
A Boolean value (true or false).

◆ pop()

template<class T >
T && lal::detail::linear_queue< T >::pop ( )
inlinenoexcept

Pops the first element of the queue.

Returns
A copy of the first element.
Postcondition
The size of the queue is reduced by one.
Pointer m_left is updated.

◆ reset()

template<class T >
void lal::detail::linear_queue< T >::reset ( )
inlinenoexcept

Makes the queue usable again.

Memory is not reset, freed, or deallocated.

Postcondition
Pointers m_left and m_right are set to 0.

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