unordered_map< Key, T, Hash, KeyEqual, Allocator >

unordered_map< Key, T, Hash, KeyEqual, Allocator >#

stdgpu: stdgpu::unordered_map< Key, T, Hash, KeyEqual, Allocator >
stdgpu Latest
Efficient STL-like Data Structures on the GPU

Detailed Description

template<typename Key, typename T, typename Hash = hash<Key>, typename KeyEqual = equal_to<Key>, typename Allocator = safe_device_allocator<pair<const Key, T>>>
class stdgpu::unordered_map< Key, T, Hash, KeyEqual, Allocator >

A generic class similar to std::unordered_map on the GPU.

Template Parameters
KeyThe key type
TThe mapped type
HashThe type of the hash functor
KeyEqualThe type of the key equality functor
AllocatorThe allocator type

Differences to std::unordered_map:

  • 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() and valid()
  • Some member functions missing
  • Iterators may point at non-occupied and non-valid hash entry
  • Difference between begin() and end() returns max_size() rather than size()
  • Insert function returns iterator to end() rather than to the element preventing insertion
  • Range insert and erase functions use iterators to value_type and key_type

Public Types

using allocator_type = Allocator
 
using const_iterator = const_pointer
 
using const_pointer = const value_type *
 
using const_reference = const value_type &
 
using difference_type = std::ptrdiff_t
 
using hasher = Hash
 
using index_type = index_t
 
using iterator = pointer
 
using key_equal = KeyEqual
 
using key_type = Key
 
using mapped_type = T
 
using pointer = value_type *
 
using reference = value_type &
 
using value_type = pair< const Key, T >
 

Public Member Functions

 unordered_map () noexcept=default
 
STDGPU_DEVICE_ONLY const_iterator begin () const noexcept
 
STDGPU_DEVICE_ONLY iterator begin () noexcept
 
STDGPU_HOST_DEVICE index_type bucket (const key_type &key) const
 
STDGPU_HOST_DEVICE index_t bucket_count () const
 
STDGPU_DEVICE_ONLY index_type bucket_size (index_type n) const
 
STDGPU_DEVICE_ONLY const_iterator cbegin () const noexcept
 
STDGPU_DEVICE_ONLY const_iterator cend () const noexcept
 
void clear ()
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
void clear (ExecutionPolicy &&policy)
 
STDGPU_DEVICE_ONLY bool contains (const key_type &key) const
 
template<typename KeyLike , STDGPU_DETAIL_OVERLOAD_IF(detail::is_transparent_v< Hash > &&detail::is_transparent_v< KeyEqual >) >
STDGPU_DEVICE_ONLY bool contains (const KeyLike &key) const
 
STDGPU_DEVICE_ONLY index_type count (const key_type &key) const
 
template<typename KeyLike , STDGPU_DETAIL_OVERLOAD_IF(detail::is_transparent_v< Hash > &&detail::is_transparent_v< KeyEqual >) >
STDGPU_DEVICE_ONLY index_type count (const KeyLike &key) const
 
device_indexed_range< value_typedevice_range ()
 
device_indexed_range< const value_typedevice_range () const
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
device_indexed_range< value_typedevice_range (ExecutionPolicy &&policy)
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
device_indexed_range< const value_typedevice_range (ExecutionPolicy &&policy) const
 
template<class... Args>
STDGPU_DEVICE_ONLY pair< iterator, bool > emplace (Args &&... args)
 
STDGPU_HOST_DEVICE bool empty () const
 
STDGPU_DEVICE_ONLY const_iterator end () const noexcept
 
STDGPU_DEVICE_ONLY iterator end () noexcept
 
STDGPU_DEVICE_ONLY index_type erase (const key_type &key)
 
template<typename ExecutionPolicy , typename KeyIterator , STDGPU_DETAIL_OVERLOAD_IF( is_execution_policy_v< remove_cvref_t< ExecutionPolicy > > &&detail::is_iterator_v< KeyIterator >) >
void erase (ExecutionPolicy &&policy, KeyIterator begin, KeyIterator end)
 
template<typename KeyIterator , STDGPU_DETAIL_OVERLOAD_IF(detail::is_iterator_v< KeyIterator >) >
void erase (KeyIterator begin, KeyIterator end)
 
STDGPU_DEVICE_ONLY iterator find (const key_type &key)
 
STDGPU_DEVICE_ONLY const_iterator find (const key_type &key) const
 
template<typename KeyLike , STDGPU_DETAIL_OVERLOAD_IF(detail::is_transparent_v< Hash > &&detail::is_transparent_v< KeyEqual >) >
STDGPU_DEVICE_ONLY iterator find (const KeyLike &key)
 
template<typename KeyLike , STDGPU_DETAIL_OVERLOAD_IF(detail::is_transparent_v< Hash > &&detail::is_transparent_v< KeyEqual >) >
STDGPU_DEVICE_ONLY const_iterator find (const KeyLike &key) const
 
STDGPU_HOST_DEVICE bool full () const
 
STDGPU_HOST_DEVICE allocator_type get_allocator () const noexcept
 
STDGPU_HOST_DEVICE hasher hash_function () const
 
STDGPU_DEVICE_ONLY pair< iterator, bool > insert (const value_type &value)
 
template<typename ExecutionPolicy , typename ValueIterator , STDGPU_DETAIL_OVERLOAD_IF( is_execution_policy_v< remove_cvref_t< ExecutionPolicy > > &&detail::is_iterator_v< ValueIterator >) >
void insert (ExecutionPolicy &&policy, ValueIterator begin, ValueIterator end)
 
template<typename ValueIterator , STDGPU_DETAIL_OVERLOAD_IF(detail::is_iterator_v< ValueIterator >) >
void insert (ValueIterator begin, ValueIterator end)
 
STDGPU_HOST_DEVICE key_equal key_eq () const
 
STDGPU_HOST_DEVICE float load_factor () const
 
STDGPU_HOST_DEVICE float max_load_factor () const
 
STDGPU_HOST_DEVICE index_t max_size () const noexcept
 
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 unordered_map 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 unordered_map createDeviceObject (ExecutionPolicy &&policy, const index_t &capacity, const Allocator &allocator=Allocator())
 
template<typename ExecutionPolicy , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
static void destroyDeviceObject (ExecutionPolicy &&policy, unordered_map &device_object)
 
static void destroyDeviceObject (unordered_map &device_object)