![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
A non scalar implementation of a Bijection. More...
#include <agrum/base/core/bijection.h>
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... Args> | |
| INLINE void | emplace (Args &&... args) |
| template<typename T1, typename T2> | |
| INLINE | BijectionImplementation (const BijectionImplementation< T1, T2, true > &toCopy) |
| template<typename T1, typename T2> | |
| INLINE | 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 iterator & | end () const noexcept |
| Returns the unsafe iterator at the end of the gum::Bijection. | |
| const const_iterator & | cend () 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_safe & | endSafe () const noexcept |
| Returns the safe iterator at the end of the gum::Bijection. | |
| const const_iterator_safe & | cendSafe () 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. | |
| 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 | |
A non scalar implementation of a Bijection.
This class is designed for modeling a gum::Bijection between two sets, the idea is following :
| T1 | The first type of elements in the gum::Bjection. |
| T2 | The second type of elements in the gum::Bjection. |
| Gen | If true, this will be replaced by a implementation omptimized for non-scalar types. |
Definition at line 104 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::const_iterator = BijectionIterator< T1, T2 > |
types for STL compliance
Definition at line 121 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::const_iterator_safe = BijectionIteratorSafe< T1, T2 > |
types for STL compliance
Definition at line 123 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::difference_type = std::ptrdiff_t |
types for STL compliance
Definition at line 119 of file bijection.h.
|
private |
Alias for more readable code.
Definition at line 563 of file bijection.h.
|
private |
Alias for more readable code.
Definition at line 564 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::iterator = BijectionIterator< T1, T2 > |
types for STL compliance
Definition at line 120 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::iterator_safe = BijectionIteratorSafe< T1, T2 > |
types for STL compliance
Definition at line 122 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::size_type = std::size_t |
types for STL compliance
Definition at line 118 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type1_const_pointer = const T1* |
types for STL compliance
Definition at line 112 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type1_const_reference = const T1& |
types for STL compliance
Definition at line 110 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type1_pointer = T1* |
types for STL compliance
Definition at line 111 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type1_reference = T1& |
types for STL compliance
Definition at line 109 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type1_type = T1 |
types for STL compliance
Definition at line 108 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type2_const_pointer = const T2* |
types for STL compliance
Definition at line 117 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type2_const_reference = const T2& |
types for STL compliance
Definition at line 115 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type2_pointer = T2* |
types for STL compliance
Definition at line 116 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type2_reference = T2& |
types for STL compliance
Definition at line 114 of file bijection.h.
| using gum::BijectionImplementation< T1, T2, Gen >::type2_type = T2 |
types for STL compliance
Definition at line 113 of file bijection.h.
|
private |
Default constructor: creates a gum::Bijection without any association.
| size | The Bijection starting size. |
| resize_policy | If true, the gum::Bijection will resize itself automatically. |
Definition at line 86 of file bijection_tpl.h.
References BijectionImplementation, _firstToSecond_, _secondToFirst_, and size().
|
private |
Initializer list constructor.
| list | The initialize list. |
Definition at line 99 of file bijection_tpl.h.
References BijectionImplementation, _firstToSecond_, _secondToFirst_, insert(), and size().
|
private |
Copy constructor.
| toCopy | Bijection to copy. |
Definition at line 112 of file bijection_tpl.h.
References BijectionImplementation, _copy_(), _firstToSecond_, _secondToFirst_, and capacity().
|
privatenoexcept |
Move constructor.
| from | Bijection to move. |
Definition at line 122 of file bijection_tpl.h.
References BijectionImplementation, _firstToSecond_, and _secondToFirst_.
| INLINE 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_().
| INLINE gum::BijectionImplementation< T1, T2, Gen >::BijectionImplementation | ( | const BijectionImplementation< T1, T2, true > & | toCopy | ) |
Definition at line 483 of file bijection_tpl.h.
|
noexcept |
Definition at line 493 of file bijection_tpl.h.
|
private |
A function that performs a complete copy of another gum::Bijection.
| source | The source from copied into this gum::Bijection. |
Definition at line 62 of file bijection_tpl.h.
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 >::BijectionImplementation(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), and operator=().
|
private |
Inserts a new association into the gum::Bijection.
Definition at line 261 of file bijection_tpl.h.
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_(), firstWithDefault(), insert(), insert(), and secondWithDefault().
|
private |
Inserts a new association into the gum::Bijection.
Definition at line 289 of file bijection_tpl.h.
References _firstToSecond_, existsFirst(), existsSecond(), first(), GUM_ERROR, and second().
| INLINE 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:
Definition at line 181 of file bijection_tpl.h.
References BijectionIterator< T1, T2 >.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE 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:
Definition at line 209 of file bijection_tpl.h.
References BijectionIteratorSafe< T1, T2 >.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
|
noexcept |
Returns the number of hashtables slots used.
Definition at line 388 of file bijection_tpl.h.
References _firstToSecond_.
Referenced by BijectionImplementation(), and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE 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:
Definition at line 188 of file bijection_tpl.h.
References BijectionIterator< T1, T2 >.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE 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:
Definition at line 216 of file bijection_tpl.h.
References BijectionIteratorSafe< T1, T2 >.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
|
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:
Definition at line 202 of file bijection_tpl.h.
References BijectionIterator< T1, T2 >.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
|
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:
Definition at line 230 of file bijection_tpl.h.
References BijectionIteratorSafe< T1, T2 >.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE void gum::BijectionImplementation< T1, T2 >::clear | ( | ) |
Removes all the associations from the gum::Bijection.
Definition at line 137 of file bijection_tpl.h.
References _firstToSecond_, and _secondToFirst_.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), operator=(), and operator=().
| void gum::BijectionImplementation< T1, T2, Gen >::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.
| args | the arguments passed to the constructor |
| DuplicateElement | exception is thrown if the association already exists |
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE void gum::BijectionImplementation< T1, T2 >::emplace | ( | Args &&... | args | ) |
Definition at line 349 of file bijection_tpl.h.
|
noexcept |
Returns true if the gum::Bijection doesn't contain any association.
Definition at line 356 of file bijection_tpl.h.
References _firstToSecond_, and _secondToFirst_.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
|
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:
Definition at line 195 of file bijection_tpl.h.
References BijectionIterator< T1, T2 >.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
|
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:
Definition at line 223 of file bijection_tpl.h.
References BijectionIteratorSafe< T1, T2 >.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE 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.
| first | The first element of a pair in the gum::Bijection. |
Definition at line 370 of file bijection_tpl.h.
References 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_().
| INLINE 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.
| second | The second element of a pair in the gum::Bijection. |
Definition at line 379 of file bijection_tpl.h.
References _firstToSecond_, _secondToFirst_, and second().
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE bool gum::BijectionImplementation< T1, T2 >::existsFirst | ( | const T1 & | first | ) | const |
Returns true if first is the first element in a pair in the gum::Bijection.
| first | The element tested for existence. |
Definition at line 248 of file bijection_tpl.h.
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::StructuredInference< GUM_SCALAR >::_translatePotSet_(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), and gum::MultiDimFunctionGraph< double >::model().
| INLINE 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.
| second | The element tested for existence. |
Definition at line 254 of file bijection_tpl.h.
References _secondToFirst_, and second().
Referenced by _insert_(), _insert_(), and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE const T1 & gum::BijectionImplementation< T1, T2 >::first | ( | const T2 & | second | ) | const |
Returns the first value of a pair given its second value.
| second | The second value of a pair in the gum::Bijection. |
| NotFound | Raised if the element cannot be found. |
Definition at line 236 of file bijection_tpl.h.
References _secondToFirst_, and second().
Referenced by gum::MultiDimICIModel< GUM_SCALAR >::MultiDimICIModel(), _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(), firstWithDefault(), insert(), insert(), second(), and secondWithDefault().
| INLINE 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.
| second | The second value of a pair in the gum::Bijection. |
| default_val | The default value returned if second is not in the gum::Bijection. |
Definition at line 317 of file bijection_tpl.h.
References _insert_(), first(), and second().
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE 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.
| first | The first element of the pair to insert. |
| second | The second element of the pair to insert. |
| DuplicateElement | Raised if the association already exists. |
Definition at line 336 of file bijection_tpl.h.
References _insert_(), first(), and second().
Referenced by BijectionImplementation(), gum::prm::PRMSlotChain< double >::PRMSlotChain(), gum::prm::gspan::Pattern::_expandCodeIsMinimal_(), gum::prm::PRMSystem< double >::_groundAgg_(), gum::prm::PRMSystem< double >::_groundTensor_(), 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::MultiDimFunctionGraph< double >::clear(), gum::prm::PRMScalarAttribute< GUM_SCALAR >::copy(), gum::IMarkovRandomField< GUM_SCALAR >::operator==(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), and gum::TreeOperatorStrategy< GUM_SCALAR >::regress().
| INLINE 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.
| first | The first element of the pair to insert. |
| second | The second element of the pair to insert. |
| DuplicateElement | Raised if the association already exists. |
Definition at line 342 of file bijection_tpl.h.
References _insert_(), first(), and second().
|
private |
Move operator.
| toCopy | Bijection to move |
Definition at line 163 of file bijection_tpl.h.
References BijectionImplementation, _firstToSecond_, _secondToFirst_, and clear().
|
private |
Copy operator.
| toCopy | Bijection to copy. |
Definition at line 147 of file bijection_tpl.h.
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=().
| INLINE void gum::BijectionImplementation< T1, T2 >::resize | ( | Size | new_size | ) |
Manually resize the gum::Bijection.
See gum::HashTable::resize(gum::Size)
| new_size | The gum::Bijection new size. |
Definition at line 394 of file bijection_tpl.h.
References _firstToSecond_, and _secondToFirst_.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
|
noexcept |
Returns true if the resize policy is automatic.
See gum::HashTable::resizePolicy().
Definition at line 409 of file bijection_tpl.h.
References _firstToSecond_.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| INLINE const T2 & gum::BijectionImplementation< T1, T2 >::second | ( | const T1 & | first | ) | const |
Returns the second value of a pair given its first value.
| first | The first value of a pair in the gum::Bijection. |
| NotFound | Raised if the element cannot be found. |
Definition at line 242 of file bijection_tpl.h.
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 >::nodeValue(), gum::IMarkovRandomField< GUM_SCALAR >::operator==(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), and secondWithDefault().
| INLINE 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.
| second | The second value of a pair in the gum::Bijection. |
| default_val | The default value returned if first is not in the gum::Bijection. |
Definition at line 327 of file bijection_tpl.h.
References _insert_(), first(), and second().
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
|
noexcept |
Change the gum::Bijection resizing policy.
See gum::HashTable::setResizePolicy( const bool );
| new_policy | If true, the gum::Bijection will resize automatically. |
Definition at line 402 of file bijection_tpl.h.
References _firstToSecond_, and _secondToFirst_.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
|
noexcept |
Returns the number of associations stored within the gum::Bijection.
Definition at line 363 of file bijection_tpl.h.
References _firstToSecond_, and _secondToFirst_.
Referenced by BijectionImplementation(), BijectionImplementation(), and gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_().
| std::string gum::BijectionImplementation< T1, T2 >::toString | ( | ) | const |
Returns a friendly representatin of the gum::Bijection.
Definition at line 415 of file bijection_tpl.h.
Referenced by gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), and gum::operator<<().
|
friend |
a friend to speed-up accesses
Definition at line 573 of file bijection.h.
Referenced by BijectionImplementation(), BijectionImplementation(), BijectionImplementation(), BijectionImplementation(), ~BijectionImplementation(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::_insert_(), operator=(), and operator=().
a friend to speed-up accesses
Definition at line 556 of file bijection.h.
Referenced by gum::Bijection< const DiscreteVariable *, const DiscreteVariable * >::Bijection(), gum::Bijection< const DiscreteVariable *, const DiscreteVariable * >::Bijection(), gum::Bijection< const DiscreteVariable *, const DiscreteVariable * >::operator=(), and gum::Bijection< const DiscreteVariable *, const DiscreteVariable * >::operator=().
|
friend |
|
friend |
a friend to speed-up accesses
Definition at line 556 of file bijection.h.
Referenced by beginSafe(), cbeginSafe(), cendSafe(), and endSafe().
|
private |
The gum::HashTable associating T2 objects to T1 objects.
Definition at line 582 of file bijection.h.
Referenced by BijectionImplementation(), BijectionImplementation(), BijectionImplementation(), BijectionImplementation(), gum::BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::BijectionImplementation(), _copy_(), _insert_(), _insert_(), capacity(), clear(), empty(), eraseSecond(), existsFirst(), operator=(), operator=(), resize(), resizePolicy(), second(), setResizePolicy(), and size().
|
private |
The gum::HashTable associating T1 objects to T2 objects.
Definition at line 585 of file bijection.h.
Referenced by BijectionImplementation(), BijectionImplementation(), BijectionImplementation(), BijectionImplementation(), _copy_(), _insert_(), clear(), empty(), eraseSecond(), existsSecond(), first(), operator=(), resize(), setResizePolicy(), and size().