aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::ListIteratorSafe< Val > Class Template Reference

Safe iterators for Lists. More...

#include <agrum/base/core/list.h>

Inheritance diagram for gum::ListIteratorSafe< Val >:
Collaboration diagram for gum::ListIteratorSafe< Val >:

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
 ListIteratorSafe () noexcept
 Default constructor.
 ListIteratorSafe (const List< Val > &theList)
 Constructor for a begin.
 ListIteratorSafe (const ListIteratorSafe< Val > &src)
 Copy constructor.
 ListIteratorSafe (const List< Val > &theList, Size ind_elt)
 Constructor for an iterator pointing to the ind_eltth element of a List.
 ListIteratorSafe (ListIteratorSafe< Val > &&src)
 Move constructor.
 ~ListIteratorSafe ()
 Class Desctructor.
Operators
ListIteratorSafe< Val > & operator= (const ListIteratorSafe< Val > &src)
 Copy operator.
ListIteratorSafe< Val > & operator= (ListIteratorSafe< Val > &&src)
 Move operator.
ListIteratorSafe< Val > & operator++ () noexcept
 Makes the iterator point to the next element in the List.
ListIteratorSafe< Val > & operator+= (difference_type i) noexcept
 Makes the iterator point to i elements further in the List.
ListIteratorSafe< Val > & operator-- () noexcept
 Makes the iterator point to the preceding element in the List.
ListIteratorSafe< Val > & operator-= (difference_type i) noexcept
 Makes the iterator point to i elements befor in the List.
ListIteratorSafe< Val > operator+ (difference_type i) noexcept
 Returns a new iterator pointing to i further elements in the gum::List.
ListIteratorSafe< Val > operator- (difference_type i) noexcept
 Returns a new iterator pointing to i preceding elements in the gum::List.
Val & operator* ()
 Gives access to the content of the iterator.
Val * operator-> ()
 Dereferences the value pointed to by the iterator.
bool operator!= (const ListIteratorSafe< Val > &src) const
 Checks whether two iterators point toward different elements.
bool operator== (const ListIteratorSafe< Val > &src) const
 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.
Accessors / Modifiers
void clear ()
 Makes the iterator point toward nothing.
void setToEnd ()
 Positions the iterator to the end of the list.
bool isEnd () const
 Returns a bool indicating whether the iterator points to the end of the list.
Operators
bool operator!= (const ListConstIteratorSafe< Val > &src) const
 Checks whether two iterators point toward different elements.
bool operator== (const ListConstIteratorSafe< Val > &src) const
 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.
void _removeFromSafeList_ () const
 Remove the iterator for its list' safe iterators list.
ListConstIteratorSafe< Val > & _opPlus_ (Size i) noexcept
 Makes the iterator point to the next element in the List.
ListConstIteratorSafe< Val > & _opMinus_ (Size i) noexcept
 Makes the iterator point to i elements before in the List.

Private Attributes

const List< Val > * _list_ {nullptr}
 The list the iterator is pointing to.
ListBucket< Val > * _bucket_ {nullptr}
 The bucket in the chained list pointed to by the iterator.
ListBucket< Val > * _next_current_bucket_ {nullptr}
 The bucket we should start from when we are pointing on a deleted bucket and we decide to do a ++.
ListBucket< Val > * _prev_current_bucket_ {nullptr}
 The bucket we should start from when we are pointing on a deleted bucket and we decide to do a –.
bool _null_pointing_ {false}
 Indicates whether the bucket the iterator points to has been deleted.

Detailed Description

template<typename Val>
class gum::ListIteratorSafe< Val >

Safe iterators for Lists.

Class ListIteratorSafe implements iterators for List. However, developers may consider using List<x>::iterator_safe instead of ListIteratorSafe<x>.

These 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. This enables safely writing code like:

for ( iter = mylist.beginSafe (); iter != mylist.endSafe (); ++iter )
list.erase ( iter );
Usage example:
// create a list of strings
list.pushBack ("toto"); list.pushBack ("titi");
// parse all the elements of a list
iter != list.endSafe(); ++iter)
cerr << *iter << endl;
iter != list.endSafe (); iter += 2 ) // step = 2
cerr << *iter << endl;
iter != list.endSafe (); iter = iter + 2 ) // step = 2
cerr << *iter << endl;
iter != list.rendSafe(); --iter)
cerr << *iter << endl;
// use member size() of the strings
iter != list.endSafe(); ++iter)
cerr << iter->size() << endl;
Generic doubly linked lists.
Definition list.h:378
const iterator_safe & rendSafe() noexcept
Returns a safe iterator pointing just before the beginning of the List.
Definition list_tpl.h:1311
iterator_safe beginSafe()
Returns a safe iterator pointing to the beginning of the List.
Definition list_tpl.h:1341
Val & pushBack(const Val &val)
Inserts a new element (a copy) at the end of the chained list.
Definition list_tpl.h:1481
ListIteratorSafe< Val > iterator_safe
Types for STL compliance.
Definition list.h:391
iterator_safe rbeginSafe()
Returns a safe iterator pointing to the last element of the List.
Definition list_tpl.h:1372
const iterator_safe & endSafe() noexcept
Returns a safe iterator pointing to the end of the List.
Definition list_tpl.h:1281
Template Parameters
ValThe gum::List values type.

Definition at line 2318 of file list.h.

Member Typedef Documentation

◆ const_pointer

template<typename Val>
using gum::ListIteratorSafe< Val >::const_pointer = const Val*

Types for STL compliance.

Definition at line 2327 of file list.h.

◆ const_reference

template<typename Val>
using gum::ListIteratorSafe< Val >::const_reference = const Val&

Types for STL compliance.

Definition at line 2325 of file list.h.

◆ difference_type

template<typename Val>
using gum::ListIteratorSafe< Val >::difference_type = std::ptrdiff_t

Types for STL compliance.

Definition at line 2328 of file list.h.

◆ iterator_category

template<typename Val>
using gum::ListIteratorSafe< Val >::iterator_category = std::bidirectional_iterator_tag

Types for STL compliance.

Definition at line 2322 of file list.h.

◆ pointer

template<typename Val>
using gum::ListIteratorSafe< Val >::pointer = Val*

Types for STL compliance.

Definition at line 2326 of file list.h.

◆ reference

template<typename Val>
using gum::ListIteratorSafe< Val >::reference = Val&

Types for STL compliance.

Definition at line 2324 of file list.h.

◆ value_type

template<typename Val>
using gum::ListIteratorSafe< Val >::value_type = Val

Types for STL compliance.

Definition at line 2323 of file list.h.

Constructor & Destructor Documentation

◆ ListIteratorSafe() [1/5]

template<typename Val>
gum::ListIteratorSafe< Val >::ListIteratorSafe ( )
explicitnoexcept

Default constructor.

Returns an iterator pointing toward nothing.

Definition at line 962 of file list_tpl.h.

964 }
Safe iterators for Lists.
Definition list.h:2318
ListIteratorSafe() noexcept
Default constructor.
Definition list_tpl.h:962

References gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), and ListIteratorSafe().

Referenced by ListIteratorSafe(), ListIteratorSafe(), ListIteratorSafe(), ListIteratorSafe(), ListIteratorSafe(), ~ListIteratorSafe(), operator!=(), operator+(), operator++(), operator+=(), operator-(), operator--(), operator-=(), operator=(), operator=(), and operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ListIteratorSafe() [2/5]

template<typename Val>
gum::ListIteratorSafe< Val >::ListIteratorSafe ( const List< Val > & theList)

Constructor for a begin.

Definition at line 969 of file list_tpl.h.

References gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), ListIteratorSafe(), and gum::ListConstIteratorSafe< Val >::List< Val >.

Here is the call graph for this function:

◆ ListIteratorSafe() [3/5]

template<typename Val>
gum::ListIteratorSafe< Val >::ListIteratorSafe ( const ListIteratorSafe< Val > & src)

Copy constructor.

Parameters
srcThe gum::ListConstIteratorSafe to copy.

Definition at line 976 of file list_tpl.h.

References ListIteratorSafe().

Here is the call graph for this function:

◆ ListIteratorSafe() [4/5]

template<typename Val>
gum::ListIteratorSafe< Val >::ListIteratorSafe ( const List< Val > & theList,
Size ind_elt )

Constructor for an iterator pointing to the ind_eltth element of a List.

Parameters
theListThe list to iterate over.
ind_eltThe iterator starting position.
Exceptions
UndefinedIteratorValueRaised if the element does not exist in the list.

Definition at line 984 of file list_tpl.h.

References gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), ListIteratorSafe(), and gum::ListConstIteratorSafe< Val >::List< Val >.

Here is the call graph for this function:

◆ ListIteratorSafe() [5/5]

template<typename Val>
gum::ListIteratorSafe< Val >::ListIteratorSafe ( ListIteratorSafe< Val > && src)

Move constructor.

Parameters
srcThe gum::ListConstIterator to move.

Definition at line 991 of file list_tpl.h.

References gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), and ListIteratorSafe().

Here is the call graph for this function:

◆ ~ListIteratorSafe()

template<typename Val>
gum::ListIteratorSafe< Val >::~ListIteratorSafe ( )

Class Desctructor.

Definition at line 1016 of file list_tpl.h.

1016 {
1018 }

References ListIteratorSafe().

Here is the call graph for this function:

Member Function Documentation

◆ _getBucket_()

template<typename Val>
ListBucket< Val > * gum::ListConstIteratorSafe< Val >::_getBucket_ ( ) const
privatenoexceptinherited

Returns the bucket the iterator is pointing to.

Definition at line 700 of file list_tpl.h.

700 {
701 return _bucket_;
702 }
ListBucket< Val > * _bucket_
The bucket in the chained list pointed to by the iterator.
Definition list.h:2232

Referenced by gum::List< Val >::_insert_(), gum::List< Val >::erase(), and gum::List< Val >::erase().

Here is the caller graph for this function:

◆ _opMinus_()

template<typename Val>
ListConstIteratorSafe< Val > & gum::ListConstIteratorSafe< Val >::_opMinus_ ( Size i)
privatenoexceptinherited

Makes the iterator point to i elements before in the List.

Definition at line 769 of file list_tpl.h.

769 {
770 // check if we are pointing to something that has been deleted
771 if (_null_pointing_) {
772 _null_pointing_ = false;
773
774 // if we are pointing to an element of the chained list that has been
775 // deleted
776 // but that has a preceding element, just point on the latter
777 if (_prev_current_bucket_ != nullptr) {
779 } else {
780 // here we were pointing on an extremity of the list (either end or
781 // rend)
782 // if next_current_bucket is not null, then we are at end and doing
783 // a -- shall now point to the beginning of the list
784 if (_next_current_bucket_ != nullptr) {
786 } else {
787 // here, we are at the rend of the chained list, hence we shall remain
788 // at rend
789 _bucket_ = nullptr;
790 return *this;
791 }
792 }
793 } else {
794 // if we are pointing to an element of the chained list, just
795 // point on the preceding bucket in this list
796 if (_bucket_ != nullptr) { _bucket_ = _bucket_->_prev_; }
797 }
798
799 for (--i; i && (_bucket_ != nullptr); --i, _bucket_ = _bucket_->_prev_) {}
800
801 return *this;
802 }
Safe const iterators for Lists.
Definition list.h:2005
ListBucket< Val > * _next_current_bucket_
The bucket we should start from when we are pointing on a deleted bucket and we decide to do a ++.
Definition list.h:2236
ListBucket< Val > * _prev_current_bucket_
The bucket we should start from when we are pointing on a deleted bucket and we decide to do a –.
Definition list.h:2240
bool _null_pointing_
Indicates whether the bucket the iterator points to has been deleted.
Definition list.h:2243

References ListConstIteratorSafe(), and _null_pointing_.

Referenced by operator+=(), and operator-=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _opPlus_()

template<typename Val>
ListConstIteratorSafe< Val > & gum::ListConstIteratorSafe< Val >::_opPlus_ ( Size i)
privatenoexceptinherited

Makes the iterator point to the next element in the List.

Definition at line 806 of file list_tpl.h.

806 {
807 // check if we are pointing to something that has been deleted
808 if (_null_pointing_) {
809 _null_pointing_ = false;
810
811 // if we are pointing to an element of the chained list that has been
812 // deleted
813 // but that has a next element, just point on the latter
814 if (_next_current_bucket_ != nullptr) {
816 } else {
817 // here we were pointing on an extremity of the list (either end or
818 // rend)
819 // if prev_current_bucket is not null, then we are at rend and doing
820 // a ++ shall now point to the beginning of the list
821 if (_prev_current_bucket_ != nullptr) {
823 } else {
824 // here, we are at the end of the chained list, hence we shall
825 // remain at end
826 _bucket_ = nullptr;
827 return *this;
828 }
829 }
830 } else {
831 // if we are pointing to an element of the chained list, just
832 // point on the next bucket in this list
833 if (_bucket_ != nullptr) { _bucket_ = _bucket_->_next_; }
834 }
835
836 for (--i; i && (_bucket_ != nullptr); --i, _bucket_ = _bucket_->_next_) {}
837
838 return *this;
839 }

References ListConstIteratorSafe(), _bucket_, _next_current_bucket_, _null_pointing_, and _prev_current_bucket_.

Referenced by operator+=(), and operator-=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _removeFromSafeList_()

template<typename Val>
void gum::ListConstIteratorSafe< Val >::_removeFromSafeList_ ( ) const
privateinherited

Remove the iterator for its list' safe iterators list.

Definition at line 591 of file list_tpl.h.

591 {
592 // find where the iterator is
594
595 for (auto i = vect.size() - 1; i >= 0; --i) {
596 if (vect[i] == this) {
597 vect.erase(vect.begin() + i);
598 break;
599 }
600 }
601 }
const List< Val > * _list_
The list the iterator is pointing to.
Definition list.h:2229

References _list_.

Referenced by ~ListConstIteratorSafe(), and clear().

Here is the caller graph for this function:

◆ clear()

template<typename Val>
void gum::ListConstIteratorSafe< Val >::clear ( )
inherited

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.

706 {
707 // remove the iterator src the list's iterator list
709
710 // set its list as well as the element it points to to nullptr
711 _list_ = nullptr;
712 _bucket_ = nullptr;
713 _null_pointing_ = false;
714 }
void _removeFromSafeList_() const
Remove the iterator for its list' safe iterators list.
Definition list_tpl.h:591

References _bucket_, _list_, _null_pointing_, and _removeFromSafeList_().

Referenced by setToEnd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEnd()

template<typename Val>
bool gum::ListConstIteratorSafe< Val >::isEnd ( ) const
inherited

Returns a bool indicating whether the iterator points to the end of the list.

Returns
Returns a bool indicating whether the iterator points to the end of the list.

Definition at line 725 of file list_tpl.h.

725 {
726 return _null_pointing_
727 ? (_next_current_bucket_ == nullptr) && (_prev_current_bucket_ == nullptr)
728 : (_bucket_ == nullptr);
729 }

References _bucket_, _next_current_bucket_, _null_pointing_, and _prev_current_bucket_.

◆ operator!=() [1/2]

template<typename Val>
bool gum::ListConstIteratorSafe< Val >::operator!= ( const ListConstIteratorSafe< Val > & src) const
inherited

Checks whether two iterators point toward different elements.

Warning
the end and rend iterators are always equal, whatever the list they belong to, i.e., list1.end() == list2.rend().
Parameters
srcThe gum::ListConstIteratorSafe to test for inequality.
Returns
Returns true if src and this are equal.

Definition at line 913 of file list_tpl.h.

References ListConstIteratorSafe(), _bucket_, _next_current_bucket_, _null_pointing_, and _prev_current_bucket_.

