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

Safe iterators for bijectionIterator. More...

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

Public Types

using iterator_category = std::forward_iterator_tag
 types for STL compliance
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 difference_type = std::ptrdiff_t
 types for STL compliance

Public Member Functions

template<bool Gen>
INLINE BijectionIteratorSafe (const BijectionImplementation< T1, T2, Gen > &bijection)
 Constructor.
Constructors and destructors
 BijectionIteratorSafe () noexcept
 Default constructor.
 BijectionIteratorSafe (const Bijection< T1, T2 > &bijection)
 Begin constructor.
 BijectionIteratorSafe (const BijectionIteratorSafe< T1, T2 > &from)
 Copy constructor.
 BijectionIteratorSafe (BijectionIteratorSafe< T1, T2 > &&from) noexcept
 Move constructor.
 ~BijectionIteratorSafe () noexcept
 Class destructor.
Operators
BijectionIteratorSafe< T1, T2 > & operator= (const BijectionIteratorSafe< T1, T2 > &toCopy)
 Copy operator.
BijectionIteratorSafe< T1, T2 > & operator= (BijectionIteratorSafe< T1, T2 > &&toMove) noexcept
 Move operator.
BijectionIteratorSafe< T1, T2 > & operator++ () noexcept
 Go to the next association, if it exists.
BijectionIteratorSafe< T1, T2 > & operator+= (Size nb) noexcept
 Moves the iterator by nb elements.
BijectionIteratorSafe< T1, T2 > operator+ (Size nb) noexcept
 Returns a new iterator.
bool operator!= (const BijectionIteratorSafe< T1, T2 > &toCompare) const noexcept
 Inequality operator.
bool operator== (const BijectionIteratorSafe< T1, T2 > &toCompare) const noexcept
 Equality operator.
Accessors/Modifiers
const T1 & first () const
 Returns the first element of the current association.
const T2 & second () const
 Returns the second element of the current association.

Private Types

using Getter = BijectionIteratorGet< std::is_scalar< T1 >::value && std::is_scalar< T2 >::value >
 Dummy classes that will enable discriminate without overhead between scalars and non-scalars functions second in iterators.
using HashTable12
 Alias for one of the internal gum::HashTable of the gum::Bijection.
using HashIter = typename HashTable12::const_iterator_safe
 Alias for one of the internal gum::HastTableIterator of the gum::Bijection.

Private Member Functions

template<bool Gen>
 BijectionIteratorSafe (const BijectionImplementation< T1, T2, Gen > &bijection)
 Begin constructor.

Private Attributes

HashIter _iter_
 The hashTable iterator that actually does all the job.

Friends

template<typename TT1, typename TT2, bool>
class BijectionImplementation

Detailed Description

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

Safe iterators for bijectionIterator.

Template Parameters
T1The first type of elements in the gum::Bjection.
T2The second type of elements in the gum::Bjection.

Definition at line 1194 of file bijection.h.

Member Typedef Documentation

◆ difference_type

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

types for STL compliance

Definition at line 1212 of file bijection.h.

◆ Getter

template<typename T1, typename T2>
using gum::BijectionIteratorSafe< T1, T2 >::Getter = BijectionIteratorGet< std::is_scalar< T1 >::value && std::is_scalar< T2 >::value >
private

Dummy classes that will enable discriminate without overhead between scalars and non-scalars functions second in iterators.

Definition at line 1220 of file bijection.h.

◆ HashIter

template<typename T1, typename T2>
using gum::BijectionIteratorSafe< T1, T2 >::HashIter = typename HashTable12::const_iterator_safe
private

Alias for one of the internal gum::HastTableIterator of the gum::Bijection.

Definition at line 1374 of file bijection.h.

◆ HashTable12

template<typename T1, typename T2>
using gum::BijectionIteratorSafe< T1, T2 >::HashTable12
private
Initial value:
typename std::conditional< std::is_scalar< T1 >::value && std::is_scalar< T2 >::value,
The class for generic Hash Tables.
Definition hashTable.h:637

Alias for one of the internal gum::HashTable of the gum::Bijection.

Definition at line 1367 of file bijection.h.

◆ iterator_category

template<typename T1, typename T2>
using gum::BijectionIteratorSafe< T1, T2 >::iterator_category = std::forward_iterator_tag

types for STL compliance

Definition at line 1201 of file bijection.h.

◆ type1_const_pointer

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

types for STL compliance

Definition at line 1206 of file bijection.h.

◆ type1_const_reference

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

types for STL compliance

Definition at line 1204 of file bijection.h.

◆ type1_pointer

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

types for STL compliance

Definition at line 1205 of file bijection.h.

◆ type1_reference

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

types for STL compliance

Definition at line 1203 of file bijection.h.

◆ type1_type

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

types for STL compliance

