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

Unsafe iterators for bijection. More...

#include <agrum/core/bijection.h>

Public Member Functions

template<typename Alloc , bool Gen>
INLINE BijectionIterator (const BijectionImplementation< T1, T2, Alloc, Gen > &bijection)
 Constructor. More...
 
template<typename Alloc >
INLINE BijectionIterator (const Bijection< T1, T2, Alloc > &bijection)
 Constructor. More...
 
Constructors/destructors
 BijectionIterator () noexcept
 Default constructor. More...
 
template<typename Alloc >
 BijectionIterator (const Bijection< T1, T2, Alloc > &bijection)
 Default constructor. More...
 
 BijectionIterator (const BijectionIterator< T1, T2 > &from)
 Copy constructor. More...
 
 BijectionIterator (BijectionIterator< T1, T2 > &&from) noexcept
 Move constructor. More...
 
 ~BijectionIterator () noexcept
 Class destructor. More...
 
Operators
BijectionIterator< T1, T2 > & operator= (const BijectionIterator< T1, T2 > &toCopy)
 Copy operator. More...
 
BijectionIterator< T1, T2 > & operator= (BijectionIterator< T1, T2 > &&toMove) noexcept
 Move operator. More...
 
BijectionIterator< T1, T2 > & operator++ () noexcept
 Go to the next association, if it exists. More...
 
BijectionIterator< T1, T2 > & operator+= (unsigned int nb) noexcept
 Moves the iterator by nb elements. More...
 
BijectionIterator< T1, T2 > operator+ (unsigned int nb) noexcept
 Return a new iterator. More...
 
bool operator!= (const BijectionIterator< T1, T2 > &toCompare) const noexcept
 Inequality operator. More...
 
bool operator== (const BijectionIterator< 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::BijectionIterator< T1, T2 >

Unsafe iterators for bijection.

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

Definition at line 1607 of file bijection.h.

Member Typedef Documentation

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

types for STL compliance

Definition at line 1625 of file bijection.h.

template<typename T1, typename T2>
using gum::BijectionIterator< 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 1634 of file bijection.h.

template<typename T1, typename T2>
using gum::BijectionIterator< T1, T2 >::HashIter = typename HashTable12::const_iterator
private

Definition at line 1777 of file bijection.h.

template<typename T1, typename T2>
using gum::BijectionIterator< 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 1776 of file bijection.h.

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

types for STL compliance

Definition at line 1614 of file bijection.h.

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

types for STL compliance

Definition at line 1619 of file bijection.h.

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

types for STL compliance

Definition at line 1617 of file bijection.h.

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

types for STL compliance

Definition at line 1618 of file bijection.h.

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

types for STL compliance

Definition at line 1616 of file bijection.h.

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

types for STL compliance

Definition at line 1615 of file bijection.h.

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

types for STL compliance

Definition at line 1624 of file bijection.h.

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

types for STL compliance

Definition at line 1622 of file bijection.h.

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

types for STL compliance

Definition at line 1623 of file bijection.h.

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

types for STL compliance

Definition at line 1621 of file bijection.h.

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

types for STL compliance

Definition at line 1620 of file bijection.h.

Constructor & Destructor Documentation

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

Begin constructor.

By default, the iterator points to the starting point of the bijection.

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

Default constructor.

Definition at line 1035 of file bijection_tpl.h.

1035  {
1036  GUM_CONSTRUCTOR(BijectionIterator);
1037  }
BijectionIterator() noexcept
Default constructor.
template<typename T1, typename T2>
template<typename Alloc >
gum::BijectionIterator< T1, T2 >::BijectionIterator ( const Bijection< T1, T2, Alloc > &  bijection)

Default constructor.

Parameters
bijectionThe gum::Bijection to iterate onto.
template<typename T1, typename T2>
INLINE gum::BijectionIterator< T1, T2 >::BijectionIterator ( const BijectionIterator< T1, T2 > &  from)

Copy constructor.

Parameters
fromThe gum::BijectionIterator to copy.

Definition at line 1059 of file bijection_tpl.h.

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

1060  :
1061  __iter{toCopy.__iter} {
1062  GUM_CONS_CPY(BijectionIterator);
1063  }
BijectionIterator() noexcept
Default constructor.
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780
template<typename T1, typename T2>
INLINE gum::BijectionIterator< T1, T2 >::BijectionIterator ( BijectionIterator< T1, T2 > &&  from)
noexcept

Move constructor.

move constructor

Parameters
fromThe gum::BijectionIterator to move.

Definition at line 1067 of file bijection_tpl.h.

1068  :
1069  __iter{std::move(from.__iter)} {
1070  GUM_CONS_MOV(BijectionIterator);
1071  }
BijectionIterator() noexcept
Default constructor.
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780
template<typename T1 , typename T2 >
INLINE gum::BijectionIterator< T1, T2 >::~BijectionIterator ( )
noexcept

Class destructor.

Destructor.

Definition at line 1075 of file bijection_tpl.h.

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

1075  {
1076  GUM_DESTRUCTOR(BijectionIterator);
1077  }
BijectionIterator() noexcept
Default constructor.

+ Here is the call graph for this function:

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

Constructor.

Definition at line 1042 of file bijection_tpl.h.

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

1043  :
1044  __iter{bijection.__firstToSecond.cbegin()} {
1045  GUM_CONSTRUCTOR(BijectionIterator);
1046  }
BijectionIterator() noexcept
Default constructor.
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780
template<typename T1, typename T2>
template<typename Alloc >
INLINE gum::BijectionIterator< T1, T2 >::BijectionIterator ( const Bijection< T1, T2, Alloc > &  bijection)

Constructor.

Definition at line 1051 of file bijection_tpl.h.

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

1052  :
1053  __iter{bijection.__firstToSecond.cbegin()} {
1054  GUM_CONSTRUCTOR(BijectionIterator);
1055  }
BijectionIterator() noexcept
Default constructor.
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780

+ Here is the call graph for this function:

Member Function Documentation

template<typename T1 , typename T2 >
INLINE const T1 & gum::BijectionIterator< 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 1134 of file bijection_tpl.h.

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

1134  {
1135  return __iter.key();
1136  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780
template<typename T1, typename T2>
INLINE bool gum::BijectionIterator< T1, T2 >::operator!= ( const BijectionIterator< 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 1121 of file bijection_tpl.h.

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

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

1121  {
1122  return __iter != toCompare.__iter;
1123  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T1 , typename T2 >
INLINE BijectionIterator< T1, T2 > gum::BijectionIterator< T1, T2 >::operator+ ( unsigned int  nb)
noexcept

Return a new iterator.

returns a new iterator

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

Definition at line 1114 of file bijection_tpl.h.

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

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

1114  {
1115  return BijectionIterator< T1, T2 >{*this} += nb;
1116  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Go to the next association, if it exists.

Go to the next association (if exists)

If the iterator points to gum::Bijection::end(), nothing is done.

Returns
Return sthis gum::BijectionIterator.

Definition at line 1098 of file bijection_tpl.h.

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

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

1098  {
1099  ++__iter;
1100  return *this;
1101  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T1 , typename T2 >
INLINE BijectionIterator< T1, T2 > & gum::BijectionIterator< T1, T2 >::operator+= ( unsigned int  nb)
noexcept

Moves the iterator by nb elements.

moves the iterator by nb elements

If the iterator points to gum::Bijection::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::Bijection::end().

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

Definition at line 1106 of file bijection_tpl.h.

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

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

1106  {
1107  __iter += nb;
1108  return *this;
1109  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Copy operator.

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

Definition at line 1082 of file bijection_tpl.h.

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

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

1082  {
1083  __iter = toCopy.__iter;
1084  return *this;
1085  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780

+ Here is the caller graph for this function:

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

Move operator.

move operator

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

Definition at line 1090 of file bijection_tpl.h.

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

1090  {
1091  __iter = std::move(toCopy.__iter);
1092  return *this;
1093  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780

+ Here is the call graph for this function:

template<typename T1, typename T2>
INLINE bool gum::BijectionIterator< T1, T2 >::operator== ( const BijectionIterator< 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 1128 of file bijection_tpl.h.

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

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

1128  {
1129  return __iter == toCompare.__iter;
1130  }
HashIter __iter
The hashTable iterator that actually does all the job.
Definition: bijection.h:1780

+ Here is the caller graph for this function:

template<typename T1 , typename T2 >
INLINE const T2 & gum::BijectionIterator< 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 1140 of file bijection_tpl.h.

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

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

+ Here is the call 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 1609 of file bijection.h.

Member Data Documentation


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