18#include "pw_allocator/allocator.h"
19#include "pw_containers/dynamic_deque.h"
20#include "pw_containers/internal/generic_queue.h"
36template <
typename T,
typename SizeType = u
int16_t>
38 :
public containers::internal::GenericQueue<DynamicQueue<T, SizeType>,
39 DynamicDeque<T, SizeType>> {
44 using const_iterator =
typename Deque::const_iterator;
45 using const_pointer =
typename Deque::const_pointer;
46 using const_reference =
typename Deque::const_reference;
47 using difference_type =
typename Deque::difference_type;
48 using iterator =
typename Deque::iterator;
49 using pointer =
typename Deque::pointer;
50 using reference =
typename Deque::reference;
51 using size_type =
typename Deque::size_type;
52 using value_type =
typename Deque::value_type;
56 : deque_(allocator) {}
67 void clear() { deque_.clear(); }
70 [[nodiscard]]
bool try_push(
const value_type& value) {
71 return deque_.try_push_back(value);
75 [[nodiscard]]
bool try_push(value_type&& value) {
76 return deque_.try_push_back(std::move(value));
80 template <
typename... Args>
82 return deque_.try_emplace_back(std::forward<Args>(args)...);
109 template <
typename,
typename>
110 friend class containers::internal::GenericQueue;
112 Deque& deque() {
return deque_; }
113 const Deque& deque()
const {
return deque_; }
Definition: allocator.h:36
Definition: dynamic_deque.h:60
Definition: dynamic_queue.h:39
void clear()
Removes all elements from the queue.
Definition: dynamic_queue.h:67
bool try_reserve_exact(size_type capacity)
Attempts to set the queue capacity to max(capacity, size()) elements.
Definition: dynamic_queue.h:98
void reserve(size_type new_capacity)
Increases capacity() to at least new_capacity. Crashes on failure.
Definition: dynamic_deque.h:151
void reserve(size_type capacity)
Sets the queue capacity to at least max(capacity, size()) elements.
Definition: dynamic_queue.h:86
constexpr DynamicQueue(pw::Allocator &allocator)
Constructs a DynamicQueue using the provided allocator.
Definition: dynamic_queue.h:55
constexpr DynamicQueue(DynamicQueue &&)=default
Move operations are supported and incur no allocations.
void reserve_exact(size_type new_capacity)
Increases capacity() to exactly new_capacity. Crashes on failure.
Definition: dynamic_deque.h:167
void swap(DynamicDeque &other) noexcept
Swaps the contents of two deques. No allocations occur.
Definition: dynamic_deque.h:182
bool try_reserve(size_type new_capacity)
Definition: dynamic_deque.h:240
void swap(DynamicQueue &other)
Swaps the contents with another queue.
Definition: dynamic_queue.h:106
void shrink_to_fit()
Attempts to reduce capacity() to size(). Not guaranteed to succeed.
Definition: dynamic_deque.h:261
bool try_reserve_exact(size_type new_capacity)
Definition: dynamic_deque.h:162
bool try_push(const value_type &value)
Attempts to add an element to the back of the queue.
Definition: dynamic_queue.h:70
bool try_push(value_type &&value)
Attempts to add an element to the back of the queue (move version).
Definition: dynamic_queue.h:75
bool try_reserve(size_type capacity)
Definition: dynamic_queue.h:90
void shrink_to_fit()
Reduces memory usage by releasing unused capacity, if possible.
Definition: dynamic_queue.h:103
bool try_emplace(Args &&... args)
Attempts to construct an element in place at the back of the queue.
Definition: dynamic_queue.h:81
void reserve_exact(size_type capacity)
Sets the queue capacity to max(capacity, size()) elements.
Definition: dynamic_queue.h:95
The Pigweed namespace.
Definition: alignment.h:27