10#ifndef PBAT_COMMON_QUEUE_H
11#define PBAT_COMMON_QUEUE_H
13#include "pbat/HostDevice.h"
24template <
class T, auto kCapacity = 64>
31 PBAT_HOST_DEVICE
Queue() : queue{}, begin{0}, end{0}, n{0} {}
37 PBAT_HOST_DEVICE
void Push(T value)
48 PBAT_HOST_DEVICE T
const&
Top()
const {
return queue[begin]; }
53 PBAT_HOST_DEVICE
void Pop()
69 PBAT_HOST_DEVICE
bool IsEmpty()
const {
return n == 0; }
75 PBAT_HOST_DEVICE
auto Size()
const {
return n; }
79 PBAT_HOST_DEVICE
void Clear() { begin = end = n = 0; }
85 PBAT_HOST_DEVICE
constexpr auto Capacity()
const {
return kCapacity; }
PBAT_HOST_DEVICE constexpr auto Capacity() const
Get the maximum number of elements in the queue.
Definition Queue.h:85
PBAT_HOST_DEVICE void Clear()
Clear the queue.
Definition Queue.h:79
PBAT_HOST_DEVICE void Pop()
Remove the next element in the queue.
Definition Queue.h:53
PBAT_HOST_DEVICE T const & Top() const
Get the next element in the queue.
Definition Queue.h:48
PBAT_HOST_DEVICE Queue()
Construct empty Queue.
Definition Queue.h:31
PBAT_HOST_DEVICE bool IsFull() const
Check if the queue is full.
Definition Queue.h:63
PBAT_HOST_DEVICE bool IsEmpty() const
Check if the queue is empty.
Definition Queue.h:69
PBAT_HOST_DEVICE auto Size() const
Get the number of elements in the queue.
Definition Queue.h:75
PBAT_HOST_DEVICE void Push(T value)
Add element to the queue.
Definition Queue.h:37
Common functionality.
Definition ArgSort.h:20
The main namespace of the library.
Definition Aliases.h:15