aGrUM  0.13.2
gum::BijectionIteratorSafe< T1, T2 > Class Template Reference

Safe iterators for bijectionIterator. More...

#include <agrum/core/bijection.h>

Public Member Functions

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

Public Types

using iterator_category = std::forward_iterator_tag
 types for STL compliance More...
 
using type1_type = T1
 types for STL compliance More...
 
using type1_reference = T1 &
 types for STL compliance More...
 
using type1_const_reference = const T1 &
 types for STL compliance More...
 
using type1_pointer = T1 *
 types for STL compliance More...
 
using type1_const_pointer = const T1 *
 types for STL compliance More...
 
using type2_type = T2
 types for STL compliance More...
 
using type2_reference = T2 &
 types for STL compliance More...
 
using type2_const_reference = const T2 &
 types for STL compliance More...
 
using type2_pointer = T2 *
 types for STL compliance More...
 
using type2_const_pointer = const T2 *
 types for STL compliance More...
 
using difference_type = std::ptrdiff_t
 types for STL compliance More...
 

Friends

template<typename TT1 , typename TT2 , typename Alloc , 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 1409 of file bijection.h.

Member Typedef Documentation

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

types for STL compliance

Definition at line 1427 of file bijection.h.

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 1436 of file bijection.h.

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 1588 of file bijection.h.

template<typename T1, typename T2>
using gum::BijectionIteratorSafe< T1, T2 >::HashTable12 = typename std::conditional< std::is_scalar< T1 >::value && std::is_scalar< T2 >::value, HashTable< T1, T2, std::allocator< std::pair< T1, T2 > > >, HashTable< T1, T2*, std::allocator< std::pair< T1, T2* > > > >::type
private

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

Definition at line 1584 of file bijection.h.

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

types for STL compliance

Definition at line 1416 of file bijection.h.

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

types for STL compliance

Definition at line 1421 of file bijection.h.

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

types for STL compliance

Definition at line 1419 of file bijection.h.

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

types for STL compliance

Definition at line 1420 of file bijection.h.

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

types for STL compliance

Definition at line 1418 of file bijection.h.

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

types for STL compliance

Definition at line 1417 of file bijection.h.

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

types for STL compliance

Definition at line 1426 of file bijection.h.

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

types for STL compliance

Definition at line 1424 of file bijection.h.

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

types for STL compliance

Definition at line 1425 of file bijection.h.

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

types for STL compliance

Definition at line 1423 of file bijection.h.

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

types for STL compliance

Definition at line 1422 of file bijection.h.

Constructor & Destructor Documentation

