Pigweed
C/C++ API Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
pw::DynamicQueue< T, SizeType > Class Template Reference
Inheritance diagram for pw::DynamicQueue< T, SizeType >:

Public Types

using const_iterator = typename Deque::const_iterator
 
using const_pointer = typename Deque::const_pointer
 
using const_reference = typename Deque::const_reference
 
using difference_type = typename Deque::difference_type
 
using iterator = typename Deque::iterator
 
using pointer = typename Deque::pointer
 
using reference = typename Deque::reference
 
using size_type = typename Deque::size_type
 
using value_type = typename Deque::value_type
 

Public Member Functions

constexpr DynamicQueue (pw::Allocator &allocator)
 Constructs a DynamicQueue using the provided allocator.
 
 DynamicQueue (const DynamicQueue &)=delete
 
DynamicQueueoperator= (const DynamicQueue &)=delete
 
constexpr DynamicQueue (DynamicQueue &&)=default
 Move operations are supported and incur no allocations.
 
DynamicQueueoperator= (DynamicQueue &&)=default
 
void clear ()
 Removes all elements from the queue.
 
bool try_push (const value_type &value)
 Attempts to add an element to the back of the queue.
 
bool try_push (value_type &&value)
 Attempts to add an element to the back of the queue (move version).
 
template<typename... Args>
bool try_emplace (Args &&... args)
 Attempts to construct an element in place at the back of the queue.
 
void reserve (size_type capacity)
 Sets the queue capacity to at least max(capacity, size()) elements.
 
bool try_reserve (size_type capacity)
 
void reserve_exact (size_type capacity)
 Sets the queue capacity to max(capacity, size()) elements.
 
bool try_reserve_exact (size_type capacity)
 Attempts to set the queue capacity to max(capacity, size()) elements.
 
void shrink_to_fit ()
 Reduces memory usage by releasing unused capacity, if possible.
 
void swap (DynamicQueue &other)
 Swaps the contents with another queue.
 

Friends

template<typename , typename >
class containers::internal::GenericQueue
 

Detailed Description

template<typename T, typename SizeType = uint16_t>
class pw::DynamicQueue< T, SizeType >

A queue implementation backed by pw::DynamicDeque.

This class provides a std::queue-like interface but uses a Pigweed allocator for dynamic memory management. It includes fallible try_* operations for scenarios where allocation failure may be handled gracefully.

Template Parameters
TThe type of elements stored in the queue.

Member Function Documentation

◆ try_reserve()

template<typename T , typename SizeType = uint16_t>
bool pw::DynamicQueue< T, SizeType >::try_reserve ( size_type  capacity)
inline

Attempts to set the queue capacity to at least max(capacity, size()) elements.


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