![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Unsafe but fast const iterators for Lists. More...
#include <agrum/tools/core/list.h>
Public Member Functions | |
template<typename Alloc > | |
INLINE | ListConstIterator (const List< Val, Alloc > &theList) noexcept |
Constructors / Destructors | |
ListConstIterator () noexcept | |
Default constructor. More... | |
template<typename Alloc > | |
ListConstIterator (const List< Val, Alloc > &theList) noexcept | |
Constructor for a begin. More... | |
ListConstIterator (const ListConstIterator< Val > &src) noexcept | |
Copy constructor. More... | |
ListConstIterator (ListConstIterator< Val > &&src) noexcept | |
Move constructor. More... | |
ListConstIterator (const List< Val > &theList, Size ind_elt) | |
Constructor for an iterator pointing to the ind_eltth element of a List. More... | |
~ListConstIterator () noexcept | |
Class Desctructor. More... | |
Accessors / Modifiers | |
void | clear () noexcept |
Makes the iterator point toward nothing. More... | |
void | setToEnd () noexcept |
Positions the iterator to the end of the list. More... | |
bool | isEnd () const noexcept |
Returns a bool indicating whether the iterator points to the end of the list. More... | |
Operators | |
ListConstIterator< Val > & | operator= (const ListConstIterator< Val > &src) noexcept |
Copy operator. More... | |
ListConstIterator< Val > & | operator= (ListConstIterator< Val > &&src) noexcept |
Move operator. More... | |
ListConstIterator< Val > & | operator++ () noexcept |
Makes the iterator point to the next element in the List. More... | |
ListConstIterator< Val > & | operator+= (difference_type i) noexcept |
Makes the iterator point to i elements further in the List. More... | |
ListConstIterator< Val > & | operator-- () noexcept |
Makes the iterator point to the preceding element in the List. More... | |
ListConstIterator< Val > & | operator-= (difference_type i) noexcept |
Makes the iterator point to i elements befor in the List. More... | |
ListConstIterator< Val > | operator+ (difference_type i) noexcept |
Returns a new iterator pointing to i further elements in the gum::List. More... | |
ListConstIterator< Val > | operator- (difference_type i) noexcept |
Returns a new iterator pointing to i preceding elements in the gum::List. More... | |
bool | operator!= (const ListConstIterator< Val > &src) const noexcept |
Checks whether two iterators point toward different elements. More... | |
bool | operator== (const ListConstIterator< Val > &src) const noexcept |
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... | |
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 |
|
noexcept |
Default constructor.
Returns an iterator pointing toward nothing.
Definition at line 133 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Constructor for a begin.
Alloc | The gum::List allocator. |
|
noexcept |
Copy constructor.
src | The gum::ListConstIterator to copy. |
Definition at line 149 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Move constructor.
src | The gum::ListConstIterator to move. |
Definition at line 157 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
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 166 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Class Desctructor.
Definition at line 189 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Definition at line 141 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
privatenoexcept |
Returns the bucket the iterator is pointing to.
Definition at line 217 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 223 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Returns a bool indicating whether the iterator points to the end of the list.
Definition at line 236 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Checks whether two iterators point toward different elements.
list1.end()
== list2.rend()
.src | The gum::ListConstIterator to test for inequality. |
Definition at line 301 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
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 324 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 286 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 242 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Makes the iterator point to i elements further in the List.
i | The number of steps to move the iterator. |
Definition at line 252 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 293 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 264 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Makes the iterator point to i elements befor in the List.
i | The number of steps to move the iterator. |
Definition at line 274 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
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 314 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Copy operator.
The current iterator now points to the same element as iterator from.
src | The gum::ListConstIterator to copy. |
Definition at line 197 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Move operator.
src | The gum::ListConstIterator to move. |
Definition at line 208 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
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 308 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
Positions the iterator to the end of the list.
Definition at line 229 of file list_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |