Pigweed
C/C++ API Reference
|
Public Member Functions | |
constexpr | DynamicQueue (pw::Allocator &allocator) |
Constructs a DynamicQueue using the provided allocator. | |
DynamicQueue (const DynamicQueue &)=delete | |
DynamicQueue & | operator= (const DynamicQueue &)=delete |
constexpr | DynamicQueue (DynamicQueue &&)=default |
Move operations are supported and incur no allocations. | |
DynamicQueue & | operator= (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 |
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.
T | The type of elements stored in the queue. |
|
inline |
Attempts to set the queue capacity to at least max(capacity, size())
elements.