deque< T, Allocator >

deque< T, Allocator >#

stdgpu: stdgpu::deque< T, Allocator >
stdgpu Latest
Efficient STL-like Data Structures on the GPU

Detailed Description

template<typename T, typename Allocator = safe_device_allocator<T>>
class stdgpu::deque< T, Allocator >

A generic container similar to std::deque on the GPU.

Template Parameters
TThe type of the stored elements
AllocatorThe allocator type

Differences to std::deque:

  • index_type instead of size_type
  • Manual allocation and destruction of container required
  • max_size and capacity limited to initially allocated size
  • No guaranteed valid state when reaching capacity limit
  • Additional non-standard capacity functions full(), capacity(), data(), and valid()
  • Some member functions missing
  • operator[] uses the internal begin position and may be invalidated during concurrent push_front or pop_front operations

Public Types

using allocator_type = Allocator
 
using const_pointer = const value_type *
 
using const_reference = const value_type &
 
using difference_type = std::ptrdiff_t
 
using index_type = index_t
 
using pointer = value_type *
 
using reference = value_type &
 
using value_type = T
 

Public Member Functions

 deque () noexcept=default
 
STDGPU_DEVICE_ONLY reference at (const index_type n)
 
STDGPU_DEVICE_ONLY const_reference at (const index_type n) const
 
STDGPU_DEVICE_ONLY reference back ()
 
STDGPU_DEVICE_ONLY const_reference back () const
 
STDGPU_HOST_DEVICE index_t capacity () const noexcept
 
void clear ()
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
void clear (ExecutionPolicy &&policy)
 
const T * data () const noexcept
 
T * data () noexcept
 
stdgpu::device_indexed_range< T > device_range ()
 
stdgpu::device_indexed_range< const T > device_range () const
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
stdgpu::device_indexed_range< T > device_range (ExecutionPolicy &&policy)
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
stdgpu::device_indexed_range< const T > device_range (ExecutionPolicy &&policy) const
 
template<class... Args>
STDGPU_DEVICE_ONLY bool emplace_back (Args &&... args)
 
template<class... Args>
STDGPU_DEVICE_ONLY bool emplace_front (Args &&... args)
 
STDGPU_HOST_DEVICE bool empty () const
 
STDGPU_DEVICE_ONLY reference front ()
 
STDGPU_DEVICE_ONLY const_reference front () const
 
STDGPU_HOST_DEVICE bool full () const
 
STDGPU_HOST_DEVICE allocator_type get_allocator () const noexcept
 
STDGPU_HOST_DEVICE index_t max_size () const noexcept
 
STDGPU_DEVICE_ONLY reference operator[] (const index_type n)
 
STDGPU_DEVICE_ONLY const_reference operator[] (const index_type n) const
 
STDGPU_DEVICE_ONLY pair< T, bool > pop_back ()
 
STDGPU_DEVICE_ONLY pair< T, bool > pop_front ()
 
STDGPU_DEVICE_ONLY bool push_back (const T &element)
 
STDGPU_DEVICE_ONLY bool push_front (const T &element)
 
void shrink_to_fit ()
 
STDGPU_HOST_DEVICE index_t size () const
 
bool valid () const
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
bool valid (ExecutionPolicy &&policy) const
 

Static Public Member Functions

static deque< T, Allocator > createDeviceObject (const index_t &capacity, const Allocator &allocator=Allocator())
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
static deque< T, Allocator > createDeviceObject (ExecutionPolicy &&policy, const index_t &capacity, const Allocator &allocator=Allocator())
 
static void destroyDeviceObject (deque< T, Allocator > &device_object)
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
static void destroyDeviceObject (ExecutionPolicy &&policy, deque< T, Allocator > &device_object)