libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gbl::HashMap< K, T, H, P > Class Template Reference
Inheritance diagram for gbl::HashMap< K, T, H, P >:
gbl::HashSet< K, H, P > gbl::ReadWriteIndexable< CRTP, Key, Value, Writable > GblHashSet gbl::HashSetBase< HashSet< K, H, P >, K > gbl::tags::HashSet

Public Types

using HashSetType = HashSet< std::pair< const K, T >, impl::HashMapHasherAdapter< K, T, H >, impl::HashMapEqualToAdapter< K, T, P > >
 
using HashSetBaseType = typename HashSetType::BaseType
 
using key_type = K
 
using mapped_type = T
 
using value_type = std::pair< const K, T >
 
using size_type = Size
 
using difference_type = std::ptrdiff_t
 
using hasher = H
 
using key_equal = P
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = value_type *
 
using const_pointer = const pointer
 
using iterator = typename HashSetType::iterator
 
using const_iterator = typename HashSetType::const_iterator
 
- Public Types inherited from gbl::HashSet< K, H, P >
using BaseType = HashSetBase< HashSet< K, H, P >, K >
 
using reference = typename BaseType::reference
 
using const_reference = typename BaseType::const_reference
 
using pointer = typename BaseType::pointer
 
using const_pointer = typename BaseType::const_pointer
 
using size_type = typename BaseType::size_type
 
using key_type = typename BaseType::key_type
 
using value_type = typename BaseType::value_type
 
using hasher = H
 
using key_equal = P
 
using iterator = HashSetIterator< HashSet< K, H, P >, K >
 
- Public Types inherited from gbl::HashSetBase< HashSet< K, H, P >, K >
using HashSetBaseType = HashSetBase< HashSet< K, H, P >, K >
 
using DerivedType = HashSet< K, H, P >
 
using KeyType = K
 
using key_type = KeyType
 
using value_type = KeyType
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = value_type *
 
using const_pointer = const value_type *
 
using const_iterator = HashSetIterator< std::add_const_t< HashSetBase< HashSet< K, H, P >, K > >, K >
 
using allocator_type = Context *
 
using size_type = Size
 
using difference_type = ptrdiff_t
 

Public Member Functions

 HashMap (size_type capacity=0, const H &hash=H(), const P &pred=P(), Context *pCtx=nullptr)
 
 HashMap (size_type capacity, const H &hash, Context *pCtx)
 
 HashMap (size_type capacity, Context *pCtx)
 
 HashMap (Context *pCtx)
 
 HashMap (std::initializer_list< value_type > init, size_type capacity=0, const H &hash=H(), const P &pred=P(), Context *pCtx=nullptr)
 
 HashMap (std::initializer_list< value_type > init, size_type capacity, const H &hash, Context *pCtx)
 
 HashMap (std::initializer_list< value_type > init, size_type capacity, Context *pCtx)
 
template<typename M >
void insert_or_assign (const key_type &k, M &&obj) noexcept
 
bool erase (const key_type &k) noexcept
 
auto at (const key_type &key) const -> const mapped_type &
 
auto at (const key_type &key) -> mapped_type &
 
auto find (const key_type &key) const noexcept -> const_iterator
 
auto find (const key_type &key) noexcept -> iterator
 
bool contains (const key_type &key) const noexcept
 
- Public Member Functions inherited from gbl::HashSet< K, H, P >
 HashSet (size_type capacity, const H &hash=H(), const P &pred=P(), Context *pCtx=nullptr)
 
 HashSet (size_type capacity, const H &hash, Context *pContext)
 
 HashSet (size_type capacity, Context *pContext)
 
 HashSet (type_compatible_container_readable< value_type > auto &&init, size_type capacity=0, const H hasher=H(), const P pred=P(), Context *pCtx=nullptr)
 
 HashSet (type_compatible_container_readable< value_type > auto &&init, size_type capacity, H hasher, Context *pCtx)
 
 HashSet (type_compatible_container_readable< value_type > auto &&init, size_type capacity, Context *pCtx)
 
 HashSet (type_compatible_iterator_readable< value_type > auto first, type_compatible_iterator_readable< value_type > auto last, size_type capacity=0, const H &hash=H(), const P &pred=P(), Context *pCtx=nullptr)
 
 HashSet (type_compatible_iterator_readable< value_type > auto first, type_compatible_iterator_readable< value_type > auto last, size_type capacity, const H &hash, Context *pCtx)
 
 HashSet (type_compatible_iterator_readable< value_type > auto first, type_compatible_iterator_readable< value_type > auto last, size_type capacity, Context *pCtx)
 
 HashSet (HashSet &other)
 
 HashSet (HashSet &other, Context *pCtx)
 
 HashSet (HashSet &&other)
 
 HashSet (HashSet &&other, Context *pCtx)
 