template<typename T1, typename T2>
template<typename Alloc , bool Gen>
gum::BijectionIteratorSafe< T1, T2 >::BijectionIteratorSafe ( const BijectionImplementation< T1, T2, Alloc, 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.
template<typename T1 , typename T2 >
INLINE gum::BijectionIteratorSafe< T1, T2 >::BijectionIteratorSafe ( )
noexcept

Default constructor.

Definition at line 917 of file bijection_tpl.h.

917  {
918  GUM_CONSTRUCTOR(BijectionIteratorSafe);
919  }
BijectionIteratorSafe() noexcept
Default constructor.
template<typename T1, typename T2>
template<typename Alloc >
gum::BijectionIteratorSafe< T1, T2 >::BijectionIteratorSafe ( const Bijection< T1, T2, Alloc > &  bijection)

Genereliazed default constructor.

Template Parameters
AllocThe gum::Bijection allocator's type.
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 941 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter.

942  :
943  __iter{toCopy.__iter} {
944  GUM_CONS_CPY(BijectionIteratorSafe);
945  }
BijectionIteratorSafe() noexcept
Default constructor.
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591
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 949 of file bijection_tpl.h.

950  :
951  __iter{std::move(from.__iter)} {
952  GUM_CONS_MOV(BijectionIteratorSafe);
953  }
BijectionIteratorSafe() noexcept
Default constructor.
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591
template<typename T1 , typename T2 >
INLINE gum::BijectionIteratorSafe< T1, T2 >::~BijectionIteratorSafe ( )
noexcept

Class destructor.

Destructor.

Definition at line 957 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::operator=().

957  {
958  GUM_DESTRUCTOR(BijectionIteratorSafe);
959  }
BijectionIteratorSafe() noexcept
Default constructor.

+ Here is the call graph for this function:

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

Constructor.

Definition at line 924 of file bijection_tpl.h.

References gum::BijectionImplementation< T1, T2, Alloc, Gen >::__firstToSecond.

925  :
926  __iter{bijection.__firstToSecond.cbeginSafe()} {
927  GUM_CONSTRUCTOR(BijectionIteratorSafe);
928  }
BijectionIteratorSafe() noexcept
Default constructor.
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591
template<typename T1, typename T2>
template<typename Alloc >
INLINE gum::BijectionIteratorSafe< T1, T2 >::BijectionIteratorSafe ( const Bijection< T1, T2, Alloc > &  bijection)

Constructor.

Definition at line 933 of file bijection_tpl.h.

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

934  :
935  __iter{bijection.__firstToSecond.cbeginSafe()} {
936  GUM_CONSTRUCTOR(BijectionIteratorSafe);
937  }
BijectionIteratorSafe() noexcept
Default constructor.
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591

+ Here is the call graph for this function:

Member Function Documentation

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 1016 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter.

Referenced by gum::MultiDimBucket< GUM_SCALAR >::_replace(), and gum::ExactTerminalNodePolicy< GUM_SCALAR >::id().

1016  {
1017  return __iter.key();
1018  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591

+ Here is the caller graph for this function:

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 1003 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter, and gum::BijectionIteratorSafe< T1, T2 >::operator==().

Referenced by gum::BijectionIteratorSafe< T1, T2 >::operator+().

1003  {
1004  return __iter != toCompare.__iter;
1005  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T1 , typename T2 >
INLINE BijectionIteratorSafe< T1, T2 > gum::BijectionIteratorSafe< T1, T2 >::operator+ ( unsigned int  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 996 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::operator!=().

Referenced by gum::BijectionIteratorSafe< T1, T2 >::operator+=().

996  {
997  return BijectionIteratorSafe< T1, T2 >{*this} += nb;
998  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 980 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter, and gum::BijectionIteratorSafe< T1, T2 >::operator+=().

Referenced by gum::BijectionIteratorSafe< T1, T2 >::operator=().

980  {
981  ++__iter;
982  return *this;
983  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T1 , typename T2 >
INLINE BijectionIteratorSafe< T1, T2 > & gum::BijectionIteratorSafe< T1, T2 >::operator+= ( unsigned int  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 988 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter, and gum::BijectionIteratorSafe< T1, T2 >::operator+().

Referenced by gum::BijectionIteratorSafe< T1, T2 >::operator++().

988  {
989  __iter += nb;
990  return *this;
991  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 964 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter.

Referenced by gum::BijectionIteratorSafe< T1, T2 >::~BijectionIteratorSafe().

964  {
965  __iter = toCopy.__iter;
966  return *this;
967  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591

+ Here is the caller graph for this function:

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 972 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter, and gum::BijectionIteratorSafe< T1, T2 >::operator++().

972  {
973  __iter = std::move(toCopy.__iter);
974  return *this;
975  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591

+ Here is the call graph for this function:

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 1010 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter.

Referenced by gum::BijectionIteratorSafe< T1, T2 >::operator!=().

1010  {
1011  return __iter == toCompare.__iter;
1012  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591

+ Here is the caller graph for this function:

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 1022 of file bijection_tpl.h.

References gum::BijectionIteratorSafe< T1, T2 >::__iter, and gum::BijectionIteratorGet< gen >::op_second().

Referenced by gum::MultiDimBucket< GUM_SCALAR >::__eraseBuffer(), gum::MultiDimBucket< GUM_SCALAR >::__initializeBuffer(), gum::ExactTerminalNodePolicy< GUM_SCALAR >::value(), and gum::MultiDimBucket< GUM_SCALAR >::~MultiDimBucket().

1022  {
1023  return Getter::op_second(__iter.val());
1024  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1591
static INLINE const T & op_second(const T *x)
Returns a refeence over a pointer.
Definition: bijection.h:1368

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

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

Definition at line 1411 of file bijection.h.

Member Data Documentation


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