![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Unsafe but fast 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 | |
| ListIterator () noexcept | |
| Default constructor. | |
| ListIterator (const List< Val > &theList) noexcept | |
| Constructor for a begin. | |
| ListIterator (const ListIterator< Val > &src) noexcept | |
| Copy constructor. | |
| ListIterator (ListIterator< Val > &&src) noexcept | |
| Move constructor. | |
| ListIterator (const List< Val > &theList, Size ind_elt) | |
| Constructor for an iterator pointing to the ind_eltth element of a List. | |
| ~ListIterator () noexcept | |
| Class destructor. | |
Operators | |
| ListIterator< Val > & | operator= (const ListIterator< Val > &src) noexcept |
| Copy operator. | |
| ListIterator< Val > & | operator= (ListIterator< Val > &&src) noexcept |
| move operator | |
| ListIterator< Val > & | operator++ () noexcept |
| Makes the iterator point to the next element in the List. | |
| ListIterator< Val > & | operator+= (difference_type i) noexcept |
| Makes the iterator point to i elements further in the List. | |
| ListIterator< Val > & | operator-- () noexcept |
| Makes the iterator point to the preceding element in the List. | |
| ListIterator< Val > & | operator-= (difference_type i) noexcept |
| Makes the iterator point to i elements befor in the List. | |
| ListIterator< Val > | operator+ (difference_type i) noexcept |
| Returns a new iterator pointing to i further elements in the gum::List. | |
| ListIterator< Val > | operator- (difference_type i) noexcept |
| Returns a new iterator pointing to i preceding elements in the gum::List. | |
| bool | operator== (const ListIterator< Val > &src) const noexcept |
| Checks whether two iterators point toward the same elements. | |
| bool | operator!= (const ListIterator< Val > &src) const noexcept |
| Checks whether two iterators point toward different elements. | |
| const Val & | operator* () const |
| Gives access to the content of the iterator. | |
| Val & | operator* () |
| Gives access to the iterator's content. | |
| const Val * | operator-> () const |
| Dereferences the value pointed to by the iterator. | |
| Val * | operator-> () |
| Dereferences the value pointed to by the iterator. | |
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 | |
| 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. | |
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. | |
Unsafe but fast iterators for Lists.
Class ListIterator implements iterators for List. However, developers may consider using List<x>::iterator instead of ListIterator<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, ListIterator 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 ListIteratorSafe<x> or List<x>::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::ListIterator< Val >::const_pointer = const Val* |
| using gum::ListIterator< Val >::const_reference = const Val& |
| using gum::ListIterator< Val >::difference_type = std::ptrdiff_t |
| using gum::ListIterator< Val >::iterator_category = std::bidirectional_iterator_tag |
| using gum::ListIterator< Val >::pointer = Val* |
| using gum::ListIterator< Val >::reference = Val& |
| using gum::ListIterator< Val >::value_type = Val |
|
explicitnoexcept |
Default constructor.
Returns an iterator pointing toward nothing.
Definition at line 365 of file list_tpl.h.
References gum::ListConstIterator< Val >::ListConstIterator(), and ListIterator().
Referenced by ListIterator(), ListIterator(), ListIterator(), ListIterator(), ListIterator(), ~ListIterator(), operator!=(), operator++(), operator-(), operator--(), operator=(), operator=(), and operator==().
|
noexcept |
Constructor for a begin.
| theList | The list to iterate over. |
Definition at line 371 of file list_tpl.h.
References gum::ListConstIterator< Val >::ListConstIterator(), ListIterator(), and gum::ListConstIterator< Val >::List< Val >.
|
noexcept |
Copy constructor.
| src | The gum::ListIterator to copy. |
Definition at line 378 of file list_tpl.h.
References gum::ListConstIterator< Val >::ListConstIterator(), and ListIterator().
|
noexcept |
Move constructor.
| src | The gum::ListIterator to move. |
Definition at line 385 of file list_tpl.h.
References gum::ListConstIterator< Val >::ListConstIterator(), and ListIterator().
| INLINE gum::ListIterator< Val >::ListIterator | ( | const List< Val > & | theList, |
| Size | ind_elt ) |
Constructor for an iterator pointing to the ind_eltth element of a List.
| theList | The gum::List to iterate over. |
| ind_elt | The position to point to. |
| UndefinedIteratorValue | Raised if the element does not exist in the list. |
Definition at line 393 of file list_tpl.h.
References gum::ListConstIterator< Val >::ListConstIterator(), ListIterator(), and gum::ListConstIterator< Val >::List< Val >.
|
noexcept |
Class destructor.
Definition at line 417 of file list_tpl.h.
References ListIterator().
|
privatenoexceptinherited |
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_().
|
noexceptinherited |
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_.
|
noexceptinherited |
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_.
|
noexceptinherited |
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_.
|
noexcept |
Checks whether two iterators point toward different elements.
list1.end() == list2.rend().| src | The gum::ListIterator to test for inequality. |
Definition at line 429 of file list_tpl.h.
References ListIterator(), and gum::operator==().
| INLINE Val & gum::ListIterator< Val >::operator* | ( | ) |
Gives access to the iterator's content.
| UndefinedIteratorValue | Raised if the iterator is pointing toward nothing. |
Definition at line 491 of file list_tpl.h.
References gum::ListConstIterator< Val >::operator*().
| INLINE const Val & gum::ListIterator< Val >::operator* | ( | ) | const |
Gives access to the content of the iterator.
| UndefinedIteratorValue | Raised if the iterator points to nothing. |
Definition at line 497 of file list_tpl.h.
References gum::ListConstIterator< 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 466 of file list_tpl.h.
|
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. Deleting elements during the loop is guaranteed to never produce a segmentation fault. Runs in constant time.
Definition at line 435 of file list_tpl.h.
References ListIterator(), and gum::ListConstIterator< 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 443 of file list_tpl.h.
References gum::ListConstIterator< 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 473 of file list_tpl.h.
References ListIterator().
|
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 450 of file list_tpl.h.
References ListIterator(), and gum::ListConstIterator< 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 458 of file list_tpl.h.
References gum::ListConstIterator< Val >::operator-=().
| INLINE Val * gum::ListIterator< Val >::operator-> | ( | ) |
Dereferences the value pointed to by the iterator.
| UndefinedIteratorValue | Raised if the iterator is pointing toward nothing. |
Definition at line 479 of file list_tpl.h.
References gum::ListConstIterator< Val >::operator->().
| INLINE const Val * gum::ListIterator< Val >::operator-> | ( | ) | const |
Dereferences the value pointed to by the iterator.
| UndefinedIteratorValue | Raised if the iterator points to nothing. |
Definition at line 485 of file list_tpl.h.
References gum::ListConstIterator< Val >::operator->().
|
noexcept |
Copy operator.
The current iterator now points to the same element as iterator src.
| src | The gum::ListIterator to copy. |
Definition at line 401 of file list_tpl.h.
References ListIterator(), and gum::ListConstIterator< Val >::operator=().
|
noexcept |
move operator
Move operator.
The current iterator now points to the same element as iterator src.
| src | The gum::ListIterator to move. |
Definition at line 409 of file list_tpl.h.
References ListIterator(), and gum::ListConstIterator< Val >::operator=().
|
noexceptinherited |
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 |
Checks whether two iterators point toward the same elements.
list1.end() == list2.rend().| src | The gum::ListIterator to test for equality. |
Definition at line 423 of file list_tpl.h.
References ListIterator(), and gum::ListConstIterator< Val >::operator==().
|
noexceptinherited |
Positions the iterator to the end of the list.
Definition at line 249 of file list_tpl.h.
References _bucket_.
|
privateinherited |
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().