HashSetoperator= (const HashSet &other)
 
HashSetoperator= (const HashSet &&other)
 
HashSetoperator= (type_compatible_container_readable< value_type > auto &&init)
 
pointer get (const key_type &key) noexcept
 
reference at (const key_type &key)
 
iterator find (const key_type &key) noexcept
 
pointer set (const key_type &key) noexcept
 
bool insert (const key_type &key) noexcept
 
void insert_or_assign (const key_type &key) noexcept
 
bool erase (const key_type &key) noexcept
 
pointer extract (const key_type &key) noexcept
 
void clear (void) noexcept
 
template<typename... Args>
bool emplace (const key_type &key, Args &&... args)
 
template<typename... Args>
bool try_emplace (const key_type &key, Args &&... args) noexcept
 
pointer probe (size_type position) noexcept
 
iterator next (iterator *pPrev)
 
iterator begin (void)
 
iterator end (void)
 
- Public Member Functions inherited from gbl::HashSetBase< HashSet< K, H, P >, K >
 operator const GblHashSet * () const
 
decltype(autogetSet (void) const
 
decltype(autogetSet (void)
 
size_type size (void) const noexcept
 
size_type bucket_count (void) const noexcept
 
size_type bucket_size (void) const noexcept
 
bool empty (void) const noexcept
 
GblContextcontext (void) const noexcept
 
const_pointer get (const key_type &key) const noexcept
 
const_reference at (const key_type &key) const
 
size_type count (const key_type &key) const noexcept
 
bool contains (const key_type &key) const noexcept
 
const_pointer probe (size_type position) const noexcept
 
const_iterator find (const key_type &key) const noexcept
 
bool for_each (F &&fn) const noexcept
 
const_iterator next (const_iterator *pPrev) const
 
const_iterator cbegin (void) const
 
auto begin (void) const
 
const_iterator cend (void) const
 
auto end (void) const
 
- Public Member Functions inherited from gbl::ReadWriteIndexable< CRTP, Key, Value, Writable >
Value operator[] (Key key) const
 

Protected Member Functions

auto getElement_ (const K &key) const noexcept -> const T &
 
void setElement_ (const K &key, const T &value) noexcept
 
- Protected Member Functions inherited from gbl::HashSet< K, H, P >
const GblHashSetset_ (void) const
 
GblHashSetset_ (void)
 

Friends

class ReadWriteIndexable< HashMap< K, T, H, P >, K, T, true >
 

Additional Inherited Members

- Data Fields inherited from GblHashSet
struct { 
 
   GblContext *   pCtx 
 
   size_t   entrySize 
 
   size_t   capacity 
 
   GblHashSetHashFn   pFnHash 
 
   GblHashSetCmpFn   pFnCompare 
 
   GblHashSetDtorFn   pFnDestruct 
 
   size_t   bucketSize 
 
   size_t   bucketCount 
 
   size_t   count 
 
   size_t   mask 
 
   void *   pBuckets 
 
   void *   pSpare 
 
   void *   pUserdata 
 
private_ 
 

Detailed Description

template<typename K, typename T, typename H = std::hash<K>, typename P = std::equal_to<K>>
class gbl::HashMap< K, T, H, P >

Definition at line 25 of file gimbal_hash_map.hpp.

Member Typedef Documentation

◆ HashSetType

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::HashSetType = HashSet<std::pair<const K, T>, impl::HashMapHasherAdapter<K, T, H>, impl::HashMapEqualToAdapter<K, T, P> >

Definition at line 34 of file gimbal_hash_map.hpp.

◆ HashSetBaseType

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::HashSetBaseType = typename HashSetType::BaseType

Definition at line 37 of file gimbal_hash_map.hpp.

◆ key_type

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::key_type = K

Definition at line 38 of file gimbal_hash_map.hpp.

◆ mapped_type

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::mapped_type = T

Definition at line 39 of file gimbal_hash_map.hpp.

◆ value_type

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::value_type = std::pair<const K, T>

Definition at line 40 of file gimbal_hash_map.hpp.

◆ size_type

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::size_type = Size

Definition at line 41 of file gimbal_hash_map.hpp.

◆ difference_type

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::difference_type = std::ptrdiff_t

Definition at line 42 of file gimbal_hash_map.hpp.

◆ hasher

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::hasher = H

Definition at line 43 of file gimbal_hash_map.hpp.

◆ key_equal

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::key_equal = P

Definition at line 44 of file gimbal_hash_map.hpp.

◆ reference

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::reference = value_type&

Definition at line 45 of file gimbal_hash_map.hpp.

◆ const_reference

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::const_reference = const value_type&

Definition at line 46 of file gimbal_hash_map.hpp.

◆ pointer

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::pointer = value_type*

Definition at line 47 of file gimbal_hash_map.hpp.

◆ const_pointer

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::const_pointer = const pointer

Definition at line 48 of file gimbal_hash_map.hpp.

◆ iterator

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::iterator = typename HashSetType::iterator

Definition at line 49 of file gimbal_hash_map.hpp.

◆ const_iterator

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
using gbl::HashMap< K, T, H, P >::const_iterator = typename HashSetType::const_iterator

Definition at line 50 of file gimbal_hash_map.hpp.

Constructor & Destructor Documentation

◆ HashMap() [1/7]

template<typename K , typename T , typename H , typename P >
gbl::HashMap< K, T, H, P >::HashMap ( size_type  capacity = 0,
const H hash = H(),
const P pred = P(),
Context *  pCtx = nullptr 
)
inline

Definition at line 154 of file gimbal_hash_map.hpp.

157 :
158 HashSetType(capacity, hash, pred, pCtx) {}

◆ HashMap() [2/7]

template<typename K , typename T , typename H , typename P >
gbl::HashMap< K, T, H, P >::HashMap ( size_type  capacity,
const H hash,
Context *  pCtx 
)
inline

Definition at line 175 of file gimbal_hash_map.hpp.

177 :
178 HashMap(capacity, hash, P(), pCtx) {}

◆ HashMap() [3/7]

template<typename K , typename T , typename H , typename P >
gbl::HashMap< K, T, H, P >::HashMap ( size_type  capacity,
Context *  pCtx 
)
inline

Definition at line 181 of file gimbal_hash_map.hpp.

181 :
182 HashMap(capacity, H(), P(), pCtx) {}

◆ HashMap() [4/7]

template<typename K , typename T , typename H , typename P >
gbl::HashMap< K, T, H, P >::HashMap ( Context *  pCtx)
inlineexplicit

Definition at line 185 of file gimbal_hash_map.hpp.

185 :
186 HashMap(0, pCtx) {}

◆ HashMap() [5/7]

template<typename K , typename T , typename H , typename P >
gbl::HashMap< K, T, H, P >::HashMap ( std::initializer_list< value_type >  init,
size_type  capacity = 0,
const H hash = H(),
const P pred = P(),
Context *  pCtx = nullptr 
)
inline

Definition at line 161 of file gimbal_hash_map.hpp.

165 :
166 HashMap(capacity < init.size()? init.size() : capacity, hash, pred, pCtx)
167{
168 //INEFFICIENT AS SHIT COPYING?
169 for(auto item : init) {
170 HashSetType::insert(item);
171 }
172}

◆ HashMap() [6/7]

template<typename K , typename T , typename H , typename P >
gbl::HashMap< K, T, H, P >::HashMap ( std::initializer_list< value_type >  init,
size_type  capacity,
const H hash,
Context *  pCtx 
)
inline

Definition at line 190 of file gimbal_hash_map.hpp.

193 :
194 HashMap(std::move(init), capacity, hash, P(), pCtx) {}

◆ HashMap() [7/7]

template<typename K , typename T , typename H , typename P >
gbl::HashMap< K, T, H, P >::HashMap ( std::initializer_list< value_type >  init,
size_type  capacity,
Context *  pCtx 
)
inline

Definition at line 197 of file gimbal_hash_map.hpp.

199 :
200 HashMap(std::move(init), capacity, H(), pCtx) {}

Member Function Documentation

◆ getElement_()

template<typename K , typename T , typename H , typename P >
const T & gbl::HashMap< K, T, H, P >::getElement_ ( const K key) const -> const T&
inlineprotectednoexcept

Definition at line 203 of file gimbal_hash_map.hpp.

203 {
204 return at(key);
205}

◆ setElement_()

template<typename K , typename T , typename H , typename P >
void gbl::HashMap< K, T, H, P >::setElement_ ( const K key,
const T value 
)
inlineprotectednoexcept

Definition at line 208 of file gimbal_hash_map.hpp.

208 {
209 insert_or_assign(key, value);
210}

◆ insert_or_assign()

template<typename K , typename T , typename H , typename P >
template<typename M >
void gbl::HashMap< K, T, H, P >::insert_or_assign ( const key_type &  k,
M &&  obj 
)
inlinenoexcept

Definition at line 214 of file gimbal_hash_map.hpp.

214 {
215 std::pair<K, T> item { k, std::forward<M>(obj) };
216 HashSetType::insert_or_assign(item);
217}

◆ erase()

template<typename K , typename T , typename H , typename P >
bool gbl::HashMap< K, T, H, P >::erase ( const key_type &  k)
inlinenoexcept

Definition at line 220 of file gimbal_hash_map.hpp.

220 {
221 std::pair<K, T> pair { k, T{} };
222 return HashSetType::erase(pair);
223}

◆ at() [1/2]

template<typename K , typename T , typename H , typename P >
auto gbl::HashMap< K, T, H, P >::at ( const key_type &  key) const -> const mapped_type&
inline

Definition at line 226 of file gimbal_hash_map.hpp.

226 {
227 std::pair<K, T> pair { k, T{} };
228 const auto& result = HashSetBaseType::at(pair);
229 return result.second;
230}

◆ at() [2/2]

template<typename K , typename T , typename H , typename P >
auto gbl::HashMap< K, T, H, P >::at ( const key_type &  key) -> mapped_type&
inline

Definition at line 233 of file gimbal_hash_map.hpp.

233 {
234 std::pair<K, T> pair { k, T{} };
235 auto& result = HashSetType::at(pair);
236 return result.second;
237}

◆ find() [1/2]

template<typename K , typename T , typename H , typename P >
auto gbl::HashMap< K, T, H, P >::find ( const key_type &  key) const -> const_iterator
inlinenoexcept

Definition at line 240 of file gimbal_hash_map.hpp.

240 {
241 std::pair<K, T> pair (k, T{});
242 return HashSetType::find(pair);
243}

◆ find() [2/2]

template<typename K , typename T , typename H , typename P >
auto gbl::HashMap< K, T, H, P >::find ( const key_type &  key) -> iterator
inlinenoexcept

Definition at line 246 of file gimbal_hash_map.hpp.

246 {
247 std::pair<K, T> pair (k, T{});
248 return HashSetType::find(pair);
249}

◆ contains()

template<typename K , typename T , typename H , typename P >
bool gbl::HashMap< K, T, H, P >::contains ( const key_type &  key) const
inlinenoexcept

Definition at line 252 of file gimbal_hash_map.hpp.

252 {
253 std::pair<K, T> pair { k, T{} };
254 return HashSetType::contains(pair);
255}

Friends And Related Symbol Documentation

◆ ReadWriteIndexable< HashMap< K, T, H, P >, K, T, true >

template<typename K , typename T , typename H = std::hash<K>, typename P = std::equal_to<K>>
friend class ReadWriteIndexable< HashMap< K, T, H, P >, K, T, true >
friend

Definition at line 252 of file gimbal_hash_map.hpp.


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