LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
lal::detail::queue_array< value_t > Class Template Reference

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

#include <queue_array.hpp>

Public Member Functions

void init (const std::size_t n) noexcept
 Initializes the queue to hold n elements.
 
void push (const value_t &v) noexcept
 Insert a new element to the queue.
 
void push (value_t &&v) noexcept
 Insert a new element to the queue.
 
value_t && pop () noexcept
 Pops the first element of the queue.
 
value_t & front () noexcept
 Returns a reference to the front element.
 
const value_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.
 
bool is_exhausted () const noexcept
 Has the queue exhausted its resources?
 
bool is_full () const noexcept
 Is the queue full?
 
value_t * begin () noexcept
 Pointer to begin.
 
const value_t * begin () const noexcept
 Constant pointer to begin.
 
value_t * end () noexcept
 Pointer to end.
 
const value_t * end () const noexcept
 Constant pointer to end.
 

Private Attributes

array< value_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<typename value_t>
class lal::detail::queue_array< value_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

  • at most n push operations can be done,
  • at most n pop operations can be done.

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
value_tType of the elements in the queue.

Member Function Documentation

◆ is_exhausted()

template<typename value_t >
bool lal::detail::queue_array< value_t >::is_exhausted ( ) const
inlinenodiscardnoexcept

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<typename value_t >
bool lal::detail::queue_array< value_t >::is_full ( ) const
inlinenodiscardnoexcept

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<typename value_t >
value_t && lal::detail::queue_array< value_t >::pop ( )
inlinenodiscardnoexcept

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<typename value_t >
void lal::detail::queue_array< value_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: