![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Safe iterators for Sequence. More...
#include <agrum/base/core/sequence.h>
Public Types | |
| using | iterator_category = std::bidirectional_iterator_tag |
| types for STL compliance | |
| using | value_type = Key |
| types for STL compliance | |
| using | reference = Key& |
| types for STL compliance | |
| using | const_reference = const Key& |
| types for STL compliance | |
| using | pointer = Key* |
| types for STL compliance | |
| using | const_pointer = const Key* |
| types for STL compliance | |
| using | difference_type = std::ptrdiff_t |
| types for STL compliance | |
Public Member Functions | |
| template<bool Gen> | |
| INLINE | SequenceIteratorSafe (const SequenceImplementation< Key, Gen > &seq, Idx pos) noexcept |
Constructors / Destructors | |
| SequenceIteratorSafe (const Sequence< Key > &seq, Idx pos=0) noexcept | |
| Constructor, always give a valid iterator (even if pos too large). | |
| SequenceIteratorSafe (const SequenceIteratorSafe< Key > &source) noexcept | |
| Copy constructor. | |
| SequenceIteratorSafe (SequenceIteratorSafe< Key > &&source) noexcept | |
| Move constructor. | |
| ~SequenceIteratorSafe () noexcept | |
| Class destructor. | |
Operators | |
| SequenceIteratorSafe< Key > & | operator= (const SequenceIteratorSafe< Key > &source) noexcept |
| Copy operator. | |
| SequenceIteratorSafe< Key > & | operator= (SequenceIteratorSafe< Key > &&source) noexcept |
| Move operator. | |
| SequenceIteratorSafe< Key > & | operator++ () noexcept |
| Point the iterator to the next value in the sequence. | |
| SequenceIteratorSafe< Key > & | operator-- () noexcept |
| Point the iterator to the preceding value in the sequence. | |
| SequenceIteratorSafe< Key > & | operator+= (Size nb) noexcept |
| Makes the iterator point to i elements further in the sequence. | |
| SequenceIteratorSafe< Key > & | operator-= (Size nb) noexcept |
| Makes the iterator point to i elements further in the sequence. | |
| SequenceIteratorSafe< Key > | operator+ (Size nb) noexcept |
| Returns a new iterator. | |
| SequenceIteratorSafe< Key > | operator- (Size nb) noexcept |
| Returns a new iterator. | |
| bool | operator!= (const SequenceIteratorSafe< Key > &source) const noexcept |
| Checks whether two iterators are pointing to different elements. | |
| bool | operator== (const SequenceIteratorSafe< Key > &source) const noexcept |
| Checks whether two iterators are pointing to the same elements. | |
| const Key & | operator* () const |
| Returns the value pointed to by the iterator. | |
| const Key * | operator-> () const |
| Returns the value pointed to by the iterator (works only for non-scalars). | |
Accessors / Modifiers | |
| Idx | pos () const |
| Returns the position of the iterator in the sequence. | |
Private Types | |
| using | Getter = SequenceIteratorGet< std::is_scalar< Key >::value > |
| The Getter used by this iterator. | |
Private Member Functions | |
| template<bool Gen> | |
| SequenceIteratorSafe (const SequenceImplementation< Key, Gen > &seq, Idx pos=0) noexcept | |
| Constructor, always give a valid iterator (even if pos too large). | |
| void | _setPos_ (Idx pos) noexcept |
| The iterator points to the posth element (0 = beginning of the sequence). | |
| void | _setAtRend_ () noexcept |
| The iterator points to rend. | |
| void | _setAtEnd_ () noexcept |
| The iterator points to the end (which is pos size()-1). | |
Private Attributes | |
| Idx | _iterator_ |
| The index in the sequence's vector where the iterator is pointing. | |
| const SequenceImplementation< Key, std::is_scalar< Key >::value > * | _seq_ |
| The sequence pointed to by the iterator (by default, key is a scalar). | |
Friends | |
| template<typename K, bool> | |
| class | SequenceImplementation |
| Friend to speed up access. | |
Safe iterators for Sequence.
This iterator enables to parse the elements in the sequence. Note that this is similar to a const safe iterator because the elements that can be accessed in the sequence are constant.
| Key | The type of elements stored in the gum::Sequence. |
Definition at line 1134 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::const_pointer = const Key* |
types for STL compliance
Definition at line 1147 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::const_reference = const Key& |
types for STL compliance
Definition at line 1145 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::difference_type = std::ptrdiff_t |
types for STL compliance
Definition at line 1148 of file sequence.h.
|
private |
The Getter used by this iterator.
Definition at line 1153 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::iterator_category = std::bidirectional_iterator_tag |
types for STL compliance
Definition at line 1142 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::pointer = Key* |
types for STL compliance
Definition at line 1146 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::reference = Key& |
types for STL compliance
Definition at line 1144 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::value_type = Key |
types for STL compliance
Definition at line 1143 of file sequence.h.
|
privatenoexcept |
Constructor, always give a valid iterator (even if pos too large).
| Gen | Used for meta-programation. |
| seq | The sequence. |
| pos | Indicates to which position of the sequence the iterator should be pointing. By default, the iterator points to begin(). |
References SequenceIteratorSafe(), pos(), and SequenceImplementation.
Referenced by SequenceIteratorSafe(), and ~SequenceIteratorSafe().
|
noexcept |
Constructor, always give a valid iterator (even if pos too large).
| seq | the sequence |
| pos | indicates to which position of the sequence the iterator should be pointing. By default, the iterator points to begin() |
Definition at line 100 of file sequence_tpl.h.
References _seq_, pos(), and SequenceImplementation.
|
noexcept |
Copy constructor.
| source | The iterator to copy. |
Definition at line 112 of file sequence_tpl.h.
References _iterator_.
|
noexcept |
Move constructor.
| source | The iterator to move. |
Definition at line 120 of file sequence_tpl.h.
References _iterator_.
|
noexcept |
Class destructor.
Definition at line 128 of file sequence_tpl.h.
References SequenceIteratorSafe().
|
noexcept |
Definition at line 87 of file sequence_tpl.h.
|
privatenoexcept |
The iterator points to the end (which is pos size()-1).
Definition at line 242 of file sequence_tpl.h.
References _iterator_, and _seq_.
|
privatenoexcept |
|
privatenoexcept |
The iterator points to the posth element (0 = beginning of the sequence).
Definition at line 229 of file sequence_tpl.h.
References _iterator_, _seq_, and pos().
|
noexcept |
Checks whether two iterators are pointing to different elements.
| source | The iterator to test for inequality. |
Definition at line 212 of file sequence_tpl.h.
References gum::operator==().
| INLINE const Key & gum::SequenceIteratorSafe< Key >::operator* | ( | ) | const |
Returns the value pointed to by the iterator.
| UndefinedIteratorValue | Raised on end() or rend(). |
Definition at line 248 of file sequence_tpl.h.
|
noexcept |
Returns a new iterator.
| nb | The number of steps the created iterator is ahead of this. |
Definition at line 189 of file sequence_tpl.h.
|
noexcept |
Point the iterator to the next value in the sequence.
Definition at line 152 of file sequence_tpl.h.
References _iterator_, and _seq_.
|
noexcept |
Makes the iterator point to i elements further in the sequence.
| nb | The number of steps to move the iterator. |
Definition at line 169 of file sequence_tpl.h.
References _iterator_, and _seq_.
|
noexcept |
Returns a new iterator.
| nb | The number of steps the created iterator is behind of this. |
Returns a new iterator.
Definition at line 195 of file sequence_tpl.h.
|
noexcept |
Point the iterator to the preceding value in the sequence.
Definition at line 161 of file sequence_tpl.h.
References _iterator_.
|
noexcept |
Makes the iterator point to i elements further in the sequence.
| nb | The number of steps to move the iterator. |
Definition at line 179 of file sequence_tpl.h.
References _iterator_, and _seq_.
| INLINE const Key * gum::SequenceIteratorSafe< Key >::operator-> | ( | ) | const |
Returns the value pointed to by the iterator (works only for non-scalars).
Definition at line 254 of file sequence_tpl.h.
|
noexcept |
Copy operator.
| source | The iterator to copy. |
Definition at line 135 of file sequence_tpl.h.
References _iterator_, and _seq_.
|
noexcept |
Move operator.
| source | The iterator to move. |
Definition at line 144 of file sequence_tpl.h.
References _iterator_, and _seq_.
|
noexcept |
Checks whether two iterators are pointing to the same elements.
| source | The iterator to test for equality. |
Definition at line 201 of file sequence_tpl.h.
References _seq_.
| INLINE Idx gum::SequenceIteratorSafe< Key >::pos | ( | ) | const |
Returns the position of the iterator in the sequence.
| UndefinedIteratorValue | Raised on end() or rend(). |
Definition at line 219 of file sequence_tpl.h.
References _iterator_, _seq_, and GUM_ERROR.
Referenced by SequenceIteratorSafe(), SequenceIteratorSafe(), _setPos_(), operator*(), and operator->().
Friend to speed up access.
Definition at line 1137 of file sequence.h.
References SequenceImplementation.
Referenced by SequenceIteratorSafe(), SequenceIteratorSafe(), and SequenceImplementation.
|
private |
The index in the sequence's vector where the iterator is pointing.
Definition at line 1339 of file sequence.h.
Referenced by SequenceIteratorSafe(), SequenceIteratorSafe(), _setAtEnd_(), _setAtRend_(), _setPos_(), operator++(), operator+=(), operator--(), operator-=(), operator=(), operator=(), and pos().
|
private |
The sequence pointed to by the iterator (by default, key is a scalar).
Definition at line 1342 of file sequence.h.
Referenced by SequenceIteratorSafe(), _setAtEnd_(), _setPos_(), operator*(), operator++(), operator+=(), operator-=(), operator->(), operator=(), operator=(), operator==(), and pos().