aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::Bijection< T1, T2 > Class Template Reference

Set of pairs of elements with fast search for both elements. More...

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

Inheritance diagram for gum::Bijection< T1, T2 >:
Collaboration diagram for gum::Bijection< T1, T2 >:

Public Types

using Implementation
 The Implementation of this gum::Bijection.
using type1_type = T1
 types for STL compliance
using type1_reference = T1&
 types for STL compliance
using type1_const_reference = const T1&
 types for STL compliance
using type1_pointer = T1*
 types for STL compliance
using type1_const_pointer = const T1*
 types for STL compliance
using type2_type = T2
 types for STL compliance
using type2_reference = T2&
 types for STL compliance
using type2_const_reference = const T2&
 types for STL compliance
using type2_pointer = T2*
 types for STL compliance
using type2_const_pointer = const T2*
 types for STL compliance
using size_type = std::size_t
 types for STL compliance
using difference_type = std::ptrdiff_t
 types for STL compliance
using iterator = BijectionIterator< T1, T2 >
 types for STL compliance
using const_iterator = BijectionIterator< T1, T2 >
 types for STL compliance
using iterator_safe = BijectionIteratorSafe< T1, T2 >
 types for STL compliance
using const_iterator_safe = BijectionIteratorSafe< T1, T2 >
 types for STL compliance

Public Member Functions

INLINE void emplace (Args &&... args)
Constructors/destructors
 Bijection (Size size=HashTableConst::default_size, bool resize_policy=HashTableConst::default_resize_policy)
 Default constructor: creates a gum::Bijection without any association.
 Bijection (std::initializer_list< std::pair< T1, T2 > > list)
 Initializer list constructor.
 Bijection (const Bijection< T1, T2 > &toCopy)
 Copy constructor.
 Bijection (Bijection< T1, T2 > &&from) noexcept
 Move constructor.
 ~Bijection ()
 Class destructor.
Operators
Bijection< T1, T2 > & operator= (const Bijection< T1, T2 > &toCopy)
 Copy operator.
Bijection< T1, T2 > & operator= (Bijection< T1, T2 > &&bij)
 Move operator.
Iterators
iterator begin () const
 Returns the unsafe iterator at the beginning of the gum::Bijection.
const_iterator cbegin () const
 Returns the constant unsafe iterator at the beginning of the gum::Bjection.
const iteratorend () const noexcept
 Returns the unsafe iterator at the end of the gum::Bijection.
const const_iteratorcend () const noexcept
 Returns the constant iterator at the end of the gum::Bijection.
iterator_safe beginSafe () const
 Returns the safe iterator at the beginning of the gum::Bijection.
const_iterator_safe cbeginSafe () const
 Returns the constant safe iterator at the begining of the gum::Bijection.
const iterator_safeendSafe () const noexcept
 Returns the safe iterator at the end of the gum::Bijection.
const const_iterator_safecendSafe () const noexcept
 Returns the constant safe iterator at the end of the gum::Bijection.
Accessors / Modifiers
const T1 & first (const T2 &second) const
 Returns the first value of a pair given its second value.
const T1 & firstWithDefault (const T2 &second, const T1 &default_val) const
 Returns the first value of a pair given its second value or default_val if second is unfound.
const T2 & second (const T1 &first) const
 Returns the second value of a pair given its first value.
const T2 & secondWithDefault (const T1 &second, const T2 &default_val) const
 Returns the second value of a pair given its first value or default_val if first is unfound.
bool existsFirst (const T1 &first) const
 Returns true if first is the first element in a pair in the gum::Bijection.
bool existsSecond (const T2 &second) const
 Returns true if second is the second element in a pair in the gum::Bijection.
void insert (const T1 &first, const T2 &second)
 Inserts a new association in the gum::Bijection.
void insert (T1 &&first, T2 &&second)
 Inserts a new association in the gum::Bijection.
void emplace (Args &&... args)
 Emplace a new element in the gum::Bijection.
void clear ()
 Removes all the associations from the gum::Bijection.
bool empty () const noexcept
 Returns true if the gum::Bijection doesn't contain any association.
Size size () const noexcept
 Returns the number of associations stored within the gum::Bijection.
void eraseFirst (const T1 &first)
 Erases an association containing the given first element.
void eraseSecond (const T2 &second)
 Erases an association containing the given second element.
std::string toString () const
 Returns a friendly representatin of the gum::Bijection.
Fine tuning
Size capacity () const noexcept
 Returns the number of hashtables slots used.
void resize (Size new_size)
 Manually resize the gum::Bijection.
void setResizePolicy (const bool new_policy) noexcept
 Change the gum::Bijection resizing policy.
bool resizePolicy () const noexcept
 Returns true if the resize policy is automatic.

Private Types

using HashTable12
 Alias for more readable code.
using HashTable21
 Alias for more readable code.

Private Member Functions

void _copy_ (const HashTable< T1, T2 * > &source)
 A function that performs a complete copy of another gum::Bijection.
HashTable12::value_type_insert_ (const T1 &first, const T2 &second)
 Inserts a new association into the gum::Bijection.
HashTable12::value_type_insert_ (T1 &&first, T2 &&second)
 Inserts a new association into the gum::Bijection.

Private Attributes

HashTable12 _firstToSecond_
 The gum::HashTable associating T2 objects to T1 objects.
HashTable21 _secondToFirst_
 The gum::HashTable associating T1 objects to T2 objects.

Detailed Description

template<typename T1, typename T2>
class gum::Bijection< T1, T2 >

Set of pairs of elements with fast search for both elements.

This class is designed for modeling a gum::Bijection between two sets, the idea is following :

  • We want to create a gum::Bjection relation between type T1 and type T2,
  • For x in T1, there exists only one y in T2 associated to x,
  • For y in T2, there exists only one x in T1 associated to y,
  • The user inserts all the (x, y) associations and can search efficiently the values thus associated.
Template Parameters
T1The first type of elements in the gum::Bjection.
T2The second type of elements in the gum::Bjection.

Definition at line 1591 of file bijection.h.

Member Typedef Documentation

◆ const_iterator

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::const_iterator = BijectionIterator< T1, T2 >

types for STL compliance

Definition at line 1611 of file bijection.h.

◆ const_iterator_safe

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::const_iterator_safe = BijectionIteratorSafe< T1, T2 >

types for STL compliance

Definition at line 1613 of file bijection.h.

◆ difference_type

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::difference_type = std::ptrdiff_t

types for STL compliance

Definition at line 1609 of file bijection.h.

◆ HashTable12

using gum::BijectionImplementation< T1, T2, Gen >::HashTable12
privateinherited

Alias for more readable code.

Definition at line 563 of file bijection.h.

◆ HashTable21

using gum::BijectionImplementation< T1, T2, Gen >::HashTable21
privateinherited

Alias for more readable code.

Definition at line 564 of file bijection.h.

◆ Implementation

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::Implementation
Initial value:
T2,
std::is_scalar< T1 >::value && std::is_scalar< T2 >::value >

The Implementation of this gum::Bijection.

Definition at line 1617 of file bijection.h.

◆ iterator

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::iterator = BijectionIterator< T1, T2 >

types for STL compliance

Definition at line 1610 of file bijection.h.

◆ iterator_safe

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::iterator_safe = BijectionIteratorSafe< T1, T2 >

types for STL compliance

Definition at line 1612 of file bijection.h.

◆ size_type

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::size_type = std::size_t

types for STL compliance

Definition at line 1608 of file bijection.h.

◆ type1_const_pointer

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type1_const_pointer = const T1*

types for STL compliance

Definition at line 1602 of file bijection.h.

◆ type1_const_reference

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type1_const_reference = const T1&

types for STL compliance

Definition at line 1600 of file bijection.h.

◆ type1_pointer

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type1_pointer = T1*

types for STL compliance

Definition at line 1601 of file bijection.h.

◆ type1_reference

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type1_reference = T1&

types for STL compliance

Definition at line 1599 of file bijection.h.

◆ type1_type

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type1_type = T1

types for STL compliance

Definition at line 1598 of file bijection.h.

◆ type2_const_pointer

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type2_const_pointer = const T2*

types for STL compliance

Definition at line 1607 of file bijection.h.

◆ type2_const_reference

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type2_const_reference = const T2&

types for STL compliance

Definition at line 1605 of file bijection.h.

◆ type2_pointer

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type2_pointer = T2*

types for STL compliance

Definition at line 1606 of file bijection.h.

◆ type2_reference

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type2_reference = T2&

types for STL compliance

Definition at line 1604 of file bijection.h.

◆ type2_type

template<typename T1, typename T2>
using gum::Bijection< T1, T2 >::type2_type = T2

types for STL compliance

Definition at line 1603 of file bijection.h.

Constructor & Destructor Documentation

◆ Bijection() [1/4]

template<typename T1, typename T2>
INLINE gum::Bijection< T1, T2 >::Bijection ( Size size = HashTableConst::default_size,
bool resize_policy = HashTableConst::default_resize_policy )

Default constructor: creates a gum::Bijection without any association.

Parameters
sizeThe gum::Bijection starting size.
resize_policyIf tru, the gum::Bijection will be automatically resized.

Definition at line 997 of file bijection_tpl.h.

997 :
999 size,
1000 resize_policy) {
1002 }
Set of pairs of elements with fast search for both elements.
Definition bijection.h:1594
Bijection(Size size=HashTableConst::default_size, bool resize_policy=HashTableConst::default_resize_policy)
Default constructor: creates a gum::Bijection without any association.

References Bijection(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::BijectionImplementation, and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::size().

Referenced by Bijection(), Bijection(), Bijection(), Bijection(), and ~Bijection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bijection() [2/4]

template<typename T1, typename T2>
INLINE gum::Bijection< T1, T2 >::Bijection ( std::initializer_list< std::pair< T1, T2 > > list)

Initializer list constructor.

Parameters
listThe initialisation list.

Definition at line 1006 of file bijection_tpl.h.

References Bijection(), and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::BijectionImplementation.

Here is the call graph for this function:

◆ Bijection() [3/4]

template<typename T1, typename T2>
INLINE gum::Bijection< T1, T2 >::Bijection ( const Bijection< T1, T2 > & toCopy)

Copy constructor.

Parameters
toCopyThe gum::Bijection to copy.

Definition at line 1014 of file bijection_tpl.h.

References Bijection(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::BijectionImplementation, and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::Bijection< T1, T2 >.

Here is the call graph for this function:

◆ Bijection() [4/4]

template<typename T1, typename T2>
INLINE gum::Bijection< T1, T2 >::Bijection ( Bijection< T1, T2 > && from)
noexcept

Move constructor.

Parameters
fromThe gum::Bijection to move from.

Definition at line 1022 of file bijection_tpl.h.

References Bijection(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::BijectionImplementation, and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::Bijection< T1, T2 >.

Here is the call graph for this function:

◆ ~Bijection()

template<typename T1, typename T2>
INLINE gum::Bijection< T1, T2 >::~Bijection ( )

Class destructor.

Definition at line 1030 of file bijection_tpl.h.

1030 {
1032 }

References Bijection().

Here is the call graph for this function:

Member Function Documentation

◆ _copy_()

void gum::BijectionImplementation< T1, T2, Gen >::_copy_ ( const HashTable< T1, T2 * > & source)
privateinherited

A function that performs a complete copy of another gum::Bijection.

Warning
this function assumes that "this" is an empty gum::Bijection. If it is not the case, use function clear() before calling copy.
Parameters
sourceThe source from copied into this gum::Bijection.

References _copy_().

Referenced by _copy_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _insert_() [1/2]

HashTable12::value_type * gum::BijectionImplementation< T1, T2, Gen >::_insert_ ( const T1 & first,
const T2 & second )
privateinherited

Inserts a new association into the gum::Bijection.

Parameters
firstThe first object in the association.
secondThe second object in the association.
Returns
Returns a pointer toward the inserted association.

References _insert_(), first(), and second().

Referenced by _insert_(), _insert_(), and emplace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _insert_() [2/2]

HashTable12::value_type * gum::BijectionImplementation< T1, T2, Gen >::_insert_ ( T1 && first,
T2 && second )
privateinherited

Inserts a new association into the gum::Bijection.

Parameters
firstThe first object in the association.
secondThe second object in the association.
Returns
Returns a pointer toward the inserted association.

References gum::BijectionImplementation< T1, T2, Gen >::BijectionImplementation, BijectionImplementation, gum::BijectionImplementation< T1, T2, Gen >::~BijectionImplementation(), gum::BijectionImplementation< T1, T2, Gen >::_copy_(), _firstToSecond_, gum::BijectionImplementation< T1, T2, Gen >::_insert_(), _insert_(), _secondToFirst_, gum::BijectionImplementation< T1, T2, Gen >::begin(), gum::BijectionImplementation< T1, T2, Gen >::beginSafe(), BijectionIterator< T1, T2 >, BijectionIteratorSafe< T1, T2 >, gum::BijectionImplementation< T1, T2, Gen >::capacity(), gum::BijectionImplementation< T1, T2, Gen >::cbegin(), gum::BijectionImplementation< T1, T2, Gen >::cbeginSafe(), gum::BijectionImplementation< T1, T2, Gen >::cend(), gum::BijectionImplementation< T1, T2, Gen >::cendSafe(), gum::BijectionImplementation< T1, T2, Gen >::clear(), gum::BijectionImplementation< T1, T2, Gen >::emplace(), gum::BijectionImplementation< T1, T2, Gen >::empty(), gum::BijectionImplementation< T1, T2, Gen >::end(), gum::BijectionImplementation< T1, T2, Gen >::endSafe(), gum::BijectionImplementation< T1, T2, Gen >::eraseFirst(), gum::BijectionImplementation< T1, T2, Gen >::eraseSecond(), gum::BijectionImplementation< T1, T2, Gen >::existsFirst(), gum::BijectionImplementation< T1, T2, Gen >::existsSecond(), gum::BijectionImplementation< T1, T2, Gen >::first(), first(), gum::BijectionImplementation< T1, T2, Gen >::firstWithDefault(), gum::BijectionImplementation< T1, T2, Gen >::insert(), gum::BijectionImplementation< T1, T2, Gen >::operator=(), gum::BijectionImplementation< T1, T2, Gen >::resize(), gum::BijectionImplementation< T1, T2, Gen >::resizePolicy(), gum::BijectionImplementation< T1, T2, Gen >::second(), second(), gum::BijectionImplementation< T1, T2, Gen >::secondWithDefault(), gum::BijectionImplementation< T1, T2, Gen >::setResizePolicy(), gum::BijectionImplementation< T1, T2, Gen >::size(), size(), and gum::BijectionImplementation< T1, T2, Gen >::toString().

◆ begin()

iterator gum::BijectionImplementation< T1, T2, Gen >::begin ( ) const
inherited

Returns the unsafe iterator at the beginning of the gum::Bijection.

Unsafe iterators are a little bit faster than safe ones. But this speed is at the expense of safety: if you point to an element that is deleted, then try to access it or trying to operate a ++ will most certainly result in a segfault. So, Unsafe iterators should only be used to parse gum::Bjection where no element is ever deleted. If unsure, prefer using safe iterators.

Note that the notion of a beginning/end of a gum::Bjection is rather fuzzy. What is important here is that for an instance bij of this class:

for(iterator iter = bij.begin(); iter != bij.end(); ++iter) {
// will parse all the associations.
}
BijectionIterator< T1, T2 > iterator
types for STL compliance
Definition bijection.h:1610

◆ beginSafe()

iterator_safe gum::BijectionImplementation< T1, T2, Gen >::beginSafe ( ) const
inherited

Returns the safe iterator at the beginning of the gum::Bijection.

Safe iterators are slightly slower than unsafe iterators. However, they guarantee that no segmentation fault can ever occur when trying to access the element they point to or when applying a ++ operator. When no element of the gum::Bijection is to be deleted during the parsing of the gum::Bijection (as for instance when you parse the gum::Bijection to display its content), prefer using the unsafe iterators, which are a little bit faster and cannot, in this case, produce segfaults.

Note that the notion of a beginning/end of a gum::Bijection is rather fuzzy. What is important here is that for an instance bij of this class:

for (iterator iter = bij.beginSafe(); iter != bij.endSafe(); ++iter) {
// loops will parse all the associations
}

References beginSafe().

Referenced by beginSafe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ capacity()

Size gum::BijectionImplementation< T1, T2, Gen >::capacity ( ) const
noexceptinherited

Returns the number of hashtables slots used.

Returns
Returns the number of hashtables slots used.

References capacity().

Referenced by BijectionImplementation(), and capacity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cbegin()

const_iterator gum::BijectionImplementation< T1, T2, Gen >::cbegin ( ) const
inherited

Returns the constant unsafe iterator at the beginning of the gum::Bjection.

Unsafe iterators are a little bit faster than safe ones. But this speed is at the expense of safety: if you point to an element that is deleted, then try to access it or trying to operate a ++ will most certainly result in a segfault. So, Unsafe iterators should only be used to parse gum::Bjection where no element is ever deleted. If unsure, prefer using safe iterators.

Note that the notion of a beginning/end of a gum::Bjection is rather fuzzy. What is important here is that for an instance bij of this class:

for (iterator iter = bij.cbegin(); iter != bij.cend(); ++iter) {
// will parse all the association
}

◆ cbeginSafe()

const_iterator_safe gum::BijectionImplementation< T1, T2, Gen >::cbeginSafe ( ) const
inherited

Returns the constant safe iterator at the begining of the gum::Bijection.

Safe iterators are slightly slower than unsafe iterators. However, they guarantee that no segmentation fault can ever occur when trying to access the element they point to or when applying a ++ operator. When no element of the gum::Bijection is to be deleted during the parsing of the gum::Bijection (as for instance when you parse the bijection to display its content), prefer using the unsafe iterators, which are a little bit faster and cannot, in this case, produce segfaults.

Note that the notion of a beginning/end of a gum::Bijection is rather fuzzy. What is important here is that for an instance bij of this class:

for (iterator iter = bij.cbeginSafe(); iter != bij.cendSafe(); ++iter) {
// loops will parse all the associations
}

References cbeginSafe().

Referenced by cbeginSafe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cend()

const const_iterator & gum::BijectionImplementation< T1, T2, Gen >::cend ( ) const
noexceptinherited

Returns the constant iterator at the end of the gum::Bijection.

Unsafe iterators are a little bit faster than safe ones. But this speed is at the expense of safety: if you point to an element that is deleted, then try to access it or trying to operate a ++ will most certainly result in a segfault. So, Unsafe iterators should only be used to parse gum::Bijection where no element is ever deleted. If unsure, prefer using safe iterators.

Note that the notion of a beginning/end of a gum::Bijection is rather fuzzy. What is important here is that for an instance bij of this class:

for (iterator iter = bij.cbegin(); iter != bij.cend(); ++iter) {
// loops will parse all the associations
}

References cend().

Referenced by cend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cendSafe()

const const_iterator_safe & gum::BijectionImplementation< T1, T2, Gen >::cendSafe ( ) const
noexceptinherited

Returns the constant safe iterator at the end of the gum::Bijection.

Safe iterators are slightly slower than unsafe iterators. However, they guarantee that no segmentation fault can ever occur when trying to access the element they point to or when applying a ++ operator. When no element of the gum::Bijection is to be deleted during the parsing of the gum::Bijection (as for instance when you parse the gum::Bijection to display its content), prefer using the unsafe iterators, which are a little bit faster and cannot, in this case, produce segfaults.

Note that the notion of a beginning/end of a gum::Bijection is rather fuzzy. What is important here is that for an instance bij of this class:

for (iterator iter = bij.cbeginSafe(); iter != bij.cendSafe(); ++iter) {
// loops will parse all the associations
}

References cendSafe().

Referenced by cendSafe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void gum::BijectionImplementation< T1, T2, Gen >::clear ( )
inherited

Removes all the associations from the gum::Bijection.

References clear().

Referenced by clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emplace() [1/2]

void gum::BijectionImplementation< T1, T2, Gen >::emplace ( Args &&... args)
inherited

Emplace a new element in the gum::Bijection.

The emplace method allows to construct directly an element of type Key by passing to its constructor all the arguments it needs.

Parameters
argsthe arguments passed to the constructor
Exceptions
DuplicateElementexception is thrown if the association already exists

References emplace().

Referenced by emplace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emplace() [2/2]

INLINE void gum::BijectionImplementation< T1, T2, Gen >::emplace ( Args &&... args)
inherited

Definition at line 349 of file bijection_tpl.h.

349 {
352 }
A non scalar implementation of a Bijection.
Definition bijection.h:104
const T1 & first(const T2 &second) const
Returns the first value of a pair given its second value.
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.

References _insert_().

Here is the call graph for this function:

◆ empty()

bool gum::BijectionImplementation< T1, T2, Gen >::empty ( ) const
noexceptinherited

Returns true if the gum::Bijection doesn't contain any association.

Returns
Returns true if the gum::Bijection doesn't contain any association.

References empty().

Referenced by empty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

const iterator & gum::BijectionImplementation< T1, T2, Gen >::end ( ) const
noexceptinherited

Returns the unsafe iterator at the end of the gum::Bijection.

Unsafe iterators are a little bit faster than safe ones. But this speed is at the expense of safety: if you point to an element that is deleted, then try to access it or trying to operate a ++ will most certainly result in a segfault. So, Unsafe iterators should only be used to parse gum::Bijection where no element is ever deleted. If unsure, prefer using safe iterators.

Note that the notion of a beginning/end of a gum::Bijection is rather fuzzy. What is important here is that for an instance bij of this class:

for(iterator iter = bij.begin(); iter != bij.end(); ++iter) {
// loops will parse all the associations
}

◆ endSafe()

const iterator_safe & gum::BijectionImplementation< T1, T2, Gen >::endSafe ( ) const
noexceptinherited

Returns the safe iterator at the end of the gum::Bijection.

Safe iterators are slightly slower than unsafe iterators. However, they guarantee that no segmentation fault can ever occur when trying to access the element they point to or when applying a ++ operator. When no element of the gum::Bijection is to be deleted during the parsing of the gum::Bijection (as for instance when you parse the gum::Bijection to display its content), prefer using the unsafe iterators, which are a little bit faster and cannot, in this case, produce segfaults.

Note that the notion of a beginning/end of a gum::Bijection is rather fuzzy. What is important here is that for an instance bij of this class:

for (iterator iter = bij.beginSafe(); iter != bij.endSafe(); ++iter) {
// loops will parse all the associations
}

References endSafe().

Referenced by endSafe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eraseFirst()

void gum::BijectionImplementation< T1, T2, Gen >::eraseFirst ( const T1 & first)
inherited

Erases an association containing the given first element.

If the element cannot be found, nothing is done. In particular, no exception is raised.

Parameters
firstThe first element of a pair in the gum::Bijection.

References eraseFirst(), and first().

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::_removeNode_(), and eraseFirst().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eraseSecond()

void gum::BijectionImplementation< T1, T2, Gen >::eraseSecond ( const T2 & second)
inherited

Erases an association containing the given second element.

If the element cannot be found, nothing is done. In particular, no exception is raised.

Parameters
secondThe second element of a pair in the gum::Bijection.

References eraseSecond(), and second().

Referenced by eraseSecond().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ existsFirst()

bool gum::BijectionImplementation< T1, T2, Gen >::existsFirst ( const T1 & first) const
inherited

Returns true if first is the first element in a pair in the gum::Bijection.

Parameters
firstThe element tested for existence.
Returns
Returns true if first is in the first element in a pair in the gum::Bijection.

References existsFirst(), and first().

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::_removeNode_(), and existsFirst().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ existsSecond()

bool gum::BijectionImplementation< T1, T2, Gen >::existsSecond ( const T2 & second) const
inherited

Returns true if second is the second element in a pair in the gum::Bijection.

Parameters
secondThe element tested for existence.
Returns
Returns true if second is in the second element in a pair in the gum::Bijection.

References existsSecond(), and second().

Referenced by existsSecond(), and gum::MDDOperatorStrategy< GUM_SCALAR >::shouldEleminateVar_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ first()

const T1 & gum::BijectionImplementation< T1, T2, Gen >::first ( const T2 & second) const
inherited

Returns the first value of a pair given its second value.

Parameters
secondThe second value of a pair in the gum::Bijection.
Returns
Returns the first value of a pair given its second value.
Exceptions
NotFoundRaised if the element cannot be found.

References first(), and second().

Referenced by gum::prm::gspan::StrictSearch< GUM_SCALAR >::_buildPatternGraph_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), _insert_(), _insert_(), eraseFirst(), existsFirst(), first(), insert(), insert(), gum::MDDOperatorStrategy< GUM_SCALAR >::regress(), gum::TreeOperatorStrategy< GUM_SCALAR >::regress(), and second().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ firstWithDefault()

const T1 & gum::BijectionImplementation< T1, T2, Gen >::firstWithDefault ( const T2 & second,
const T1 & default_val ) const
inherited

Returns the first value of a pair given its second value or default_val if second is unfound.

Parameters
secondThe second value of a pair in the gum::Bijection.
default_valThe default value returned if second is not in the gum::Bijection.
Returns
Returns the first value of a pair given its second value or default_val if second is not in the bjection.

References firstWithDefault(), and second().

Referenced by firstWithDefault().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert() [1/2]

void gum::BijectionImplementation< T1, T2, Gen >::insert ( const T1 & first,
const T2 & second )
inherited

Inserts a new association in the gum::Bijection.

The values are added by copy.

Parameters
firstThe first element of the pair to insert.
secondThe second element of the pair to insert.
Exceptions
DuplicateElementRaised if the association already exists.

References first(), insert(), and second().

Referenced by gum::prm::gspan::StrictSearch< GUM_SCALAR >::_buildPatternGraph_(), gum::prm::StructuredInference< GUM_SCALAR >::_buildPatternGraph_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClassDag_(), insert(), and insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert() [2/2]

void gum::BijectionImplementation< T1, T2, Gen >::insert ( T1 && first,
T2 && second )
inherited

Inserts a new association in the gum::Bijection.

The values are moved in the gum::Bijection.

Parameters
firstThe first element of the pair to insert.
secondThe second element of the pair to insert.
Exceptions
DuplicateElementRaised if the association already exists.

References first(), insert(), and second().

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename T1, typename T2>
INLINE Bijection< T1, T2 > & gum::Bijection< T1, T2 >::operator= ( Bijection< T1, T2 > && bij)

Move operator.

Parameters
bijThe gum::Bijection to move from.

Definition at line 1043 of file bijection_tpl.h.

1043 {
1045 return *this;
1046 }
BijectionImplementation< T1, T2, Gen > & operator=(const BijectionImplementation< T1, T2, Gen > &toCopy)
Copy operator.

References gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::Bijection< T1, T2 >, and gum::BijectionImplementation< T1, T2, Gen >::operator=().

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename T1, typename T2>
INLINE Bijection< T1, T2 > & gum::Bijection< T1, T2 >::operator= ( const Bijection< T1, T2 > & toCopy)

Copy operator.

Parameters
toCopyThe gum::Bijection to copy.
Returns
Returns this gum::Bijection.

Definition at line 1036 of file bijection_tpl.h.

1036 {
1038 return *this;
1039 }

References gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::Bijection< T1, T2 >, and gum::BijectionImplementation< T1, T2, Gen >::operator=().

Here is the call graph for this function:

◆ resize()

void gum::BijectionImplementation< T1, T2, Gen >::resize ( Size new_size)
inherited

Manually resize the gum::Bijection.

See gum::HashTable::resize(gum::Size)

Parameters
new_sizeThe gum::Bijection new size.

References resize().

Referenced by resize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resizePolicy()

bool gum::BijectionImplementation< T1, T2, Gen >::resizePolicy ( ) const
noexceptinherited

Returns true if the resize policy is automatic.

See gum::HashTable::resizePolicy().

Returns
Returns true if the resize policy is automatic.

Referenced by Bijection< T1, T2 >.

Here is the caller graph for this function:

◆ second()

const T2 & gum::BijectionImplementation< T1, T2, Gen >::second ( const T1 & first) const
inherited

Returns the second value of a pair given its first value.

Parameters
firstThe first value of a pair in the gum::Bijection.
Returns
Returns the second value of a pair given its first value.
Exceptions
NotFoundRaised if the element cannot be found.

References first(), and second().

Referenced by gum::MultiDimBijArray< GUM_SCALAR >::MultiDimBijArray(), gum::MultiDimBijArray< GUM_SCALAR >::MultiDimBijArray(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), _insert_(), _insert_(), eraseSecond(), existsSecond(), first(), firstWithDefault(), insert(), insert(), second(), and secondWithDefault().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ secondWithDefault()

const T2 & gum::BijectionImplementation< T1, T2, Gen >::secondWithDefault ( const T1 & second,
const T2 & default_val ) const
inherited

Returns the second value of a pair given its first value or default_val if first is unfound.

Parameters
secondThe second value of a pair in the gum::Bijection.
default_valThe default value returned if first is not in the gum::Bijection.
Returns
Returns the second value of a pair given its first value or default_val if first is not in the bjection.

References second(), and secondWithDefault().

Referenced by secondWithDefault().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setResizePolicy()

void gum::BijectionImplementation< T1, T2, Gen >::setResizePolicy ( const bool new_policy)
noexceptinherited

Change the gum::Bijection resizing policy.

See gum::HashTable::setResizePolicy( const bool );

Parameters
new_policyIf true, the gum::Bijection will resize automatically.

References setResizePolicy().

Referenced by setResizePolicy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

Size gum::BijectionImplementation< T1, T2, Gen >::size ( ) const
noexceptinherited

Returns the number of associations stored within the gum::Bijection.

Returns
Returns the number of associations stored within the gum::Bijection.

References size().

Referenced by gum::Bijection< T1, T2 >::Bijection(), BijectionImplementation(), _insert_(), and size().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

std::string gum::BijectionImplementation< T1, T2, Gen >::toString ( ) const
inherited

Returns a friendly representatin of the gum::Bijection.

Returns
Returns a friendly representatin of the gum::Bijection.

References toString().

Referenced by toString().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _firstToSecond_

HashTable12 gum::BijectionImplementation< T1, T2, Gen >::_firstToSecond_
privateinherited

The gum::HashTable associating T2 objects to T1 objects.

Definition at line 582 of file bijection.h.

Referenced by BijectionImplementation(), BijectionImplementation(), and _insert_().

◆ _secondToFirst_

HashTable21 gum::BijectionImplementation< T1, T2, Gen >::_secondToFirst_
privateinherited

The gum::HashTable associating T1 objects to T2 objects.

Definition at line 585 of file bijection.h.

Referenced by BijectionImplementation(), BijectionImplementation(), and _insert_().


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