Definition at line 1202 of file bijection.h.

◆ type2_const_pointer

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

types for STL compliance

Definition at line 1211 of file bijection.h.

◆ type2_const_reference

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

types for STL compliance

Definition at line 1209 of file bijection.h.

◆ type2_pointer

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

types for STL compliance

Definition at line 1210 of file bijection.h.

◆ type2_reference

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

types for STL compliance

Definition at line 1208 of file bijection.h.

◆ type2_type

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

types for STL compliance

Definition at line 1207 of file bijection.h.

Constructor & Destructor Documentation

◆ BijectionIteratorSafe() [1/6]

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

Begin constructor.

By default, the iterator points to the starting point of the gum::Bijection.

Parameters
bijectionThe gum::Bijection to iterate onto.

References BijectionIteratorSafe(), _iter_, and BijectionImplementation.

Referenced by BijectionIteratorSafe(), BijectionIteratorSafe(), BijectionIteratorSafe(), BijectionIteratorSafe(), BijectionIteratorSafe(), ~BijectionIteratorSafe(), operator!=(), operator+(), operator++(), operator=(), operator=(), and operator==().

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

◆ BijectionIteratorSafe() [2/6]

template<typename T1, typename T2>
INLINE gum::BijectionIteratorSafe< T1, T2 >::BijectionIteratorSafe ( )
explicitnoexcept

Default constructor.

Definition at line 775 of file bijection_tpl.h.

775 {
777 }
Safe iterators for bijectionIterator.
Definition bijection.h:1194
BijectionIteratorSafe(const BijectionImplementation< T1, T2, Gen > &bijection)
Begin constructor.

References BijectionIteratorSafe().

Here is the call graph for this function:

◆ BijectionIteratorSafe() [3/6]

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

Begin constructor.

Constructor.

By default, the iterator points to the starting point of the gum::Bijection.

Parameters
bijectionThe gum::Bijection to iterate onto.

Definition at line 791 of file bijection_tpl.h.

791 :
792 _iter_{bijection._firstToSecond_.cbeginSafe()} {
794 }
HashIter _iter_
The hashTable iterator that actually does all the job.
Definition bijection.h:1377

References BijectionIteratorSafe(), and _iter_.

Here is the call graph for this function:

◆ BijectionIteratorSafe() [4/6]

template<typename T1, typename T2>
INLINE gum::BijectionIteratorSafe< T1, T2 >::BijectionIteratorSafe ( const BijectionIteratorSafe< T1, T2 > & from)

Copy constructor.

Parameters
fromThe gum::BijectionIteratorSafe to copy.

Definition at line 798 of file bijection_tpl.h.

References BijectionIteratorSafe(), and _iter_.

Here is the call graph for this function:

◆ BijectionIteratorSafe() [5/6]

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

Move constructor.

move constructor

Parameters
fromThe gum::BijectionIteratorSafe to move.

Definition at line 805 of file bijection_tpl.h.

References BijectionIteratorSafe(), and _iter_.

Here is the call graph for this function:

◆ ~BijectionIteratorSafe()

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

Class destructor.

Destructor.

Definition at line 812 of file bijection_tpl.h.

References BijectionIteratorSafe().

Here is the call graph for this function:

◆ BijectionIteratorSafe() [6/6]

template<typename T1, typename T2>
template<bool Gen>
INLINE gum::BijectionIteratorSafe< T1, T2 >::BijectionIteratorSafe ( const BijectionImplementation< T1, T2, Gen > & bijection)

Constructor.

Definition at line 782 of file bijection_tpl.h.

783 :
784 _iter_{bijection._firstToSecond_.cbeginSafe()} {
786 }

Member Function Documentation

◆ first()

template<typename T1, typename T2>
INLINE const T1 & gum::BijectionIteratorSafe< T1, T2 >::first ( ) const

Returns the first element of the current association.

return the first element of the current association

Returns
Returns the first element of the current association.
Exceptions
UndefinedIteratorValueRaised when the iterator does not point to a valid element of the bijection.

Definition at line 870 of file bijection_tpl.h.

870 {
871 return _iter_.key();
872 }

References _iter_.

◆ operator!=()

template<typename T1, typename T2>
INLINE bool gum::BijectionIteratorSafe< T1, T2 >::operator!= ( const BijectionIteratorSafe< T1, T2 > & toCompare) const
noexcept

Inequality operator.

Comparison of iterators.

Parameters
toCompareThe gum::BijectionIteratorSafe to compare.
Returns
Returns true if they differ.

Definition at line 856 of file bijection_tpl.h.

857 {
858 return _iter_ != toCompare._iter_;
859 }

References BijectionIteratorSafe(), and _iter_.

Here is the call graph for this function:

◆ operator+()

