stack< T, ContainerT >

stack< T, ContainerT >#

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

Detailed Description

template<typename T, typename ContainerT = deque<T>>
class stdgpu::stack< T, ContainerT >

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

Template Parameters
TThe type of the stored elements
ContainerTThe type of the underlying container

Differences to std::stack:

  • index_type instead of size_type
  • Manual allocation and destruction of container required
  • No guaranteed valid state when reaching capacity limit
  • Additional non-standard capacity functions full(), capacity(), and valid()
  • Several member functions missing

Public Types

using const_reference = typename ContainerT::const_reference
 
using container_type = ContainerT
 
using index_type = typename ContainerT::index_type
 
using reference = typename ContainerT::reference
 
using value_type = typename ContainerT::value_type
 

Public Member Functions

 stack ()=default
 
STDGPU_HOST_DEVICE index_t capacity () const
 
STDGPU_HOST_DEVICE bool empty () const
 
STDGPU_HOST_DEVICE bool full () const
 
STDGPU_DEVICE_ONLY pair< T, bool > pop ()
 
STDGPU_DEVICE_ONLY bool push (const T &element)
 
STDGPU_HOST_DEVICE index_t size () const
 
bool valid () const
 

Static Public Member Functions

static stack< T, ContainerT > createDeviceObject (const index_t &size)
 
static void destroyDeviceObject (stack< T, ContainerT > &device_object)