COROIO: NNet::NActors::TUnboundedVectorQueue< T > Struct Template Reference
COROIO
 
Loading...
Searching...
No Matches
NNet::NActors::TUnboundedVectorQueue< T > Struct Template Reference

Unbounded queue with automatic capacity growth. More...

#include <queue.hpp>

Public Member Functions

 TUnboundedVectorQueue (size_t capacity=16)
 Construct queue with initial capacity.
 
void Push (T &&item)
 Add element to the back of the queue.
 
T & Front ()
 Get reference to the front element.
 
void Pop ()
 Remove the front element from the queue.
 
bool TryPop (T &item)
 
size_t Size () const
 Get current number of elements in the queue.
 
bool Empty () const
 Check if the queue is empty.
 

Detailed Description

template<typename T>
struct NNet::NActors::TUnboundedVectorQueue< T >

Unbounded queue with automatic capacity growth.

Template Parameters
TElement type stored in the queue

TUnboundedVectorQueue uses a single vector as circular buffer to avoid the frequent chunk allocations/deallocations that std::queue (std::deque) performs. Power-of-two sizing enables fast bitwise indexing operations. The queue grows by doubling capacity when full, maintaining amortized O(1) push operations while keeping memory usage predictable.

Constructor & Destructor Documentation

◆ TUnboundedVectorQueue()

template<typename T >
NNet::NActors::TUnboundedVectorQueue< T >::TUnboundedVectorQueue ( size_t  capacity = 16)
inline

Construct queue with initial capacity.

Parameters
capacityInitial capacity (will be rounded up to power of two)

Member Function Documentation

◆ Empty()

template<typename T >
bool NNet::NActors::TUnboundedVectorQueue< T >::Empty ( ) const
inline

Check if the queue is empty.

Returns
true if queue contains no elements

◆ Front()

template<typename T >
T & NNet::NActors::TUnboundedVectorQueue< T >::Front ( )
inline

Get reference to the front element.

Returns
Reference to the front element
Note
Behavior is undefined if queue is empty

◆ Pop()

template<typename T >
void NNet::NActors::TUnboundedVectorQueue< T >::Pop ( )
inline

Remove the front element from the queue.

Note
Behavior is undefined if queue is empty

◆ Push()

template<typename T >
void NNet::NActors::TUnboundedVectorQueue< T >::Push ( T &&  item)
inline

Add element to the back of the queue.

Parameters
itemElement to add (moved into the queue)

◆ Size()

template<typename T >
size_t NNet::NActors::TUnboundedVectorQueue< T >::Size ( ) const
inline

Get current number of elements in the queue.

Returns
Number of elements currently stored

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