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

A non scalar implementation of a Bijection. More...

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

Inheritance diagram for gum::BijectionImplementation< T1, T2, Gen >:
Collaboration diagram for gum::BijectionImplementation< T1, T2, Gen >:

Public Types

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

template<typename T1, typename T2>
 BijectionImplementation (const BijectionImplementation< T1, T2, true > &toCopy)
template<typename T1, typename T2>
 BijectionImplementation (BijectionImplementation< T1, T2, true > &&toCopy) noexcept
Constructors/destructors
 ~BijectionImplementation ()
 Destructor.
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.
template<typename K>
const T2 & second (const K &first) const
 Heterogeneous overload: accepts any type convertible to string_view when T1=std::string.
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.
template<typename K>
bool existsFirst (const K &first) const
 Heterogeneous overload: accepts any type convertible to string_view when T1=std::string.
bool existsSecond (const T2 &second) const
 Returns true if second is the second element in a pair in the gum::Bijection.
optional_ref< const T1 > tryFirst (const T2 &second) const
 Returns a pointer to the first value associated with the given second value, or nullptr if not found.
optional_ref< const T2 > trySecond (const T1 &first) const
 Returns an optional reference to the second value associated with the given first value, or empty if not found.
template<typename K>
optional_ref< const T2 > trySecond (const K &first) const
 Heterogeneous overload: accepts any type convertible to string_view when T1=std::string.
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.
template<typename... Args>
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 = HashTable< T1, T2* >
 Alias for more readable code.
using HashTable21 = HashTable< T2, T1* >
 Alias for more readable code.

Private Member Functions

 BijectionImplementation (Size size, bool resize_policy)
 Default constructor: creates a gum::Bijection without any association.
 BijectionImplementation (std::initializer_list< std::pair< T1, T2 > > list)
 Initializer list constructor.
 BijectionImplementation (const BijectionImplementation< T1, T2, Gen > &toCopy)
 Copy constructor.
 BijectionImplementation (BijectionImplementation< T1, T2, Gen > &&from) noexcept
 Move constructor.
BijectionImplementation< T1, T2, Gen > & operator= (const BijectionImplementation< T1, T2, Gen > &toCopy)
 Copy operator.
BijectionImplementation< T1, T2, Gen > & operator= (BijectionImplementation< T1, T2, Gen > &&toCopy)
 Move operator.
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.

Friends

class BijectionIteratorSafe< T1, T2 >
 a friend to speed-up accesses
class BijectionIterator< T1, T2 >
 a friend to speed-up accesses
class Bijection< T1, T2 >
 a friend to speed-up accesses
template<typename TT1, typename TT2, bool>
class BijectionImplementation
 a friend to speed-up accesses

Detailed Description

template<typename T1, typename T2, bool Gen>
class gum::BijectionImplementation< T1, T2, Gen >

A non scalar implementation of a Bijection.

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.
GenIf true, this will be replaced by a implementation omptimized for non-scalar types.

Definition at line 104 of file bijection.h.

Member Typedef Documentation

◆ const_iterator

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::const_iterator = BijectionIterator< T1, T2 >

types for STL compliance

Definition at line 121 of file bijection.h.

◆ const_iterator_safe

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::const_iterator_safe = BijectionIteratorSafe< T1, T2 >

types for STL compliance

Definition at line 123 of file bijection.h.

◆ difference_type

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::difference_type = std::ptrdiff_t

types for STL compliance

Definition at line 119 of file bijection.h.

◆ HashTable12

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::HashTable12 = HashTable< T1, T2* >
private

Alias for more readable code.

Definition at line 597 of file bijection.h.

◆ HashTable21

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::HashTable21 = HashTable< T2, T1* >
private

Alias for more readable code.

Definition at line 598 of file bijection.h.

◆ iterator

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::iterator = BijectionIterator< T1, T2 >

types for STL compliance

Definition at line 120 of file bijection.h.

◆ iterator_safe

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::iterator_safe = BijectionIteratorSafe< T1, T2 >

types for STL compliance

Definition at line 122 of file bijection.h.

◆ size_type

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::size_type = std::size_t

types for STL compliance

Definition at line 118 of file bijection.h.

◆ type1_const_pointer

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type1_const_pointer = const T1*

types for STL compliance

Definition at line 112 of file bijection.h.

◆ type1_const_reference

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type1_const_reference = const T1&

types for STL compliance

Definition at line 110 of file bijection.h.

◆ type1_pointer

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type1_pointer = T1*

types for STL compliance

Definition at line 111 of file bijection.h.

◆ type1_reference

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type1_reference = T1&

types for STL compliance

Definition at line 109 of file bijection.h.

◆ type1_type

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type1_type = T1

types for STL compliance

Definition at line 108 of file bijection.h.

◆ type2_const_pointer

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type2_const_pointer = const T2*

types for STL compliance

Definition at line 117 of file bijection.h.

◆ type2_const_reference

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type2_const_reference = const T2&

types for STL compliance

Definition at line 115 of file bijection.h.

◆ type2_pointer

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type2_pointer = T2*

types for STL compliance

Definition at line 116 of file bijection.h.

◆ type2_reference

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type2_reference = T2&

types for STL compliance

Definition at line 114 of file bijection.h.

◆ type2_type

template<typename T1, typename T2, bool Gen>
using gum::BijectionImplementation< T1, T2, Gen >::type2_type = T2

types for STL compliance

Definition at line 113 of file bijection.h.

Constructor & Destructor Documentation

◆ BijectionImplementation() [1/6]

template<typename T1, typename T2>
gum::BijectionImplementation< T1, T2 >::BijectionImplementation ( Size size,
bool resize_policy )
private

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

Parameters
sizeThe Bijection starting size.
resize_policyIf true, the gum::Bijection will resize itself automatically.

Definition at line 87 of file bijection_tpl.h.

87 :
88 // warning: below, we create the internal hashTables with a key
89 // uniqueness
90 // policy set to false because we will do the uniqueness tests ourselves
91 // (this
92 // will speed-up the process)
95 }
A non scalar implementation of a Bijection.
Definition bijection.h:104
HashTable12 _firstToSecond_
The gum::HashTable associating T2 objects to T1 objects.
Definition bijection.h:616
HashTable21 _secondToFirst_
The gum::HashTable associating T1 objects to T2 objects.
Definition bijection.h:619
Size size() const noexcept
Returns the number of associations stored within the gum::Bijection.
friend class BijectionImplementation
a friend to speed-up accesses
Definition bijection.h:607

References BijectionImplementation, _firstToSecond_, _secondToFirst_, and size().

Here is the call graph for this function:

◆ BijectionImplementation() [2/6]

template<typename T1, typename T2>
gum::BijectionImplementation< T1, T2 >::BijectionImplementation ( std::initializer_list< std::pair< T1, T2 > > list)
private

Initializer list constructor.

Parameters
listThe initialize list.

Definition at line 99 of file bijection_tpl.h.

100 :
101 _firstToSecond_(Size(list.size()) / 2, true, false),
102 _secondToFirst_(Size(list.size()) / 2, true, false) {
104
105 for (const auto& elt: list) {
107 }
108 }
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
void insert(const T1 &first, const T2 &second)
Inserts a new association in the gum::Bijection.
const T1 & first(const T2 &second) const
Returns the first value of a pair given its second value.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

References BijectionImplementation, _firstToSecond_, _secondToFirst_, insert(), and size().

Here is the call graph for this function:

◆ BijectionImplementation() [3/6]

template<typename T1, typename T2, bool Gen>
gum::BijectionImplementation< T1, T2, Gen >::BijectionImplementation ( const BijectionImplementation< T1, T2, Gen > & toCopy)
private

Copy constructor.

Parameters
toCopyBijection to copy.

Definition at line 112 of file bijection_tpl.h.

113 :
118 }
void _copy_(const HashTable< T1, T2 * > &source)
A function that performs a complete copy of another gum::Bijection.
Size capacity() const noexcept
Returns the number of slots in the 'nodes' vector of the hashtable.

References BijectionImplementation, _copy_(), _firstToSecond_, _secondToFirst_, and capacity().

Here is the call graph for this function:

◆ BijectionImplementation() [4/6]

template<typename T1, typename T2, bool Gen>
gum::BijectionImplementation< T1, T2, Gen >::BijectionImplementation ( BijectionImplementation< T1, T2, Gen > && from)
privatenoexcept

Move constructor.

Parameters
fromBijection to move.

Definition at line 122 of file bijection_tpl.h.

References BijectionImplementation, _firstToSecond_, and _secondToFirst_.

Here is the call graph for this function:

◆ ~BijectionImplementation()

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

Destructor.

Definition at line 131 of file bijection_tpl.h.

References BijectionImplementation.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ BijectionImplementation() [5/6]

template<typename T1, typename T2, bool Gen>
template<typename T1, typename T2>
gum::BijectionImplementation< T1, T2, Gen >::BijectionImplementation ( const BijectionImplementation< T1, T2, true > & toCopy)

◆ BijectionImplementation() [6/6]

template<typename T1, typename T2, bool Gen>
template<typename T1, typename T2>
gum::BijectionImplementation< T1, T2, Gen >::BijectionImplementation ( BijectionImplementation< T1, T2, true > && toCopy)
noexcept

Member Function Documentation

◆ _copy_()

template<typename T1, typename T2, bool Gen>
void gum::BijectionImplementation< T1, T2 >::_copy_ ( const HashTable< T1, T2 * > & source)
private

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.

Definition at line 63 of file bijection_tpl.h.

63 {
64 // parse f2s and perform copies
65 for (auto iter = f2s.cbegin(); iter != f2s.cend(); ++iter) {
66 typename HashTable12::value_type* val1 = &(_firstToSecond_.insert(iter.key(), nullptr));
68
69 try {
70 val2 = &(_secondToFirst_.insert(*(iter.val()), nullptr));
71 } catch (...) {
72 _firstToSecond_.erase(iter.key());
73 throw;
74 }
75
76 val1->second = &(const_cast< T2& >(val2->first));
77 val2->second = &(const_cast< T1& >(val1->first));
78 }
79
80 // note that _iter_end_ is actually a constant, whatever we add/remove
81 // to/from _firstToSecond_. As a consequence, it need not be updated
82 // after _copy_
83 }
const_iterator cbegin() const
Returns the constant unsafe iterator at the beginning of the gum::Bjection.
const const_iterator & cend() const noexcept
Returns the constant iterator at the end of the gum::Bijection.
std::pair< const T1, T2 * > value_type
Definition hashTable.h:646

References _firstToSecond_, _secondToFirst_, gum::HashTable< Key, Val >::cbegin(), and gum::HashTable< Key, Val >::cend().

Referenced by BijectionImplementation(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), and operator=().

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

◆ _insert_() [1/2]

template<typename T1, typename T2, bool Gen>
BijectionImplementation< T1, T2, Gen >::HashTable12::value_type * gum::BijectionImplementation< T1, T2, Gen >::_insert_ ( const T1 & first,
const T2 & second )
private

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.

Definition at line 305 of file bijection_tpl.h.

305 {
306 // check the uniqueness property
309 "the bijection contains an element with the same couple (" << first << "," << second
310 << ")");
311 }
312
313 // insert copies of first and second
314 typename HashTable12::value_type* val1 = &(_firstToSecond_.insert(first, nullptr));
316
317 try {
318 val2 = &(_secondToFirst_.insert(second, nullptr));
319 } catch (...) {
320 _firstToSecond_.erase(first);
321 throw;
322 }
323
324 val1->second = &(const_cast< T2& >(val2->first));
325 val2->second = &(const_cast< T1& >(val1->first));
326
327 return val1;
328 }
bool existsSecond(const T2 &second) const
Returns true if second is the second element in a pair in the gum::Bijection.
bool existsFirst(const T1 &first) const
Returns true if first is the first element in a pair in the gum::Bijection.
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References _firstToSecond_, _secondToFirst_, existsFirst(), existsSecond(), first(), GUM_ERROR, and second().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), emplace(), firstWithDefault(), insert(), and insert().

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