template<typename T1, typename T2>
INLINE BijectionIteratorSafe< T1, T2 > gum::BijectionIteratorSafe< T1, T2 >::operator+ ( Size nb)
noexcept

Returns a new iterator.

returns a new iterator

If the iterator points to end(), the resulting iterator also points to end (). If there are nb or fewer elements to parse to reach the end of the bijection, then the resulting iterator points to gum::BijectionIteratorSafe::end().

Parameters
nbThe number of steps by wich the iterator moves.
Returns
Returns this gum::BijectionIteratorSafe.

Definition at line 850 of file bijection_tpl.h.

850 {
851 return BijectionIteratorSafe< T1, T2 >{*this} += nb;
852 }

References BijectionIteratorSafe().

Here is the call graph for this function:

◆ operator++()

template<typename T1, typename T2>
INLINE BijectionIteratorSafe< T1, T2 > & gum::BijectionIteratorSafe< T1, T2 >::operator++ ( )
noexcept

Go to the next association, if it exists.

Go to the next association (if exists).

If the iterator points to end(), nothing happens.

Returns
Returns this gum::BijectionIteratorSafe.

Definition at line 834 of file bijection_tpl.h.

834 {
835 ++_iter_;
836 return *this;
837 }

References BijectionIteratorSafe(), and _iter_.

Here is the call graph for this function:

◆ operator+=()

template<typename T1, typename T2>
INLINE BijectionIteratorSafe< T1, T2 > & gum::BijectionIteratorSafe< T1, T2 >::operator+= ( Size nb)
noexcept

Moves the iterator by nb elements.

moves the iterator by nb elements

If the iterator points to end(), nothing is done. If there are nb or fewer elements to parse to reach the end of the bijection, then this method makes the iterator point to gum::BijectionIteratorSafe::end().

Parameters
nbThe number of steps by wich the iterator moves.
Returns
Returns this gum::BijectionIteratorSafe.

Definition at line 842 of file bijection_tpl.h.

842 {
843 _iter_ += nb;
844 return *this;
845 }

References _iter_.

◆ operator=() [1/2]

template<typename T1, typename T2>
INLINE BijectionIteratorSafe< T1, T2 > & gum::BijectionIteratorSafe< T1, T2 >::operator= ( BijectionIteratorSafe< T1, T2 > && toMove)
noexcept

Move operator.

move operator

Parameters
toMoveThe gum::BijectionIteratorSafe to move.
Returns
Returns this gum::BijectionIteratorSafe.

Definition at line 826 of file bijection_tpl.h.

827 {
829 return *this;
830 }

References BijectionIteratorSafe(), and _iter_.

Here is the call graph for this function:

◆ operator=() [2/2]

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

Copy operator.

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

Definition at line 819 of file bijection_tpl.h.

819 {
821 return *this;
822 }

References BijectionIteratorSafe(), and _iter_.

Here is the call graph for this function:

◆ operator==()

template<typename T1, typename T2>
INLINE bool gum::BijectionIteratorSafe< T1, T2 >::operator== ( const BijectionIteratorSafe< T1, T2 > & toCompare) const
noexcept

Equality operator.

Comparison of iterators.

Parameters
toCompareThe gum::BijectionIteratorSafe to compare.
Returns
Returns true if they are equal.

Definition at line 863 of file bijection_tpl.h.

864 {
865 return _iter_ == toCompare._iter_;
866 }

References BijectionIteratorSafe(), and _iter_.

Here is the call graph for this function:

◆ second()

template<typename T1, typename T2>
INLINE const T2 & gum::BijectionIteratorSafe< T1, T2 >::second ( ) const

Returns the second element of the current association.

return the second element of the current association

Returns
Returns the second element of the current association.
Exceptions
UndefinedIteratorValueRaised when the iterator does not point to a valid element of the bijection.

Definition at line 876 of file bijection_tpl.h.

876 {
877 return Getter::op_second(_iter_.val());
878 }
static INLINE const T & op_second(const T *x)
Returns a refeence over a pointer.
Definition bijection.h:1153

References _iter_, and gum::BijectionIteratorGet< gen >::op_second().

Here is the call graph for this function:

◆ BijectionImplementation

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

Definition at line 1196 of file bijection.h.

References BijectionImplementation.

Referenced by BijectionIteratorSafe(), and BijectionImplementation.

Member Data Documentation

◆ _iter_

template<typename T1, typename T2>
HashIter gum::BijectionIteratorSafe< T1, T2 >::_iter_
private

The hashTable iterator that actually does all the job.

Definition at line 1377 of file bijection.h.

Referenced by BijectionIteratorSafe(), BijectionIteratorSafe(), BijectionIteratorSafe(), BijectionIteratorSafe(), first(), operator!=(), operator++(), operator+=(), operator=(), operator=(), operator==(), and second().


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