aGrUM  0.20.3
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/tools/core/hashTable.h>

Public Attributes

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

Public Member Functions

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

Public Types

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

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 197 of file hashTable.h.

Member Enumeration Documentation

◆ Emplace

template<typename Key, typename Val>
enum 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 211 of file hashTable.h.

212  { EMPLACE };

Constructor & Destructor Documentation

◆ HashTableBucket() [1/7]

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

Class constructor.

Definition at line 217 of file hashTable.h.

217 {}

◆ 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 223 of file hashTable.h.

223 : pair{from.pair} {}
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

◆ 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 230 of file hashTable.h.

230 : pair{k, v} {}
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

◆ 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 237 of file hashTable.h.

237 : pair{std::move(k), std::move(v)} {}
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

◆ HashTableBucket() [5/7]

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

Constructor.

Parameters
pThe pair to store.

Definition at line 243 of file hashTable.h.

243 : pair(p) {}
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

◆ HashTableBucket() [6/7]

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

Constructor.

Parameters
pThe pair to store.

Definition at line 249 of file hashTable.h.

249 : pair(std::move(p)) {}
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

◆ HashTableBucket() [7/7]

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

The emplace constructor.

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

Definition at line 258 of file hashTable.h.

258  :
259  // emplace (universal) constructor
260  pair(std::forward< Args >(args)...) {}
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

◆ ~HashTableBucket()

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

Class destructor.

Definition at line 265 of file hashTable.h.

265 {}

Member Function Documentation

◆ elt()

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

Returns the pair stored in this bucket.

Returns
Returns the pair stored in this bucket.

Definition at line 271 of file hashTable.h.

271 { return pair; }
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

◆ key()

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

Returns the key part of the pair.

Returns
Returns the key part of the pair.

Definition at line 277 of file hashTable.h.

277 { return const_cast< Key& >(pair.first); }
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

◆ val()

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

Returns the value part of the pair.

Returns
Returns value key part of the pair.

Definition at line 283 of file hashTable.h.

283 { return pair.second; }
std::pair< const Key, Val > pair
The pair stored in this bucket.
Definition: hashTable.h:199

Member Data Documentation

◆ next

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

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

Definition at line 205 of file hashTable.h.

◆ pair

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

The pair stored in this bucket.

Definition at line 199 of file hashTable.h.

◆ 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 202 of file hashTable.h.


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