Here is the call graph for this function:

◆ operator!=() [2/2]

template<typename Val>
bool gum::ListIteratorSafe< Val >::operator!= ( const ListIteratorSafe< Val > & src) const

Checks whether two iterators point toward different elements.

Warning
the end and rend iterators are always equal, whatever the list they belong to, i.e., list1.end() == list2.rend().
Parameters
srcThe gum::ListIteratorSafe to test for inequality.
Returns
Returns true if src and this are equal.

Definition at line 1028 of file list_tpl.h.

1028 {
1029 return !operator==(src);
1030 }
bool operator==(const TiXmlString &a, const TiXmlString &b)
Definition tinystr.h:243

References ListIteratorSafe(), and gum::operator==().

Here is the call graph for this function:

◆ operator*() [1/2]

template<typename Val>
Val & gum::ListIteratorSafe< Val >::operator* ( )

Gives access to the content of the iterator.

Exceptions
UndefinedIteratorValueRaised if the iterator points to nothing.
Returns
Returns the content of the iterator.

Definition at line 1090 of file list_tpl.h.

1090 {
1091 return const_cast< Val& >(ListConstIteratorSafe< Val >::operator*());
1092 }
const Val & operator*() const
Gives access to the content of the iterator.
Definition list_tpl.h:936

References gum::ListConstIteratorSafe< Val >::operator*().

Here is the call graph for this function:

◆ operator*() [2/2]

template<typename Val>
const Val & gum::ListIteratorSafe< Val >::operator* ( ) const

Gives access to the content of the iterator.

Exceptions
UndefinedIteratorValueRaised if the iterator points to nothing.
Returns
Returns the content of the iterator.

Definition at line 1096 of file list_tpl.h.

1096 {
1098 }

References gum::ListConstIteratorSafe< Val >::operator*().

Here is the call graph for this function:

◆ operator+()

template<typename Val>
ListIteratorSafe< Val > gum::ListIteratorSafe< Val >::operator+ ( difference_type i)
noexcept

Returns a new iterator pointing to i further elements in the gum::List.

Parameters
iThe number of steps to move the iterator.
Returns
Returns a new gum::ListConstIteratoSafe.

Definition at line 1064 of file list_tpl.h.

1065 {
1066 return ListIteratorSafe< Val >(*this) += i;
1067 }

References ListIteratorSafe().

Here is the call graph for this function:

◆ operator++()

template<typename Val>
ListIteratorSafe< Val > & gum::ListIteratorSafe< Val >::operator++ ( )
noexcept

Makes the iterator point to the next element in the List.

for (iter = list.begin(); iter != list.end(); ++iter) { }

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.

Returns
Returns this gum::ListIteratorSafe.

Definition at line 1034 of file list_tpl.h.

1034 {
1036 return *this;
1037 }
ListConstIteratorSafe< Val > & operator++() noexcept
Makes the iterator point to the next element in the List.
Definition list_tpl.h:733

References ListIteratorSafe(), and gum::ListConstIteratorSafe< Val >::operator++().

Here is the call graph for this function:

◆ operator+=()

template<typename Val>
ListIteratorSafe< Val > & gum::ListIteratorSafe< Val >::operator+= ( difference_type i)
noexcept

Makes the iterator point to i elements further in the List.

Parameters
iThe number of steps to move the iterator.
Returns
Returns this gum::ListIterator.

Definition at line 1041 of file list_tpl.h.

1042 {
1044 return *this;
1045 }
ListConstIteratorSafe< Val > & operator+=(difference_type i) noexcept
Makes the iterator point to i elements further in the List.
Definition list_tpl.h:843

References ListIteratorSafe(), and gum::ListConstIteratorSafe< Val >::operator+=().

Here is the call graph for this function:

◆ operator-()

template<typename Val>
ListIteratorSafe< Val > gum::ListIteratorSafe< Val >::operator- ( difference_type i)
noexcept

Returns a new iterator pointing to i preceding elements in the gum::List.

Parameters
iThe number of steps to move the iterator.
Returns
Returns a new gum::ListIteratorSafe.

Definition at line 1071 of file list_tpl.h.

1072 {
1073 return ListIteratorSafe< Val >(*this) -= i;
1074 }

References ListIteratorSafe().

Here is the call graph for this function:

◆ operator--()

template<typename Val>
ListIteratorSafe< Val > & gum::ListIteratorSafe< Val >::operator-- ( )
noexcept

Makes the iterator point to the preceding element in the List.

for (iter = list.rbegin(); iter != list.rend(); --iter) { }

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.

Returns
Returns this gum::ListIteratorSafe.

Definition at line 1049 of file list_tpl.h.

1049 {
1051 return *this;
1052 }
ListConstIteratorSafe< Val > & operator--() noexcept
Makes the iterator point to the preceding element in the List.
Definition list_tpl.h:853

References ListIteratorSafe(), and gum::ListConstIteratorSafe< Val >::operator--().

Here is the call graph for this function:

◆ operator-=()

template<typename Val>
ListIteratorSafe< Val > & gum::ListIteratorSafe< Val >::operator-= ( difference_type i)
noexcept

Makes the iterator point to i elements befor in the List.

Parameters
iThe number of steps to move the iterator.
Returns
Returns this gum::ListIteratorSafe.

Definition at line 1056 of file list_tpl.h.

1057 {
1059 return *this;
1060 }
ListConstIteratorSafe< Val > & operator-=(difference_type i) noexcept
Makes the iterator point to i elements befor in the List.
Definition list_tpl.h:889

References ListIteratorSafe(), and gum::ListConstIteratorSafe< Val >::operator-=().

Here is the call graph for this function:

◆ operator->() [1/2]

template<typename Val>
Val * gum::ListIteratorSafe< Val >::operator-> ( )

Dereferences the value pointed to by the iterator.

Exceptions
UndefinedIteratorValueRaised if the iterator points to nothing.
Returns
Returns the value pointed to by the iterator.

Definition at line 1078 of file list_tpl.h.

1078 {
1079 return const_cast< Val* >(ListConstIteratorSafe< Val >::operator->());
1080 }
const Val * operator->() const
Dereferences the value pointed to by the iterator.
Definition list_tpl.h:929

References gum::ListConstIteratorSafe< Val >::operator->().

Here is the call graph for this function:

◆ operator->() [2/2]

template<typename Val>
const Val * gum::ListIteratorSafe< Val >::operator-> ( ) const

Dereferences the value pointed to by the iterator.

Exceptions
UndefinedIteratorValueRaised if the iterator points to nothing.
Returns
Returns the value pointed to by the iterator.

Definition at line 1084 of file list_tpl.h.

1084 {
1086 }

References gum::ListConstIteratorSafe< Val >::operator->().

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename Val>
ListIteratorSafe< Val > & gum::ListIteratorSafe< Val >::operator= ( const ListIteratorSafe< Val > & src)

Copy operator.

The current iterator now points to the same element as iterator from.

Parameters
srcThe gum::ListIteratorSafe to copy.
Returns
Returns this gum::ListIteratorSafe.

Definition at line 998 of file list_tpl.h.

998 {
999 // for debugging purposes
1002 return *this;
1003 }
ListConstIteratorSafe< Val > & operator=(const ListConstIteratorSafe< Val > &src)
Copy operator.
Definition list_tpl.h:606

References ListIteratorSafe().

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename Val>
ListIteratorSafe< Val > & gum::ListIteratorSafe< Val >::operator= ( ListIteratorSafe< Val > && src)

Move operator.

Parameters
srcThe gum::ListIteratorSafe to move.
Returns
Returns this gum::ListIteratorSafe.

Definition at line 1007 of file list_tpl.h.

1007 {
1008 // for debugging purposes
1011 return *this;
1012 }

References ListIteratorSafe(), and gum::ListConstIteratorSafe< Val >::operator=().

Here is the call graph for this function:

