Games Task Scheduler (GTS)
A multi-processor scheduling framework for games engines
gts::RingDeque< T, TAllocator > Class Template Reference

A re-sizable ring buffer ADT. More...

#include <RingDeque.h>

Inherits gts::AlignedAllocator< GTS_NO_SHARING_CACHE_LINE_SIZE >.

Public Types

using size_type = int64_t
 
using value_type = T
 
using allocator_type = TAllocator
 

Public Member Functions

 ~RingDeque ()
 Destructs the container. The destructors of the elements are called and the used storage is deallocated.
 
 RingDeque (const allocator_type &allocator=allocator_type())
 Constructs an empty container with the given 'allocator'.
 
 RingDeque (RingDeque const &other)
 Copy constructor. Constructs the container with the copy of the contents of 'other'.
 
 RingDeque (RingDeque &&other)
 Move constructor. Constructs the container with the contents of other using move semantics. After the move, other is invalid.
 
RingDequeoperator= (RingDeque const &other)
 Copy assignment operator. Replaces the contents with a copy of the contents of 'other'.
 
RingDequeoperator= (RingDeque &&other)
 Move assignment operator. Replaces the contents with those of other using move semantics. After the move, other is invalid.
 
bool empty () const
 Checks if the contains has no elements. More...
 
size_type size () const
 Gets the number of elements in the container. More...
 
size_type capacity () const
 Gets the number of elements that can be held in the currently allocated storage. More...
 
value_type const & front () const
 Gets the first element. More...
 
value_type & front ()
 Gets the first element. More...
 
value_type const & back () const
 Gets the last element. More...
 
value_type & back ()
 Gets the last element. More...
 
value_type const & operator[] (size_type pos) const
 Gets the element at pos. More...
 
value_type & operator[] (size_type pos)
 Gets the element at pos. More...
 
allocator_type get_allocator () const
 Get this RingDeque's allocator. More...
 
void push_back (value_type const &val)
 
void push_back (value_type &&val)
 
void push_front (value_type const &val)
 
void push_front (value_type &&val)
 
template<typename... TArgs>
void emplace_back (TArgs &&... args)
 
template<typename... TArgs>
void emplace_front (TArgs &&... args)
 
void pop_back ()
 
void pop_front ()
 
void reserve (size_type sizePow2)
 
void clear ()
 

Detailed Description

template<typename T, typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
class gts::RingDeque< T, TAllocator >

A re-sizable ring buffer ADT.

Template Parameters
TThe element type stored in the container.
TAllocatorThe allocator used by the storage backing.

Member Function Documentation

◆ back() [1/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
value_type& gts::RingDeque< T, TAllocator >::back ( )
inline

Gets the last element.

Returns
An element.

◆ back() [2/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
value_type const& gts::RingDeque< T, TAllocator >::back ( ) const
inline

Gets the last element.

Returns
An element.

◆ capacity()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
size_type gts::RingDeque< T, TAllocator >::capacity ( ) const
inline

Gets the number of elements that can be held in the currently allocated storage.

Returns
The capacity.

◆ clear()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void gts::RingDeque< T, TAllocator >::clear ( )
inline

Removes all elements but does not destroy the underlying array.

◆ emplace_back()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
template<typename... TArgs>
void gts::RingDeque< T, TAllocator >::emplace_back ( TArgs &&...  args)
inline

Construct a new element at the back.

◆ emplace_front()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
template<typename... TArgs>
void gts::RingDeque< T, TAllocator >::emplace_front ( TArgs &&...  args)
inline

Construct a new element at the front.

◆ empty()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
bool gts::RingDeque< T, TAllocator >::empty ( ) const
inline

Checks if the contains has no elements.

Returns
True if empty, false otherwise.

◆ front() [1/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
value_type& gts::RingDeque< T, TAllocator >::front ( )
inline

Gets the first element.

Returns
An element.

◆ front() [2/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
value_type const& gts::RingDeque< T, TAllocator >::front ( ) const
inline

Gets the first element.

Returns
An element.

◆ get_allocator()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
allocator_type gts::RingDeque< T, TAllocator >::get_allocator ( ) const
inline

Get this RingDeque's allocator.

Returns
The allocator.

◆ operator[]() [1/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
value_type& gts::RingDeque< T, TAllocator >::operator[] ( size_type  pos)
inline

Gets the element at pos.

Returns
An element.

◆ operator[]() [2/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
value_type const& gts::RingDeque< T, TAllocator >::operator[] ( size_type  pos) const
inline

Gets the element at pos.

Returns
An element.

◆ pop_back()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void gts::RingDeque< T, TAllocator >::pop_back ( )
inline

Removes and destroys the element at the end.

◆ pop_front()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void gts::RingDeque< T, TAllocator >::pop_front ( )
inline

Removes and destroys the element at the front.

◆ push_back() [1/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void gts::RingDeque< T, TAllocator >::push_back ( value_type &&  val)
inline

Inserts 'val' at the back.

◆ push_back() [2/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void gts::RingDeque< T, TAllocator >::push_back ( value_type const &  val)
inline

Inserts a copy of 'val' at the back.

◆ push_front() [1/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void gts::RingDeque< T, TAllocator >::push_front ( value_type &&  val)
inline

Inserts 'val' at the front.

◆ push_front() [2/2]

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void gts::RingDeque< T, TAllocator >::push_front ( value_type const &  val)
inline

Inserts a copy of 'val' at the front.

◆ reserve()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
void gts::RingDeque< T, TAllocator >::reserve ( size_type  sizePow2)
inline

Increases the capacity of the queue. Does nothing if 'sizePow2' < capacity.

Remarks
Not thread-safe.

◆ size()

template<typename T , typename TAllocator = AlignedAllocator<GTS_NO_SHARING_CACHE_LINE_SIZE>>
size_type gts::RingDeque< T, TAllocator >::size ( ) const
inline

Gets the number of elements in the container.

Returns
The size.