◆ _insert_() [2/2]

template<typename T1, typename T2, bool Gen>
BijectionImplementation< T1, T2, Gen >::HashTable12::value_type * gum::BijectionImplementation< T1, T2, Gen >::_insert_ ( T1 && first,
T2 && second )
private

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.

Definition at line 333 of file bijection_tpl.h.

333 {
334 // check the uniqueness property
337 "the bijection contains an element with the same couple (" << first << "," << second
338 << ")");
339 }
340
341 // insert copies of first and second
342 typename HashTable12::value_type* val1 = &(_firstToSecond_.insert(std::move(first), nullptr));
344
345 try {
346 val2 = &(_secondToFirst_.insert(std::move(second), nullptr));
347 } catch (...) {
348 _firstToSecond_.erase(val1->first);
349 throw;
350 }
351
352 val1->second = &(const_cast< T2& >(val2->first));
353 val2->second = &(const_cast< T1& >(val1->first));
354
355 return val1;
356 }

References _firstToSecond_, _secondToFirst_, existsFirst(), existsSecond(), first(), GUM_ERROR, and second().

Here is the call graph for this function:

◆ begin()

template<typename T1, typename T2>
BijectionImplementation< T1, T2, true >::iterator gum::BijectionImplementation< T1, T2 >::begin ( ) const

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:120

Definition at line 181 of file bijection_tpl.h.

181 {
182 return BijectionIterator< T1, T2 >{*this};
183 }
friend class BijectionIterator< T1, T2 >
a friend to speed-up accesses
Definition bijection.h:604

References BijectionIterator< T1, T2 >.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), and toString().

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

◆ beginSafe()

template<typename T1, typename T2>
BijectionImplementation< T1, T2, true >::iterator_safe gum::BijectionImplementation< T1, T2 >::beginSafe ( ) const

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
}

Definition at line 209 of file bijection_tpl.h.

209 {
211 }
friend class BijectionIteratorSafe< T1, T2 >
a friend to speed-up accesses
Definition bijection.h:603

References BijectionIteratorSafe< T1, T2 >.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ capacity()

template<typename T1, typename T2>
Size gum::BijectionImplementation< T1, T2 >::capacity ( ) const
noexcept

Returns the number of hashtables slots used.

Returns
Returns the number of hashtables slots used.

Definition at line 430 of file bijection_tpl.h.

430 {
431 return _firstToSecond_.capacity();
432 }

References _firstToSecond_.

Referenced by BijectionImplementation(), and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

Here is the caller graph for this function:

◆ cbegin()

template<typename T1, typename T2>
BijectionImplementation< T1, T2, true >::const_iterator gum::BijectionImplementation< T1, T2 >::cbegin ( ) const

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
}

Definition at line 188 of file bijection_tpl.h.

188 {
189 return BijectionIterator< T1, T2 >{*this};
190 }

References BijectionIterator< T1, T2 >.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ cbeginSafe()

template<typename T1, typename T2>
BijectionImplementation< T1, T2, true >::const_iterator_safe gum::BijectionImplementation< T1, T2 >::cbeginSafe ( ) const

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
}

Definition at line 216 of file bijection_tpl.h.

216 {
218 }

References BijectionIteratorSafe< T1, T2 >.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ cend()

template<typename T1, typename T2>
const BijectionImplementation< T1, T2, true >::const_iterator & gum::BijectionImplementation< T1, T2 >::cend ( ) const
noexcept

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
}

Definition at line 202 of file bijection_tpl.h.

202 {
203 return *(reinterpret_cast< const BijectionIterator< T1, T2 >* >(_Bijection_end_));
204 }

References BijectionIterator< T1, T2 >.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ cendSafe()

template<typename T1, typename T2>
const BijectionImplementation< T1, T2, true >::const_iterator_safe & gum::BijectionImplementation< T1, T2 >::cendSafe ( ) const
noexcept

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
}

Definition at line 230 of file bijection_tpl.h.

230 {
231 return *(reinterpret_cast< const BijectionIteratorSafe< T1, T2 >* >(_Bijection_end_safe_));
232 }

References BijectionIteratorSafe< T1, T2 >.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ clear()

template<typename T1, typename T2>
void gum::BijectionImplementation< T1, T2 >::clear ( )

Removes all the associations from the gum::Bijection.

Definition at line 137 of file bijection_tpl.h.

137 {
138 _firstToSecond_.clear();
139 _secondToFirst_.clear();
140 // note that _iter_end_ is actually a constant, whatever we add/remove
141 // to/from _firstToSecond_. As a consequence, it need not be updated
142 // after the clear's
143 }

References _firstToSecond_, and _secondToFirst_.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), operator=(), and operator=().

Here is the caller graph for this function:

◆ emplace()

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

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

Definition at line 391 of file bijection_tpl.h.

391 {
394 }
HashTable12::value_type * _insert_(const T1 &first, const T2 &second)
Inserts a new association into the gum::Bijection.

References _insert_().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ empty()

template<typename T1, typename T2>
bool gum::BijectionImplementation< T1, T2 >::empty ( ) const
noexcept

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

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

Definition at line 398 of file bijection_tpl.h.

398 {
399 GUM_ASSERT(_firstToSecond_.empty() == _secondToFirst_.empty());
400 return _firstToSecond_.empty();
401 }

References _firstToSecond_, and _secondToFirst_.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

Here is the caller graph for this function:

◆ end()

template<typename T1, typename T2>
const BijectionImplementation< T1, T2, true >::iterator & gum::BijectionImplementation< T1, T2 >::end ( ) const
noexcept

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
}

Definition at line 195 of file bijection_tpl.h.

195 {
196 return *(reinterpret_cast< const BijectionIterator< T1, T2 >* >(_Bijection_end_));
197 }

References BijectionIterator< T1, T2 >.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), and toString().

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

◆ endSafe()

template<typename T1, typename T2>
const BijectionImplementation< T1, T2, true >::iterator_safe & gum::BijectionImplementation< T1, T2 >::endSafe ( ) const
noexcept

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
}

Definition at line 223 of file bijection_tpl.h.

223 {
224 return *(reinterpret_cast< const BijectionIteratorSafe< T1, T2 >* >(_Bijection_end_safe_));
225 }

References BijectionIteratorSafe< T1, T2 >.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ eraseFirst()

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

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.

Definition at line 412 of file bijection_tpl.h.

412 {
413 if (auto ptr = _firstToSecond_.tryGet(first)) {
414 _secondToFirst_.erase(**ptr);
415 _firstToSecond_.erase(first);
416 }
417 }

References _firstToSecond_, _secondToFirst_, and first().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), gum::prm::gspan::Pattern::_not_rec_(), and gum::prm::gspan::Pattern::_rec_().

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

◆ eraseSecond()

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

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.

Definition at line 421 of file bijection_tpl.h.

421 {
422 if (auto ptr = _secondToFirst_.tryGet(second)) {
423 _firstToSecond_.erase(**ptr);
424 _secondToFirst_.erase(second);
425 }
426 }

References _secondToFirst_, and second().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ existsFirst() [1/2]

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

Heterogeneous overload: accepts any type convertible to string_view when T1=std::string.

Definition at line 264 of file bijection_tpl.h.

264 {
265 return _firstToSecond_.exists(first);
266 }

References _firstToSecond_, existsFirst(), and first().

Here is the call graph for this function:

◆ existsFirst() [2/2]

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

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.

Definition at line 256 of file bijection_tpl.h.

256 {
257 return _firstToSecond_.exists(first);
258 }

Referenced by _insert_(), _insert_(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), gum::prm::gspan::Pattern::_not_rec_(), gum::prm::gspan::Pattern::_rec_(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), and existsFirst().

Here is the caller graph for this function:

◆ existsSecond()

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

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.

Definition at line 270 of file bijection_tpl.h.

270 {
271 return _secondToFirst_.exists(second);
272 }

References _secondToFirst_, and second().

Referenced by _insert_(), _insert_(), and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ first()

template<typename T1, typename T2, bool Gen>
const T1 & gum::BijectionImplementation< T1, T2 >::first ( const T2 & second) const

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.

Definition at line 236 of file bijection_tpl.h.

236 {
237 return *(_secondToFirst_[second]);
238 }

References _secondToFirst_, and second().

Referenced by _insert_(), _insert_(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), gum::prm::gspan::Pattern::_not_rec_(), gum::prm::gspan::Pattern::_rec_(), gum::prm::StructuredInference< GUM_SCALAR >::_translatePotSet_(), eraseFirst(), existsFirst(), insert(), insert(), second(), second(), secondWithDefault(), toString(), trySecond(), and trySecond().

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

◆ firstWithDefault()

template<typename T1, typename T2, bool Gen>
const T1 & gum::BijectionImplementation< T1, T2 >::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.

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.

Definition at line 361 of file bijection_tpl.h.

362 {
363 if (auto ptr = tryFirst(second)) return *ptr;
364 return _insert_(val, second)->first;
365 }
optional_ref< const T1 > tryFirst(const T2 &second) const
Returns a pointer to the first value associated with the given second value, or nullptr if not found.

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

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ insert() [1/2]

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

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.

Definition at line 378 of file bijection_tpl.h.

378 {
380 }

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

Referenced by BijectionImplementation(), gum::prm::PRMSlotChain< GUM_SCALAR >::_copyLastElt_(), gum::prm::gspan::Pattern::_expandCodeIsMinimal_(), gum::prm::PRMSystem< GUM_SCALAR >::_groundTensor_(), gum::prm::PRMSystem< double >::_groundTensor_(), gum::prm::PRMClass< GUM_SCALAR >::_inheritClass_(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), gum::prm::gspan::Pattern::_not_rec_(), gum::prm::gspan::Pattern::_rec_(), gum::prm::GSpan< GUM_SCALAR >::_sortNodesAndEdges_(), gum::prm::StructuredInference< GUM_SCALAR >::_translatePotSet_(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::IMarkovRandomField< GUM_SCALAR >::operator==(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), and gum::TreeOperatorStrategy< GUM_ELEMENT >::regress().

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

◆ insert() [2/2]

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

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.

Definition at line 384 of file bijection_tpl.h.

384 {
386 }

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

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename T1, typename T2, bool Gen>
BijectionImplementation< T1, T2, Gen > & gum::BijectionImplementation< T1, T2, Gen >::operator= ( BijectionImplementation< T1, T2, Gen > && toCopy)
private

Move operator.

Parameters
toCopyBijection to move
Returns
Returns the moved gum::Bijection in which the move was made.

Definition at line 163 of file bijection_tpl.h.

164 {
165 // avoid self assignment
166 if (this != &from) {
167 clear();
170 }
171
172 // note that _iter_end_ is actually a constant, whatever we add/remove
173 // to/from _firstToSecond_. As a consequence, it need not be updated
174 // after _copy_
175 return *this;
176 }
void clear()
Removes all the associations from the gum::Bijection.

References BijectionImplementation, _firstToSecond_, _secondToFirst_, and clear().

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename T1, typename T2, bool Gen>
BijectionImplementation< T1, T2, Gen > & gum::BijectionImplementation< T1, T2, Gen >::operator= ( const BijectionImplementation< T1, T2, Gen > & toCopy)
private

Copy operator.

Parameters
toCopyBijection to copy.
Returns
Returns the gum::Bijection in which the copy was made.

Definition at line 147 of file bijection_tpl.h.

148 {
149 // avoid self assignment
150 if (this != &toCopy) {
151 clear();
153 }
154
155 // note that _iter_end_ is actually a constant, whatever we add/remove
156 // to/from _firstToSecond_. As a consequence, it need not be updated
157 // after _copy_
158 return *this;
159 }

References BijectionImplementation, _copy_(), _firstToSecond_, and clear().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), gum::Bijection< T1, T2 >::operator=(), and gum::Bijection< T1, T2 >::operator=().

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

◆ resize()

template<typename T1, typename T2>
void gum::BijectionImplementation< T1, T2 >::resize ( Size new_size)

Manually resize the gum::Bijection.

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

Parameters
new_sizeThe gum::Bijection new size.

Definition at line 436 of file bijection_tpl.h.

436 {
439 }

References _firstToSecond_, and _secondToFirst_.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

Here is the caller graph for this function:

◆ resizePolicy()

template<typename T1, typename T2>
bool gum::BijectionImplementation< T1, T2 >::resizePolicy ( ) const
noexcept

Returns true if the resize policy is automatic.

See gum::HashTable::resizePolicy().

Returns
Returns true if the resize policy is automatic.

Definition at line 450 of file bijection_tpl.h.

450 {
451 return _firstToSecond_.resizePolicy();
452 }

References _firstToSecond_.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

Here is the caller graph for this function:

◆ second() [1/2]

template<typename T1, typename T2, bool Gen>
template<typename K>
const T2 & gum::BijectionImplementation< T1, T2, Gen >::second ( const K & first) const

Heterogeneous overload: accepts any type convertible to string_view when T1=std::string.

Definition at line 250 of file bijection_tpl.h.

250 {
251 return *(_firstToSecond_[first]);
252 }

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

Here is the call graph for this function:

◆ second() [2/2]

template<typename T1, typename T2, bool Gen>
const T2 & gum::BijectionImplementation< T1, T2, Gen >::second ( const T1 & first) const

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.

Definition at line 242 of file bijection_tpl.h.

242 {
243 return *(_firstToSecond_[first]);
244 }

References _firstToSecond_, and first().

Referenced by _insert_(), _insert_(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), gum::prm::gspan::Pattern::_not_rec_(), gum::prm::gspan::Pattern::_rec_(), gum::prm::PRMFormAttribute< GUM_SCALAR >::copyCpf(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copyCpf(), gum::prm::copyTensor(), eraseSecond(), existsSecond(), first(), firstWithDefault(), insert(), insert(), gum::MultiDimFunctionGraph< double >::node(), gum::IMarkovRandomField< GUM_SCALAR >::operator==(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), second(), and tryFirst().

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

◆ secondWithDefault()

template<typename T1, typename T2, bool Gen>
const T2 & gum::BijectionImplementation< T1, 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.

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.

Definition at line 370 of file bijection_tpl.h.

371 {
372 if (auto ptr = trySecond(first)) return *ptr;
373 return *(_insert_(first, val)->second);
374 }
optional_ref< const T2 > trySecond(const T1 &first) const
Returns an optional reference to the second value associated with the given first value,...

References first().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

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

◆ setResizePolicy()

template<typename T1, typename T2>
void gum::BijectionImplementation< T1, T2 >::setResizePolicy ( const bool new_policy)
noexcept

Change the gum::Bijection resizing policy.

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

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

Definition at line 443 of file bijection_tpl.h.

443 {
444 _firstToSecond_.setResizePolicy(new_policy);
445 _secondToFirst_.setResizePolicy(new_policy);
446 }

References _firstToSecond_, and _secondToFirst_.

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

Here is the caller graph for this function:

◆ size()

template<typename T1, typename T2>
Size gum::BijectionImplementation< T1, T2 >::size ( ) const
noexcept

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

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

Definition at line 405 of file bijection_tpl.h.

405 {
407 return _firstToSecond_.size();
408 }

Referenced by BijectionImplementation(), BijectionImplementation(), and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().

Here is the caller graph for this function:

◆ toString()

template<typename T1, typename T2>
std::string gum::BijectionImplementation< T1, T2 >::toString ( ) const

Returns a friendly representatin of the gum::Bijection.

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

Definition at line 456 of file bijection_tpl.h.

456 {
458 stream << "{ ";
459 bool first = true;
460
461 for (iterator iter = begin(); iter != end(); ++iter) {
462 if (!first) stream << ", ";
463 else first = false;
464
465 stream << '(' << iter.first() << " <-> " << iter.second() << ')';
466 }
467
468 stream << " }";
469 return stream.str();
470 }
const iterator & end() const noexcept
Returns the unsafe iterator at the end of the gum::Bijection.
iterator begin() const
Returns the unsafe iterator at the beginning of the gum::Bijection.

References begin(), end(), and first().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), and gum::operator<<().

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

◆ tryFirst()

template<typename T1, typename T2, bool Gen>
optional_ref< const T1 > gum::BijectionImplementation< T1, T2 >::tryFirst ( const T2 & second) const

Returns a pointer to the first value associated with the given second value, or nullptr if not found.

Parameters
secondThe second value to look up.
Returns
A pointer to the first value, or nullptr if not found.

Definition at line 277 of file bijection_tpl.h.

277 {
278 auto ptr = _secondToFirst_.tryGet(second);
279 if (!ptr) return {};
281 }

References second().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), and firstWithDefault().

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

◆ trySecond() [1/2]

template<typename T1, typename T2, bool Gen>
template<typename K>
optional_ref< const T2 > gum::BijectionImplementation< T1, T2, Gen >::trySecond ( const K & first) const

Heterogeneous overload: accepts any type convertible to string_view when T1=std::string.

Definition at line 296 of file bijection_tpl.h.

296 {
297 auto ptr = _firstToSecond_.tryGet(first);
298 if (!ptr) return {};
300 }

References _firstToSecond_, first(), and trySecond().

Here is the call graph for this function:

◆ trySecond() [2/2]

template<typename T1, typename T2, bool Gen>
optional_ref< const T2 > gum::BijectionImplementation< T1, T2, Gen >::trySecond ( const T1 & first) const

Returns an optional reference to the second value associated with the given first value, or empty if not found.

Parameters
firstThe first value to look up.
Returns
An optional_ref to the second value, or empty if not found.

Definition at line 286 of file bijection_tpl.h.

286 {
287 auto ptr = _firstToSecond_.tryGet(first);
288 if (!ptr) return {};
290 }

References _firstToSecond_, and first().

Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), and trySecond().

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

◆ BijectionImplementation

template<typename T1, typename T2, bool Gen>
template<typename TT1, typename TT2, bool>
friend class BijectionImplementation
friend

◆ Bijection< T1, T2 >

◆ BijectionIterator< T1, T2 >

template<typename T1, typename T2, bool Gen>
friend class BijectionIterator< T1, T2 >
friend

a friend to speed-up accesses

Definition at line 590 of file bijection.h.

Referenced by begin(), cbegin(), cend(), and end().

◆ BijectionIteratorSafe< T1, T2 >

template<typename T1, typename T2, bool Gen>
friend class BijectionIteratorSafe< T1, T2 >
friend

a friend to speed-up accesses

Definition at line 590 of file bijection.h.

Referenced by beginSafe(), cbeginSafe(), cendSafe(), and endSafe().

Member Data Documentation

◆ _firstToSecond_

◆ _secondToFirst_

template<typename T1, typename T2, bool Gen>
HashTable21 gum::BijectionImplementation< T1, T2, Gen >::_secondToFirst_
private

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