◆ operator==() [1/2]

template<typename Val>
bool gum::ListConstIteratorSafe< Val >::operator== ( const ListConstIteratorSafe< Val > & src) const
inherited

Checks whether two iterators point toward the same elements.

Warning
the end and rend iterators are always equal, whatever the list they belong to, i.e., list1.end() == list2.rend().
Parameters
srcThe gum::ListConstIteratorSafe to test for equality.
Returns
Returns true if src and this are equal.

Definition at line 921 of file list_tpl.h.

References ListConstIteratorSafe(), _bucket_, _next_current_bucket_, _null_pointing_, and _prev_current_bucket_.

Referenced by gum::ListIteratorSafe< Val >::operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator==() [2/2]

template<typename Val>
bool gum::ListIteratorSafe< Val >::operator== ( const ListIteratorSafe< Val > & src) const

Checks whether two iterators point toward the same elements.

Warning
the end and rend iterators are always equal, whatever the list they belong to, i.e., list1.end() == list2.rend().
Parameters
srcThe gum::ListIteratorSafe to test for equality.
Returns
Returns true if src and this are equal.

Definition at line 1022 of file list_tpl.h.

1022 {
1024 }
bool operator==(const ListConstIteratorSafe< Val > &src) const
Checks whether two iterators point toward the same elements.
Definition list_tpl.h:921

References ListIteratorSafe(), and gum::ListConstIteratorSafe< Val >::operator==().

Here is the call graph for this function:

◆ setToEnd()

template<typename Val>
void gum::ListConstIteratorSafe< Val >::setToEnd ( )
inherited

Positions the iterator to the end of the list.

Definition at line 718 of file list_tpl.h.

718 {
719 clear();
720 }
void clear()
Makes the iterator point toward nothing.
Definition list_tpl.h:706

References clear().

Here is the call graph for this function:

Member Data Documentation

◆ _bucket_

template<typename Val>
ListBucket< Val >* gum::ListConstIteratorSafe< Val >::_bucket_ {nullptr}
privateinherited

The bucket in the chained list pointed to by the iterator.

Definition at line 2232 of file list.h.

2232{nullptr};

Referenced by ListConstIteratorSafe(), ListConstIteratorSafe(), ListConstIteratorSafe(), _opPlus_(), clear(), isEnd(), operator!=(), operator*(), operator++(), operator--(), operator->(), and operator==().

◆ _list_

◆ _next_current_bucket_

template<typename Val>
ListBucket< Val >* gum::ListConstIteratorSafe< Val >::_next_current_bucket_ {nullptr}
privateinherited

The bucket we should start from when we are pointing on a deleted bucket and we decide to do a ++.

Definition at line 2236 of file list.h.

2236{nullptr};

Referenced by ListConstIteratorSafe(), ListConstIteratorSafe(), gum::List< Val >::_insert_(), _opPlus_(), isEnd(), operator!=(), operator++(), operator--(), and operator==().

◆ _null_pointing_

template<typename Val>
bool gum::ListConstIteratorSafe< Val >::_null_pointing_ {false}
privateinherited

Indicates whether the bucket the iterator points to has been deleted.

Definition at line 2243 of file list.h.

2243{false};

Referenced by ListConstIteratorSafe(), ListConstIteratorSafe(), gum::List< Val >::_insert_(), _opMinus_(), _opPlus_(), clear(), isEnd(), operator!=(), operator++(), operator--(), and operator==().

◆ _prev_current_bucket_

template<typename Val>
ListBucket< Val >* gum::ListConstIteratorSafe< Val >::_prev_current_bucket_ {nullptr}
privateinherited

The bucket we should start from when we are pointing on a deleted bucket and we decide to do a –.

Definition at line 2240 of file list.h.

2240{nullptr};

Referenced by ListConstIteratorSafe(), ListConstIteratorSafe(), gum::List< Val >::_insert_(), _opPlus_(), isEnd(), operator!=(), operator++(), operator--(), and operator==().


The documentation for this class was generated from the following files: