![]() |
aGrUM 3.1.1
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 | |
Constructors / Destructors | |
| SequenceIteratorSafe ()=delete | |
| Constructor, always give a valid iterator (even if pos too large). | |
| 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_v< Key > > |
| 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_v< Key > > * | _seq_ {nullptr} |
| 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 1148 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::const_pointer = const Key* |
types for STL compliance
Definition at line 1161 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::const_reference = const Key& |
types for STL compliance
Definition at line 1159 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::difference_type = std::ptrdiff_t |
types for STL compliance
Definition at line 1162 of file sequence.h.
|
private |
The Getter used by this iterator.
Definition at line 1167 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::iterator_category = std::bidirectional_iterator_tag |
types for STL compliance
Definition at line 1156 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::pointer = Key* |
types for STL compliance
Definition at line 1160 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::reference = Key& |
types for STL compliance
Definition at line 1158 of file sequence.h.
| using gum::SequenceIteratorSafe< Key >::value_type = Key |
types for STL compliance
Definition at line 1157 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(). |
Definition at line 88 of file sequence_tpl.h.
References _seq_, pos(), and SequenceImplementation.
Referenced by SequenceIteratorSafe(), ~SequenceIteratorSafe(), and operator=().
|
delete |
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() |
References SequenceIteratorSafe(), and pos().
|
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 111 of file sequence_tpl.h.
References _iterator_.
|
noexcept |
Move constructor.
| source | The iterator to move. |
Definition at line 119 of file sequence_tpl.h.
References _iterator_.
|
noexcept |
Class destructor.
Definition at line 126 of file sequence_tpl.h.
References SequenceIteratorSafe().
|
privatenoexcept |
The iterator points to the end (which is pos size()-1).
Definition at line 237 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 224 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 207 of file sequence_tpl.h.
References gum::operator==().
| const Key & gum::SequenceIteratorSafe< Key >::operator* | ( | ) | const |
Returns the value pointed to by the iterator.
| UndefinedIteratorValue | Raised on end() or rend(). |
Definition at line 243 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 184 of file sequence_tpl.h.
|
noexcept |
Point the iterator to the next value in the sequence.
Definition at line 147 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 164 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 190 of file sequence_tpl.h.
|
noexcept |
Point the iterator to the preceding value in the sequence.
Definition at line 156 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 174 of file sequence_tpl.h.
| const Key * gum::SequenceIteratorSafe< Key >::operator-> | ( | ) | const |
Returns the value pointed to by the iterator (works only for non-scalars).
Definition at line 249 of file sequence_tpl.h.
|
defaultnoexcept |
Copy operator.
| source | The iterator to copy. |
References SequenceIteratorSafe(), and pos().
|
noexcept |
Move operator.
| source | The iterator to move. |
Definition at line 139 of file sequence_tpl.h.
References _iterator_.
|
noexcept |
Checks whether two iterators are pointing to the same elements.
| source | The iterator to test for equality. |
Definition at line 196 of file sequence_tpl.h.
References _seq_.
| Idx gum::SequenceIteratorSafe< Key >::pos | ( | ) | const |
Returns the position of the iterator in the sequence.
| UndefinedIteratorValue | Raised on end() or rend(). |
Definition at line 214 of file sequence_tpl.h.
References _iterator_, _seq_, and GUM_ERROR.
Referenced by SequenceIteratorSafe(), SequenceIteratorSafe(), SequenceIteratorSafe(), _setPos_(), operator->(), and operator=().
Friend to speed up access.
Definition at line 1151 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 1354 of file sequence.h.
Referenced by SequenceIteratorSafe(), SequenceIteratorSafe(), _setAtEnd_(), _setAtRend_(), _setPos_(), operator++(), operator+=(), operator--(), operator=(), and pos().
|
private |
The sequence pointed to by the iterator (by default, key is a scalar).
Definition at line 1357 of file sequence.h.
Referenced by SequenceIteratorSafe(), SequenceIteratorSafe(), _setAtEnd_(), _setPos_(), operator++(), operator+=(), operator->(), operator==(), and pos().