![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Unsafe but fast const iterators for Lists. More...
#include <agrum/base/core/list.h>
Public Types | |
| using | iterator_category = std::bidirectional_iterator_tag |
| Types for STL compliance. | |
| using | value_type = Val |
| Types for STL compliance. | |
| using | reference = Val& |
| Types for STL compliance. | |
| using | const_reference = const Val& |
| Types for STL compliance. | |
| using | pointer = Val* |
| Types for STL compliance. | |
| using | const_pointer = const Val* |
| Types for STL compliance. | |
| using | difference_type = std::ptrdiff_t |
| Types for STL compliance. | |
Public Member Functions | |
Constructors / Destructors | |
| ListConstIterator () noexcept | |
| Default constructor. | |
| ListConstIterator (const List< Val > &theList) noexcept | |
| Constructor for a begin. | |
| ListConstIterator (const ListConstIterator< Val > &src) noexcept | |
| Copy constructor. | |
| ListConstIterator (ListConstIterator< Val > &&src) noexcept | |
| Move constructor. | |
| ListConstIterator (const List< Val > &theList, Size ind_elt) | |
| Constructor for an iterator pointing to the ind_eltth element of a List. | |
| ~ListConstIterator () noexcept | |
| Class Desctructor. | |
Accessors / Modifiers | |
| void | clear () noexcept |
| Makes the iterator point toward nothing. | |
| void | setToEnd () noexcept |
| Positions the iterator to the end of the list. | |
| bool | isEnd () const noexcept |
| Returns a bool indicating whether the iterator points to the end of the list. | |
Operators | |
| ListConstIterator< Val > & | operator= (const ListConstIterator< Val > &src) noexcept |
| Copy operator. | |
| ListConstIterator< Val > & | operator= (ListConstIterator< Val > &&src) noexcept |
| Move operator. | |
| ListConstIterator< Val > & | operator++ () noexcept |
| Makes the iterator point to the next element in the List. | |
| ListConstIterator< Val > & | operator+= (difference_type i) noexcept |
| Makes the iterator point to i elements further in the List. | |
| ListConstIterator< Val > & | operator-- () noexcept |
| Makes the iterator point to the preceding element in the List. | |
| ListConstIterator< Val > & | operator-= (difference_type i) noexcept |
| Makes the iterator point to i elements befor in the List. | |
| ListConstIterator< Val > | operator+ (difference_type i) noexcept |
| Returns a new iterator pointing to i further elements in the gum::List. | |
| ListConstIterator< Val > | operator- (difference_type i) noexcept |
| Returns a new iterator pointing to i preceding elements in the gum::List. | |
| bool | operator!= (const ListConstIterator< Val > &src) const noexcept |
| Checks whether two iterators point toward different elements. | |
| bool | operator== (const ListConstIterator< Val > &src) const noexcept |
| Checks whether two iterators point toward the same elements. | |
| const Val & | operator* () const |
| Gives access to the content of the iterator. | |
| const Val * | operator-> () const |
| Dereferences the value pointed to by the iterator. | |
Private Member Functions | |
| ListBucket< Val > * | _getBucket_ () const noexcept |
| Returns the bucket the iterator is pointing to. | |
Private Attributes | |
| ListBucket< Val > * | _bucket_ {nullptr} |
| The bucket in the chained list pointed to by the iterator. | |
Friends | |
| class | List< Val > |
| Class List must be a friend because it uses the getBucket method to speed up some processes. | |
Unsafe but fast const iterators for Lists.
Class ListConstIterator implements unsafe iterators for List. However, developers may consider using List<x>::const_iterator instead of ListConstIterator<x>.
These iterators are fast but they are unaware of changes within the List. Therefore, if they point to an element that is being deleted from memory by the list, their accessing this element will most probably produce a segmentation fault. Similarly, incrementing or decrementing such an iterator pointing to a deleted element will most certainly produce a mess. So, ListConstIterator should be used only if you are sure that they will never point to an element that has been removed from the list (a typical use is to iterate over a const List). Whenever you are not sure that this property holds, use ListConstIteratorSafe<x> or List<x>::const_iterator_safe. Those iterators are a little bit slower but guarantee that no segmentation fault will ever occur.
| Val | The gum::List values type. |
| using gum::ListConstIterator< Val >::const_pointer = const Val* |
| using gum::ListConstIterator< Val >::const_reference = const Val& |
| using gum::ListConstIterator< Val >::difference_type = std::ptrdiff_t |
| using gum::ListConstIterator< Val >::iterator_category = std::bidirectional_iterator_tag |
| using gum::ListConstIterator< Val >::pointer = Val* |
| using gum::ListConstIterator< Val >::reference = Val& |
| using gum::ListConstIterator< Val >::value_type = Val |
|
explicitnoexcept |
Default constructor.
Returns an iterator pointing toward nothing.
Definition at line 154 of file list_tpl.h.
References ListConstIterator().
Referenced by ListConstIterator(), ListConstIterator(), ListConstIterator(), ListConstIterator(), gum::ListIterator< Val >::ListIterator(), gum::ListIterator< Val >::ListIterator(), gum::ListIterator< Val >::ListIterator(), gum::ListIterator< Val >::ListIterator(), gum::ListIterator< Val >::ListIterator(), ~ListConstIterator(), operator!=(), operator+(), operator++(), operator+=(), operator-(), operator--(), operator-=(), operator=(), operator=(), and operator==().
|
noexcept |
Constructor for a begin.
Definition at line 161 of file list_tpl.h.
References _bucket_, and List< Val >.
|
noexcept |
Copy constructor.
| src | The gum::ListConstIterator to copy. |
Definition at line 169 of file list_tpl.h.
References ListConstIterator(), and _bucket_.
|
noexcept |
Move constructor.
| src | The gum::ListConstIterator to move. |
Definition at line 177 of file list_tpl.h.
References ListConstIterator(), and _bucket_.
| INLINE gum::ListConstIterator< Val >::ListConstIterator | ( | const List< Val > & | theList, |
| Size | ind_elt ) |
Constructor for an iterator pointing to the ind_eltth element of a List.
| theList | The list to iterate over. |
| ind_elt | The iterator starting position. |
| UndefinedIteratorValue | Raised if the element does not exist in the list. |
Definition at line 186 of file list_tpl.h.
References ListConstIterator(), _bucket_, gum::List< Val >::_deb_list_, gum::List< Val >::_nb_elements_, GUM_ERROR, and List< Val >.
|
noexcept |
Class Desctructor.
Definition at line 209 of file list_tpl.h.
References ListConstIterator().
|
privatenoexcept |
Returns the bucket the iterator is pointing to.
Definition at line 237 of file list_tpl.h.
References _bucket_.
Referenced by gum::List< Val >::_insert_().
|
noexcept |
Makes the iterator point toward nothing.
A method for detaching the iterator from the List it is attached to. After being detached, the iterator does not point to any element, i.e., trying to access its content will raise an exception.
Definition at line 243 of file list_tpl.h.
References _bucket_.
|
noexcept |
Returns a bool indicating whether the iterator points to the end of the list.
Definition at line 256 of file list_tpl.h.
References _bucket_.
|
noexcept |
Checks whether two iterators point toward different elements.
list1.end() == list2.rend().| src | The gum::ListConstIterator to test for inequality. |
Definition at line 321 of file list_tpl.h.
References ListConstIterator(), and _bucket_.
| INLINE const Val & gum::ListConstIterator< Val >::operator* | ( | ) | const |
Gives access to the content of the iterator.
| UndefinedIteratorValue | Raised if the iterator points to nothing. |
Definition at line 341 of file list_tpl.h.
References _bucket_, and GUM_ERROR.
Referenced by gum::ListIterator< Val >::operator*(), and gum::ListIterator< Val >::operator*().
|
noexcept |
Returns a new iterator pointing to i further elements in the gum::List.
| i | The number of steps to move the iterator. |
Definition at line 306 of file list_tpl.h.
References ListConstIterator().
|
noexcept |
Makes the iterator point to the next element in the List.
The above loop is guaranteed to parse the whole List as long as no element is added to or deleted from the List while being in the loop. Runs in constant time.
Definition at line 262 of file list_tpl.h.
References ListConstIterator(), and _bucket_.
Referenced by gum::ListIterator< Val >::operator++().
|
noexcept |
Makes the iterator point to i elements further in the List.
| i | The number of steps to move the iterator. |
Definition at line 272 of file list_tpl.h.
References ListConstIterator(), and _bucket_.
Referenced by gum::ListIterator< Val >::operator+=().
|
noexcept |
Returns a new iterator pointing to i preceding elements in the gum::List.
| i | The number of steps to move the iterator. |
Definition at line 313 of file list_tpl.h.
References ListConstIterator().
|
noexcept |
Makes the iterator point to the preceding element in the List.
The above loop is guaranteed to parse the whole List as long as no element is added to or deleted from the List while being in the loop. Runs in constant time.
Definition at line 284 of file list_tpl.h.
References ListConstIterator(), and _bucket_.
Referenced by gum::ListIterator< Val >::operator--().
|
noexcept |
Makes the iterator point to i elements befor in the List.
| i | The number of steps to move the iterator. |
Definition at line 294 of file list_tpl.h.
References ListConstIterator(), and _bucket_.
Referenced by gum::ListIterator< Val >::operator-=().
| INLINE const Val * gum::ListConstIterator< Val >::operator-> | ( | ) | const |
Dereferences the value pointed to by the iterator.
| UndefinedIteratorValue | Raised if the iterator points to nothing. |
Definition at line 334 of file list_tpl.h.
References _bucket_, and GUM_ERROR.
Referenced by gum::ListIterator< Val >::operator->(), and gum::ListIterator< Val >::operator->().
|
noexcept |
Copy operator.
The current iterator now points to the same element as iterator from.
| src | The gum::ListConstIterator to copy. |
Definition at line 217 of file list_tpl.h.
References ListConstIterator().
Referenced by gum::ListIterator< Val >::operator=(), and gum::ListIterator< Val >::operator=().
|
noexcept |
Move operator.
| src | The gum::ListConstIterator to move. |
Definition at line 228 of file list_tpl.h.
References ListConstIterator().
|
noexcept |
Checks whether two iterators point toward the same elements.
list1.end() == list2.rend().| src | The gum::ListConstIterator to test for equality. |
Definition at line 328 of file list_tpl.h.
References ListConstIterator(), and _bucket_.
Referenced by gum::ListIterator< Val >::operator==().
|
noexcept |
Positions the iterator to the end of the list.
Definition at line 249 of file list_tpl.h.
References _bucket_.
Class List must be a friend because it uses the getBucket method to speed up some processes.
Definition at line 1660 of file list.h.
Referenced by ListConstIterator(), ListConstIterator(), gum::ListIterator< Val >::ListIterator(), and gum::ListIterator< Val >::ListIterator().
|
private |
The bucket in the chained list pointed to by the iterator.
Definition at line 1672 of file list.h.
Referenced by ListConstIterator(), ListConstIterator(), ListConstIterator(), ListConstIterator(), _getBucket_(), clear(), isEnd(), operator!=(), operator*(), operator++(), operator+=(), operator--(), operator-=(), operator->(), operator==(), and setToEnd().