![]() |
aGrUM
0.14.2
|
Safe const iterators for Lists. More...
#include <agrum/core/list.h>
Public Member Functions | |
template<typename Alloc > | |
INLINE | ListConstIteratorSafe (const List< Val, Alloc > &theList) |
Constructors / Destructors | |
ListConstIteratorSafe () noexcept | |
Default constructor. More... | |
template<typename Alloc > | |
ListConstIteratorSafe (const List< Val, Alloc > &theList) | |
Constructor for a begin. More... | |
ListConstIteratorSafe (const ListConstIteratorSafe< Val > &src) | |
Copy constructor. More... | |
template<typename Alloc > | |
ListConstIteratorSafe (const List< Val, Alloc > &theList, Size ind_elt) | |
Constructor for an iterator pointing to the ind_eltth element of a List. More... | |
ListConstIteratorSafe (ListConstIteratorSafe< Val > &&src) | |
Move constructor. More... | |
~ListConstIteratorSafe () | |
Class Desctructor. More... | |
Accessors / Modifiers | |
void | clear () |
Makes the iterator point toward nothing. More... | |
void | setToEnd () |
Positions the iterator to the end of the list. More... | |
bool | isEnd () const |
Returns a bool indicating whether the iterator points to the end of the list. More... | |
Operators | |
ListConstIteratorSafe< Val > & | operator= (const ListConstIteratorSafe< Val > &src) |
Copy operator. More... | |
ListConstIteratorSafe< Val > & | operator= (ListConstIteratorSafe< Val > &&src) |
Move operator. More... | |
ListConstIteratorSafe< Val > & | operator++ () noexcept |
Makes the iterator point to the next element in the List. More... | |
ListConstIteratorSafe< Val > & | operator+= (difference_type i) noexcept |
Makes the iterator point to i elements further in the List. More... | |
ListConstIteratorSafe< Val > & | operator-- () noexcept |
Makes the iterator point to the preceding element in the List. More... | |
ListConstIteratorSafe< Val > & | operator-= (difference_type i) noexcept |
Makes the iterator point to i elements befor in the List. More... | |
ListConstIteratorSafe< Val > | operator+ (difference_type i) noexcept |
Returns a new iterator pointing to i further elements in the gum::List. More... | |
ListConstIteratorSafe< Val > | operator- (difference_type i) noexcept |
Returns a new iterator pointing to i preceding elements in the gum::List. More... | |
bool | operator!= (const ListConstIteratorSafe< Val > &src) const |
Checks whether two iterators point toward different elements. More... | |
bool | operator== (const ListConstIteratorSafe< Val > &src) const |
Checks whether two iterators point toward the same elements. More... | |
const Val & | operator* () const |
Gives access to the content of the iterator. More... | |
const Val * | operator-> () const |
Dereferences the value pointed to by the iterator. More... | |
Public Types | |
using | iterator_category = std::bidirectional_iterator_tag |
Types for STL compliance. More... | |
using | value_type = Val |
Types for STL compliance. More... | |
using | reference = Val & |
Types for STL compliance. More... | |
using | const_reference = const Val & |
Types for STL compliance. More... | |
using | pointer = Val * |
Types for STL compliance. More... | |
using | const_pointer = const Val * |
Types for STL compliance. More... | |
using | difference_type = std::ptrdiff_t |
Types for STL compliance. More... | |
Friends | |
template<typename T , typename A > | |
class | List |
class List must be a friend because it uses the getBucket method to speed up some processes. More... | |
class | ListConstIterator< Val > |
class List must be a friend because it uses the getBucket method to speed up some processes. More... | |
Safe const iterators for Lists.
Class ListConstIteratorSafe implements safe const iterators for List. However, developers may consider using List<x>::const_iterator_safe instead of ListConstIteratorSafe<x>.
These const iterators ensure that whenever they point to an element that is being deleted from memory, their accessing this element will never produce a segmentation fault but rather throw an exception. Similarly, incrementing or decrementing an iterator pointing to a deleted element is guaranteed to make the iterator point on the next (or preceding) element that has not been deleted.
Val | The gum::List values type. |
using gum::ListConstIteratorSafe< Val >::const_pointer = const Val* |
using gum::ListConstIteratorSafe< Val >::const_reference = const Val& |
using gum::ListConstIteratorSafe< Val >::difference_type = std::ptrdiff_t |
using gum::ListConstIteratorSafe< Val >::iterator_category = std::bidirectional_iterator_tag |
using gum::ListConstIteratorSafe< Val >::pointer = Val* |
using gum::ListConstIteratorSafe< Val >::reference = Val& |
using gum::ListConstIteratorSafe< Val >::value_type = Val |
|
noexcept |
Default constructor.
Returns an iterator pointing toward nothing.
Definition at line 489 of file list_tpl.h.
gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe | ( | const List< Val, Alloc > & | theList | ) |
Constructor for a begin.
Alloc | The gum::List allocator. |
INLINE gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe | ( | const ListConstIteratorSafe< Val > & | src | ) |
Copy constructor.
src | The gum::ListConstIteratorSafe to copy. |
Definition at line 511 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__list, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, gum::ListConstIteratorSafe< Val >::__prev_current_bucket, and gum::List< Val, Alloc >::__safe_iterators.
gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe | ( | const List< Val, Alloc > & | 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 528 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::List< Val, Alloc >::__deb_list, gum::List< Val, Alloc >::__end_list, gum::ListConstIteratorSafe< Val >::__list, gum::List< Val, Alloc >::__nb_elements, and GUM_ERROR.
INLINE gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe | ( | ListConstIteratorSafe< Val > && | src | ) |
Move constructor.
src | The gum::ListConstIterator to move. |
Definition at line 560 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__list, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, gum::ListConstIteratorSafe< Val >::__prev_current_bucket, and gum::List< Val, Alloc >::__safe_iterators.
INLINE gum::ListConstIteratorSafe< Val >::~ListConstIteratorSafe | ( | ) |
Class Desctructor.
Definition at line 689 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__list, and gum::ListConstIteratorSafe< Val >::__removeFromSafeList().
INLINE gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe | ( | const List< Val, Alloc > & | theList | ) |
Definition at line 497 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket.
|
privatenoexcept |
Returns the bucket the iterator is pointing to.
Definition at line 699 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket.
Referenced by gum::List< const gum::Potential< GUM_SCALAR > * >::__insert(), and gum::List< const gum::Potential< GUM_SCALAR > * >::erase().
|
privatenoexcept |
Makes the iterator point to i elements before in the List.
Definition at line 771 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, and gum::ListConstIteratorSafe< Val >::__prev_current_bucket.
Referenced by gum::ListConstIteratorSafe< Val >::operator+=(), and gum::ListConstIteratorSafe< Val >::operator-=().
|
privatenoexcept |
Makes the iterator point to the next element in the List.
Definition at line 809 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, and gum::ListConstIteratorSafe< Val >::__prev_current_bucket.
Referenced by gum::ListConstIteratorSafe< Val >::operator+=(), and gum::ListConstIteratorSafe< Val >::operator-=().
|
private |
Remove the iterator for its list' safe iterators list.
Definition at line 589 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__list, gum::List< Val, Alloc >::__safe_iterators, and gum::ListConstIteratorSafe< Val >::operator=().
Referenced by gum::ListConstIteratorSafe< Val >::clear(), gum::ListConstIteratorSafe< Val >::operator=(), and gum::ListConstIteratorSafe< Val >::~ListConstIteratorSafe().
INLINE void gum::ListConstIteratorSafe< Val >::clear | ( | ) |
Makes the iterator point toward nothing.
A method for detaching the iterator from the List it is attached to. It is mainly used by the List when the latter is deleted while the iterator is still alive. 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 706 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__list, gum::ListConstIteratorSafe< Val >::__null_pointing, and gum::ListConstIteratorSafe< Val >::__removeFromSafeList().
Referenced by gum::ListConstIteratorSafe< Val >::setToEnd().
INLINE bool gum::ListConstIteratorSafe< Val >::isEnd | ( | ) | const |
Returns a bool indicating whether the iterator points to the end of the list.
Definition at line 725 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, gum::ListConstIteratorSafe< Val >::__prev_current_bucket, and gum::ListConstIteratorSafe< Val >::operator++().
INLINE bool gum::ListConstIteratorSafe< Val >::operator!= | ( | const ListConstIteratorSafe< Val > & | src | ) | const |
Checks whether two iterators point toward different elements.
list1.end()
== list2.rend()
.src | The gum::ListConstIteratorSafe to test for inequality. |
Definition at line 922 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, gum::ListConstIteratorSafe< Val >::__prev_current_bucket, and gum::ListConstIteratorSafe< Val >::operator==().
Referenced by gum::ListConstIteratorSafe< Val >::operator-().
INLINE const Val & gum::ListConstIteratorSafe< Val >::operator* | ( | ) | const |
Gives access to the content of the iterator.
UndefinedIteratorValue | Raised if the iterator points to nothing. |
Definition at line 951 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, and GUM_ERROR.
Referenced by gum::ListIteratorSafe< 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 908 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::operator-().
Referenced by gum::ListConstIteratorSafe< Val >::operator-=().
|
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 734 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, and gum::ListConstIteratorSafe< Val >::__prev_current_bucket.
Referenced by gum::ListConstIteratorSafe< Val >::isEnd(), and gum::ListIteratorSafe< 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 846 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__opMinus(), gum::ListConstIteratorSafe< Val >::__opPlus(), and gum::ListConstIteratorSafe< Val >::operator--().
Referenced by gum::ListIteratorSafe< 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 915 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::operator!=().
Referenced by gum::ListConstIteratorSafe< Val >::operator+().
|
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 859 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, and gum::ListConstIteratorSafe< Val >::__prev_current_bucket.
Referenced by gum::ListConstIteratorSafe< Val >::operator+=(), and gum::ListIteratorSafe< 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 895 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__opMinus(), gum::ListConstIteratorSafe< Val >::__opPlus(), and gum::ListConstIteratorSafe< Val >::operator+().
Referenced by gum::ListIteratorSafe< Val >::operator-=().
INLINE const Val * gum::ListConstIteratorSafe< Val >::operator-> | ( | ) | const |
Dereferences the value pointed to by the iterator.
UndefinedIteratorValue | Raised if the iterator points to nothing. |
Definition at line 941 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, and GUM_ERROR.
Referenced by gum::ListIteratorSafe< Val >::operator->().
ListConstIteratorSafe< Val > & gum::ListConstIteratorSafe< Val >::operator= | ( | const ListConstIteratorSafe< Val > & | src | ) |
Copy operator.
The current iterator now points to the same element as iterator from.
src | The gum::ListConstIteratorSafe to copy. |
Definition at line 604 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__list, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, gum::ListConstIteratorSafe< Val >::__prev_current_bucket, gum::ListConstIteratorSafe< Val >::__removeFromSafeList(), and gum::List< Val, Alloc >::__safe_iterators.
Referenced by gum::ListConstIteratorSafe< Val >::__removeFromSafeList(), and gum::ListIteratorSafe< Val >::operator=().
ListConstIteratorSafe< Val > & gum::ListConstIteratorSafe< Val >::operator= | ( | ListConstIteratorSafe< Val > && | src | ) |
Move operator.
src | The gum::ListConstIteratorSafe to move. |
Definition at line 643 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__list, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, gum::ListConstIteratorSafe< Val >::__prev_current_bucket, gum::ListConstIteratorSafe< Val >::__removeFromSafeList(), and gum::List< Val, Alloc >::__safe_iterators.
INLINE bool gum::ListConstIteratorSafe< Val >::operator== | ( | const ListConstIteratorSafe< Val > & | src | ) | const |
Checks whether two iterators point toward the same elements.
list1.end()
== list2.rend()
.src | The gum::ListConstIteratorSafe to test for equality. |
Definition at line 932 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::__bucket, gum::ListConstIteratorSafe< Val >::__next_current_bucket, gum::ListConstIteratorSafe< Val >::__null_pointing, and gum::ListConstIteratorSafe< Val >::__prev_current_bucket.
Referenced by gum::ListConstIteratorSafe< Val >::operator!=().
INLINE void gum::ListConstIteratorSafe< Val >::setToEnd | ( | ) |
Positions the iterator to the end of the list.
Definition at line 718 of file list_tpl.h.
References gum::ListConstIteratorSafe< Val >::clear().
|
friend |
|
private |
The bucket in the chained list pointed to by the iterator.
Definition at line 2253 of file list.h.
Referenced by gum::ListConstIteratorSafe< Val >::__getBucket(), gum::ListConstIteratorSafe< Val >::__opMinus(), gum::ListConstIteratorSafe< Val >::__opPlus(), gum::ListConstIteratorSafe< Val >::clear(), gum::ListConstIteratorSafe< Val >::isEnd(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), gum::ListConstIteratorSafe< Val >::operator!=(), gum::ListConstIteratorSafe< Val >::operator*(), gum::ListConstIteratorSafe< Val >::operator++(), gum::ListConstIteratorSafe< Val >::operator--(), gum::ListConstIteratorSafe< Val >::operator->(), gum::ListConstIteratorSafe< Val >::operator=(), and gum::ListConstIteratorSafe< Val >::operator==().
|
private |
The list the iterator is pointing to.
Definition at line 2250 of file list.h.
Referenced by gum::ListConstIteratorSafe< Val >::__removeFromSafeList(), gum::ListConstIteratorSafe< Val >::clear(), gum::List< const gum::Potential< GUM_SCALAR > * >::insert(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), gum::ListConstIteratorSafe< Val >::operator=(), and gum::ListConstIteratorSafe< Val >::~ListConstIteratorSafe().
|
private |
The bucket we should start from when we are pointing on a deleted bucket and we decide to do a ++.
Definition at line 2257 of file list.h.
Referenced by gum::List< const gum::Potential< GUM_SCALAR > * >::__insert(), gum::ListConstIteratorSafe< Val >::__opMinus(), gum::ListConstIteratorSafe< Val >::__opPlus(), gum::ListConstIteratorSafe< Val >::isEnd(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), gum::ListConstIteratorSafe< Val >::operator!=(), gum::ListConstIteratorSafe< Val >::operator++(), gum::ListConstIteratorSafe< Val >::operator--(), gum::ListConstIteratorSafe< Val >::operator=(), and gum::ListConstIteratorSafe< Val >::operator==().
|
private |
Indicates whether the bucket the iterator points to has been deleted.
Definition at line 2264 of file list.h.
Referenced by gum::List< const gum::Potential< GUM_SCALAR > * >::__insert(), gum::ListConstIteratorSafe< Val >::__opMinus(), gum::ListConstIteratorSafe< Val >::__opPlus(), gum::ListConstIteratorSafe< Val >::clear(), gum::ListConstIteratorSafe< Val >::isEnd(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), gum::ListConstIteratorSafe< Val >::operator!=(), gum::ListConstIteratorSafe< Val >::operator++(), gum::ListConstIteratorSafe< Val >::operator--(), gum::ListConstIteratorSafe< Val >::operator=(), and gum::ListConstIteratorSafe< Val >::operator==().
|
private |
The bucket we should start from when we are pointing on a deleted bucket and we decide to do a –.
Definition at line 2261 of file list.h.
Referenced by gum::List< const gum::Potential< GUM_SCALAR > * >::__insert(), gum::ListConstIteratorSafe< Val >::__opMinus(), gum::ListConstIteratorSafe< Val >::__opPlus(), gum::ListConstIteratorSafe< Val >::isEnd(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), gum::ListConstIteratorSafe< Val >::operator!=(), gum::ListConstIteratorSafe< Val >::operator++(), gum::ListConstIteratorSafe< Val >::operator--(), gum::ListConstIteratorSafe< Val >::operator=(), and gum::ListConstIteratorSafe< Val >::operator==().