semf
semf::LinkedList< T >::Iterator Class Reference

Implementation of a bidirectional iterator for LinkedList. More...

#include <linkedlist.h>

Collaboration diagram for semf::LinkedList< T >::Iterator:
Collaboration graph

Public Types

using iterator_category = std::bidirectional_iterator_tag
 
using value_type = T
 
using difference_type = std::ptrdiff_t
 
using pointer = T *
 
using refernce = T &
 

Public Member Functions

 Iterator ()=default
 
 Iterator (T *element)
 Constructor with member variable initialization. More...
 
virtual ~Iterator ()=default
 
T & operator* () const
 Returns the reference of the element the iterator's position. More...
 
T * operator-> () const
 Returns the pointer into the element the iterator's position. More...
 
Iteratoroperator++ ()
 Iterates to the next element in the list. More...
 
Iterator operator++ (int)
 Iterates to the next element in the list. More...
 
Iteratoroperator-- ()
 Iterates to the previous element in the list. More...
 
Iterator operator-- (int)
 Iterates to the previous element in the list. More...
 
bool operator== (const Iterator &that) const
 Compares this element with that element. More...
 
bool operator!= (const Iterator &that) const
 Compares this element with that element. More...
 

Detailed Description

template<class T>
class semf::LinkedList< T >::Iterator

Implementation of a bidirectional iterator for LinkedList.

Definition at line 115 of file linkedlist.h.

Member Typedef Documentation

◆ difference_type

template<class T >
using semf::LinkedList< T >::Iterator::difference_type = std::ptrdiff_t

Definition at line 120 of file linkedlist.h.

◆ iterator_category

template<class T >
using semf::LinkedList< T >::Iterator::iterator_category = std::bidirectional_iterator_tag

Definition at line 118 of file linkedlist.h.

◆ pointer

template<class T >
using semf::LinkedList< T >::Iterator::pointer = T*

Definition at line 121 of file linkedlist.h.

◆ refernce

template<class T >
using semf::LinkedList< T >::Iterator::refernce = T&

Definition at line 122 of file linkedlist.h.

◆ value_type

template<class T >
using semf::LinkedList< T >::Iterator::value_type = T

Definition at line 119 of file linkedlist.h.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

template<class T >
semf::LinkedList< T >::Iterator::Iterator ( )
default

◆ Iterator() [2/2]

template<class T >
semf::LinkedList< T >::Iterator::Iterator ( T *  element)
inlineexplicit

Constructor with member variable initialization.

Parameters
elementPointer to the element starting iterating.

Definition at line 129 of file linkedlist.h.

◆ ~Iterator()

template<class T >
virtual semf::LinkedList< T >::Iterator::~Iterator ( )
virtualdefault

Member Function Documentation

◆ operator!=()

template<class T >
bool semf::LinkedList< T >::Iterator::operator!= ( const Iterator that) const
inline

Compares this element with that element.

Parameters
thatIterator to compare.
Returns
true for both iterators are different elements; false for both iterators are the same element.

Definition at line 217 of file linkedlist.h.

◆ operator*()

template<class T >
T & semf::LinkedList< T >::Iterator::operator* ( ) const
inline

Returns the reference of the element the iterator's position.

Attention
Using the reference for an iterator being nullptr (e.g. LinkedList::end) leads to undefined behavior.
Returns
Reference to the element.

Definition at line 141 of file linkedlist.h.

◆ operator++() [1/2]

template<class T >
Iterator & semf::LinkedList< T >::Iterator::operator++ ( )
inline

Iterates to the next element in the list.

Attention
Using the reference for an iterator being nullptr (e.g. LinkedList::end) leads to undefined behavior.
Returns
Next element in the list.

Definition at line 161 of file linkedlist.h.

◆ operator++() [2/2]

template<class T >
Iterator semf::LinkedList< T >::Iterator::operator++ ( int  )
inline

Iterates to the next element in the list.

Attention
Using the reference for an iterator being nullptr (e.g. LinkedList::end) leads to undefined behavior.
Returns
Copy of unchanged this.

Definition at line 172 of file linkedlist.h.

◆ operator--() [1/2]

template<class T >
Iterator & semf::LinkedList< T >::Iterator::operator-- ( )
inline

Iterates to the previous element in the list.

Attention
Using the reference for an iterator being nullptr (e.g. LinkedList::end) leads to undefined behavior.
Returns
Previous element in the list.

Definition at line 184 of file linkedlist.h.

◆ operator--() [2/2]

template<class T >
Iterator semf::LinkedList< T >::Iterator::operator-- ( int  )
inline

Iterates to the previous element in the list.

Attention
Using the reference for an iterator being nullptr (e.g. LinkedList::end) leads to undefined behavior.
Returns
Copy of unchanged this.

Definition at line 195 of file linkedlist.h.

◆ operator->()

template<class T >
T * semf::LinkedList< T >::Iterator::operator-> ( ) const
inline

Returns the pointer into the element the iterator's position.

Attention
Using the reference for an iterator being nullptr (e.g. LinkedList::end) leads to undefined behavior.
Returns
Pointer into the element.

Definition at line 151 of file linkedlist.h.

◆ operator==()

template<class T >
bool semf::LinkedList< T >::Iterator::operator== ( const Iterator that) const
inline

Compares this element with that element.

Parameters
thatIterator to compare.
Returns
true for both iterator's position is the same element; false for both iterator's position are different elements.

Definition at line 207 of file linkedlist.h.