aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::HashTableBucket< Key, Val > Class Template Reference

A recipient for a pair of key value in a gum::HashTableList. More...

#include <agrum/base/core/hashTable.h>

Public Types

enum class  Emplace { EMPLACE }
 A dummy type for the emplace constructor. More...

Public Member Functions

 HashTableBucket ()=default
 Class constructor.
 HashTableBucket (const HashTableBucket< Key, Val > &from)
 Copy constructor.
 HashTableBucket (const Key &k, const Val &v)
 Constructor.
 HashTableBucket (Key &&k, Val &&v)
 Constructor.
 HashTableBucket (const std::pair< const Key, Val > &p)
 Constructor.
 HashTableBucket (std::pair< const Key, Val > &&p)
 Constructor.
template<typename... Args>
 HashTableBucket (Emplace e, Args &&... args)
 The emplace constructor.
 ~HashTableBucket ()=default
 Class destructor.
std::pair< const Key, Val > & elt ()
 Returns the pair stored in this bucket.
Key & key ()
 Returns the key part of the pair.
Val & val ()
 Returns the value part of the pair.

Public Attributes

std::pair< const Key, Val > pair
 The pair stored in this bucket.
HashTableBucket< Key, Val > * prev {nullptr}
 A pointer toward the previous bucket in the gum::HashTableList.
HashTableBucket< Key, Val > * next {nullptr}
 A pointer toward the next bucket in the gum::HashTableList.

Detailed Description

template<typename Key, typename Val>
class gum::HashTableBucket< Key, Val >

A recipient for a pair of key value in a gum::HashTableList.

In aGrUM, hashtables are vectors of chained lists. Each list corresponds to the pairs (key,val) the keys of which have the same hashed value. Each box of the list is called a bucket. Lists are doubly linked so as to enable efficient begin/end iterators and efficient insert/erase operations.

Template Parameters
KeyThe type for keys in a gum::HashTable.
ValThe type for values in a gum::HashTable.

Definition at line 216 of file hashTable.h.

Member Enumeration Documentation

◆ Emplace

template<typename Key, typename Val>
enum class gum::HashTableBucket::Emplace
strong

A dummy type for the emplace constructor.

This type is used to prevent the Bucket emplace (int,...) to compile.

Enumerator
EMPLACE 

Definition at line 230 of file hashTable.h.

230{ EMPLACE };

Constructor & Destructor Documentation

◆ HashTableBucket() [1/7]

template<typename Key, typename Val>
gum::HashTableBucket< Key, Val >::HashTableBucket ( )
default

Class constructor.

Referenced by HashTableBucket(), and HashTableBucket().

Here is the caller graph for this function:

◆ HashTableBucket() [2/7]

template<typename Key, typename Val>
gum::HashTableBucket< Key, Val >::HashTableBucket ( const HashTableBucket< Key, Val > & from)
inline

Copy constructor.

Parameters
fromThe gum::HashTableBucket to copy.

Definition at line 241 of file hashTable.h.

241: pair{from.pair} {}
A recipient for a pair of key value in a gum::HashTableList.
Definition hashTable.h:216
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition hashTable.h:218

References HashTableBucket(), and pair.

Here is the call graph for this function:

◆ HashTableBucket() [3/7]

template<typename Key, typename Val>
gum::HashTableBucket< Key, Val >::HashTableBucket ( const Key & k,
const Val & v )
inline

Constructor.

Parameters
kThe key part of the pair.
vThe value part of the pair.

Definition at line 248 of file hashTable.h.

248: pair{k, v} {}

References pair.

◆ HashTableBucket() [4/7]

template<typename Key, typename Val>
gum::HashTableBucket< Key, Val >::HashTableBucket ( Key && k,
Val && v )
inline

Constructor.

Parameters
kThe key part of the pair.
vThe value part of the pair.

Definition at line 255 of file hashTable.h.

255: pair{std::move(k), std::move(v)} {}

References pair.

◆ HashTableBucket() [5/7]

template<typename Key, typename Val>
gum::HashTableBucket< Key, Val >::HashTableBucket ( const std::pair< const Key, Val > & p)
explicit

Constructor.

Parameters
pThe pair to store.

Definition at line 2013 of file hashTable_tpl.h.

2013: pair(p) {}

References HashTableBucket(), and pair.

Here is the call graph for this function:

◆ HashTableBucket() [6/7]

template<typename Key, typename Val>
gum::HashTableBucket< Key, Val >::HashTableBucket ( std::pair< const Key, Val > && p)
explicit

Constructor.

Parameters
pThe pair to store.

Definition at line 2016 of file hashTable_tpl.h.

2016 :
2017 pair(std::move(p)) {}

References pair.

◆ HashTableBucket() [7/7]

template<typename Key, typename Val>
template<typename... Args>
gum::HashTableBucket< Key, Val >::HashTableBucket ( Emplace e,
Args &&... args )

The emplace constructor.

Parameters
eThe emplace.
argsA construction list.
Template Parameters
argsThe types in the construction list.

Definition at line 2021 of file hashTable_tpl.h.

2021 :
2022 // emplace (universal) constructor

References pair.

◆ ~HashTableBucket()

template<typename Key, typename Val>
gum::HashTableBucket< Key, Val >::~HashTableBucket ( )
default

Class destructor.

Member Function Documentation

◆ elt()

template<typename Key, typename Val>
std::pair< const Key, Val > & gum::HashTableBucket< Key, Val >::elt ( )

Returns the pair stored in this bucket.

Returns
Returns the pair stored in this bucket.

Definition at line 2026 of file hashTable_tpl.h.

2026 {
2027 return pair;
2028 }

References pair.

Referenced by gum::HashTableList< Key, Val >::at(), gum::HashTableList< Key, Val >::at(), gum::HashTable< const gum::DiscreteVariable *, Idx >::cend(), gum::HashTable< Key, Val >::emplace(), gum::HashTable< Key, Val >::insert(), gum::HashTable< Key, Val >::insert(), and gum::HashTable< Key, Val >::insert().

Here is the caller graph for this function:

◆ key()

template<typename Key, typename Val>
Key & gum::HashTableBucket< Key, Val >::key ( )

Returns the key part of the pair.

Returns
Returns the key part of the pair.

Definition at line 2031 of file hashTable_tpl.h.

2031 {
2032 return const_cast< Key& >(pair.first);
2033 }

References pair.

Referenced by gum::HashTable< const gum::DiscreteVariable *, Idx >::HashTable(), gum::HashTable< Key, Val >::_insert_(), gum::HashTable< const gum::DiscreteVariable *, Idx >::end(), gum::HashTable< Key, Val >::key(), and gum::HashTable< Key, Val >::tryGetKey().

Here is the caller graph for this function:

◆ val()

template<typename Key, typename Val>
Val & gum::HashTableBucket< Key, Val >::val ( )

Returns the value part of the pair.

Returns
Returns value key part of the pair.

Definition at line 2036 of file hashTable_tpl.h.

2036 {
2037 return pair.second;
2038 }

References pair.

Referenced by gum::HashTable< const gum::DiscreteVariable *, Idx >::cbegin(), gum::HashTable< Key, Val >::getWithDefault(), gum::HashTable< Key, Val >::operator[](), gum::HashTable< Key, Val >::tryGet(), and gum::HashTable< Key, Val >::tryGet().

Here is the caller graph for this function:

Member Data Documentation

◆ next

◆ pair

template<typename Key, typename Val>
std::pair< const Key, Val > gum::HashTableBucket< Key, Val >::pair

◆ prev

template<typename Key, typename Val>
HashTableBucket< Key, Val >* gum::HashTableBucket< Key, Val >::prev {nullptr}

A pointer toward the previous bucket in the gum::HashTableList.

Definition at line 221 of file hashTable.h.

221{nullptr};

Referenced by gum::HashTableList< Key, Val >::erase().


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