C/C++ API Reference
Loading...
Searching...
No Matches
pw::containers::internal::GenericVarLenEntryQueue< Derived, T > Class Template Reference

Overview

template<typename Derived, typename T>
class pw::containers::internal::GenericVarLenEntryQueue< Derived, T >

A queue of variable length entries.

This type use CRTP to allow a derived class to specify access to the backing storage and indicate where the queue head and tail are within it.

Inheritance diagram for pw::containers::internal::GenericVarLenEntryQueue< Derived, T >:
pw::containers::internal::GenericVarLenEntryQueueBase

Public Types

using value_type = containers::internal::VarLenEntry< T >
 
using const_value_type = containers::internal::VarLenEntry< const T >
 
using iterator = VarLenEntryQueueIterator< T >
 
using const_iterator = VarLenEntryQueueIterator< const T >
 

Public Member Functions

constexpr iterator begin ()
 Returns an iterator to the start of the queue.
 
constexpr const_iterator begin () const
 
constexpr const_iterator cbegin () const
 
constexpr iterator end ()
 Returns an iterator to the end of the queue.
 
constexpr const_iterator end () const
 
constexpr const_iterator cend () const
 
constexpr bool empty () const
 Returns true if the queue is empty, false if it has at least one entry.
 
constexpr size_t size () const
 
constexpr size_t max_size () const
 
constexpr size_t size_bytes () const
 
constexpr size_t encoded_size_bytes () const
 
constexpr size_t max_size_bytes () const
 
constexpr value_type front ()
 
constexpr const_value_type front () const
 
constexpr void push (span< const T > data)
 
constexpr bool try_push (span< const T > data)
 
constexpr void push_overwrite (span< const T > data)
 
constexpr void pop ()
 
constexpr void clear ()
 Empties the queue.
 
constexpr std::pair< span< const T >, span< const T > > contiguous_raw_storage () const
 
span< const T > dering ()
 Moves entries to be contiguous and start from the beginning of the buffer.
 

Static Public Member Functions

static constexpr size_t DataSizeBytes (size_t max_size_bytes)
 

Protected Member Functions

constexpr size_t GetHead () const
 
constexpr void SetHead (size_t head)
 
constexpr size_t GetTail () const
 
constexpr void SetTail (size_t tail)
 
constexpr span< T > GetBuffer ()
 
constexpr span< const T > GetBuffer () const
 
GetBytes

Returns the buffer as a span of bytes. Only constexpr if T is std::byte.

constexpr ByteSpan GetBytes ()
 
constexpr ConstByteSpan GetBytes () const
 

Friends

template<typename D1 , typename T1 , typename D2 , typename T2 >
constexpr void CopyVarLenEntriesImpl (const GenericVarLenEntryQueue< D1, T1 > &src, GenericVarLenEntryQueue< D2, T2 > &dst, bool overwrite)
 
template<typename D1 , typename T1 , typename D2 , typename T2 >
constexpr void MoveVarLenEntriesImpl (GenericVarLenEntryQueue< D1, T1 > &src, GenericVarLenEntryQueue< D2, T2 > &dst, bool overwrite)
 

Member Function Documentation

◆ contiguous_raw_storage()

template<typename Derived , typename T >
constexpr std::pair< span< const T >, span< const T > > pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::contiguous_raw_storage
constexpr

Returns views of the contiguous raw storage backing this queue. If empty, both returned spans will be empty. If the data does not wrap, only the first returned span will be non-empty. If the data wraps around, both contiguous regions will be returned, from the head to the tail.

◆ DataSizeBytes()

template<typename Derived , typename T >
static constexpr size_t pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::DataSizeBytes ( size_t  max_size_bytes)
inlinestaticconstexpr

Returns the minimum number of data bytes needed to hold an entry of max_size_bytes.

◆ dering()

template<typename Derived , typename T >
span< const T > pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::dering

Moves entries to be contiguous and start from the beginning of the buffer.

Returns a view to the contiguous data.

◆ encoded_size_bytes()

template<typename Derived , typename T >
constexpr size_t pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::encoded_size_bytes ( ) const
inlineconstexpr

Returns the combined size in bytes of all entries in the queue, including metadata. This is at most O(n) in the number of entries in the queue.

◆ front()

template<typename Derived , typename T >
constexpr GenericVarLenEntryQueue< Derived, T >::value_type pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::front
constexpr

Returns the first entry in the queue.

Precondition
The queue must NOT be empty (empty() is false).

◆ max_size()

template<typename Derived , typename T >
constexpr size_t pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::max_size ( ) const
inlineconstexpr

Returns the maximum number of entries in the queue. This is only attainable if all entries are empty.

◆ max_size_bytes()

template<typename Derived , typename T >
constexpr size_t pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::max_size_bytes ( ) const
inlineconstexpr

Returns the maximum number of bytes that can be stored in the queue. This is largest possible value of size_bytes(), and the size of the largest single entry that can be stored in this queue. Attempting to store a larger entry is invalid and results in a crash.

◆ pop()

template<typename Derived , typename T >
constexpr void pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::pop
constexpr

Removes the first entry from queue.

Precondition
The queue MUST have at least one entry.

◆ push()

template<typename Derived , typename T >
constexpr void pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::push ( span< const T >  data)
inlineconstexpr

Appends an entry to the end of the queue.

Precondition
The entry MUST NOT be larger than max_size_bytes().
There must be sufficient space in the queue for this entry.

◆ push_overwrite()

template<typename Derived , typename T >
constexpr void pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::push_overwrite ( span< const T >  data)
inlineconstexpr

Appends an entry to the end of the queue, removing entries with Pop as necessary to make room. Calling this function drops old entries to make room for new; call try_push() to drop new entries instead.

Precondition
The entry MUST NOT be larger than max_size_bytes().

◆ size()

template<typename Derived , typename T >
constexpr size_t pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::size ( ) const
inlineconstexpr

Returns the number of variable-length entries in the queue. This is at most O(n) in the number of entries in the queue.

◆ size_bytes()

template<typename Derived , typename T >
constexpr size_t pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::size_bytes ( ) const
inlineconstexpr

Returns the combined size in bytes of all entries in the queue, excluding metadata. This is at most O(n) in the number of entries in the queue.

◆ try_push()

template<typename Derived , typename T >
constexpr bool pw::containers::internal::GenericVarLenEntryQueue< Derived, T >::try_push ( span< const T >  data)
inlineconstexpr

Appends an entry to the end of the queue, but only if there is sufficient space for it.

Returns
true if the data was added to the queue; false if it did not fit
Precondition
The entry MUST NOT be larger than max_size_bytes().

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