Skip to main content

The double_list_iterator Class Template Reference

A class template for a doubly linked list forward iterator. More...

Declaration

template <class T, class N = T, class U = T>
class micro_os_plus::utils::double_list_iterator<T, N, U>;

Included Headers

Public Member Typedefs Index

usingdifference_type = ptrdiff_t

Type of pointer difference. More...

usingiterator_category = std::forward_iterator_tag

Category of iterator. More...

usingiterator_pointer = N *

Type of reference to the iterator internal pointer. More...

usingpointer = value_type *

Type of pointer to object pointed to by the iterator. More...

usingreference = value_type &

Type of reference to object pointed to by the iterator. More...

usingvalue_type = U

Type of value pointed to by the iterator. More...

Protected Member Attributes Index

iterator_pointernode_

Pointer to the node. More...

Public Constructors Index

constexprdouble_list_iterator ()

Default constructor. Constructs an iterator pointing to nullptr. More...

constexprdouble_list_iterator (iterator_pointer const node)

Construct an iterator from a node pointer. More...

constexprdouble_list_iterator (reference element)

Construct an iterator from a reference to an element. More...

Public Member Functions Index

constexpr iterator_pointerget_iterator_pointer (void) const

Get the internal iterator pointer (node pointer). More...

constexpr pointerget_pointer (void) const

Get a pointer to the value pointed to by the iterator. More...

constexpr double_list_iterator &operator-- ()

Pre-decrement operator. More...

constexpr double_list_iteratoroperator-- (int)

Post-decrement operator. More...

constexpr pointeroperator-> () const

Pointer access operator. More...

constexpr booloperator!= (const double_list_iterator &other) const

Inequality comparison operator. More...

constexpr referenceoperator* () const

Dereference operator. More...

constexpr double_list_iterator &operator++ ()

Pre-increment operator. More...

constexpr double_list_iteratoroperator++ (int)

Post-increment operator. More...

constexpr booloperator== (const double_list_iterator &other) const

Equality comparison operator. More...

Description

A class template for a doubly linked list forward iterator.

Template Parameters
TType of object returned by the iterator.
NType of intrusive node. Must have the public members previous & next.
UType stored in the list, derived from T.

This iterator provides an interface similar to std::list::iterator for traversing a doubly linked list. It supports bidirectional iteration and access to the underlying node and value. In a typical doubly linked list, all types are double_list_links.

Definition at line 489 of file lists.h.

Public Member Typedefs

difference_type

template <class T, class N = T, class U = T>
using micro_os_plus::utils::double_list_iterator< T, N, U >::difference_type = ptrdiff_t

Type of pointer difference.

Definition at line 515 of file lists.h.

iterator_category

template <class T, class N = T, class U = T>
using micro_os_plus::utils::double_list_iterator< T, N, U >::iterator_category = std::forward_iterator_tag

Category of iterator.

Definition at line 520 of file lists.h.

iterator_pointer

template <class T, class N = T, class U = T>
using micro_os_plus::utils::double_list_iterator< T, N, U >::iterator_pointer = N*

Type of reference to the iterator internal pointer.

Definition at line 510 of file lists.h.

pointer

template <class T, class N = T, class U = T>
using micro_os_plus::utils::double_list_iterator< T, N, U >::pointer = value_type*

Type of pointer to object pointed to by the iterator.

Definition at line 500 of file lists.h.

reference

template <class T, class N = T, class U = T>
using micro_os_plus::utils::double_list_iterator< T, N, U >::reference = value_type&

Type of reference to object pointed to by the iterator.

Definition at line 505 of file lists.h.

value_type

template <class T, class N = T, class U = T>
using micro_os_plus::utils::double_list_iterator< T, N, U >::value_type = U

Type of value pointed to by the iterator.

Definition at line 495 of file lists.h.

Protected Member Attributes

node_

template <class T, class N = T, class U = T>
iterator_pointer micro_os_plus::utils::double_list_iterator< T, N, U >::node_
protected

Pointer to the node.

Definition at line 640 of file lists.h.

Public Constructors

double_list_iterator()

template <class T, class N = T, class U = T>
micro_os_plus::utils::double_list_iterator< T, N, U >::double_list_iterator ()
constexpr

Default constructor. Constructs an iterator pointing to nullptr.

The default constructor for double_list_iterator initialises the iterator to a null state, meaning it does not point to any node in the list. This is typically used to create an "end" iterator or to initialise an iterator variable before assigning it to a valid node.

info

The internal node pointer is value-initialised (set to nullptr), ensuring that the iterator is safe to use in comparisons and will not dereference an invalid address.

Declaration at line 528 of file lists.h, definition at line 285 of file lists-inlines.h.

double_list_iterator()

template <class T, class N = T, class U = T>
micro_os_plus::utils::double_list_iterator< T, N, U >::double_list_iterator (iterator_pointer const node)
explicitconstexpr

Construct an iterator from a node pointer.

Parameters
nodePointer to the node to which the iterator should point.

This constructor creates a double_list_iterator that points to the specified node. The internal node pointer is set to the provided node address, allowing the iterator to traverse the list starting from that node. This constructor is typically used to initialise an iterator to a specific position within the list, such as the beginning or end.

Declaration at line 535 of file lists.h, definition at line 298 of file lists-inlines.h.

double_list_iterator()

template <class T, class N = T, class U = T>
micro_os_plus::utils::double_list_iterator< T, N, U >::double_list_iterator (reference element)
explicitconstexpr

Construct an iterator from a reference to an element.

Parameters
elementReference to the element to which the iterator should point.

Definition at line 543 of file lists.h.

Public Member Functions

get_iterator_pointer()

template <class T, class N = T, class U = T>
double_list_iterator< T, N, U >::iterator_pointer micro_os_plus::utils::double_list_iterator< T, N, U >::get_iterator_pointer (void) const
constexpr

Get the internal iterator pointer (node pointer).

Parameters

None.

Returns

Pointer to the node.

Returns the internal node pointer that the iterator currently references. This is useful for advanced list operations or when direct access to the underlying node structure is required, such as for interoperability with other list utilities or for debugging purposes.

Declaration at line 634 of file lists.h, definition at line 455 of file lists-inlines.h.

get_pointer()

template <class T, class N = T, class U = T>
pointer micro_os_plus::utils::double_list_iterator< T, N, U >::get_pointer (void) const
constexpr

Get a pointer to the value pointed to by the iterator.

Parameters

None.

Returns

Pointer to the value.

Definition at line 624 of file lists.h.

operator!=()

template <class T, class N = T, class U = T>
bool micro_os_plus::utils::double_list_iterator< T, N, U >::operator!= (const double_list_iterator & other) const
constexpr

Inequality comparison operator.

Parameters
otherIterator to compare with.
Returns

true if the iterators point to different nodes, false otherwise.

The inequality comparison operator (operator!=) checks whether two iterators point to different nodes in the list by comparing their internal node pointers. This is useful for standard iterator operations, such as determining whether an iterator has reached the end of a range or for loop termination conditions.

Declaration at line 614 of file lists.h, definition at line 440 of file lists-inlines.h.

operator*()

template <class T, class N = T, class U = T>
double_list_iterator< T, N, U >::reference micro_os_plus::utils::double_list_iterator< T, N, U >::operator* () const
constexpr

Dereference operator.

Returns

Reference to the value pointed to by the iterator.

The dereference operator (operator*) provides access to the value or object pointed to by the iterator. Internally, it calls get_pointer() to obtain a pointer to the underlying value or object associated with the current node in the list, and then dereferences it to return a reference.

This allows the iterator to be used in a manner similar to standard C++ iterators, enabling direct access to the list element for reading or modification.

Declaration at line 562 of file lists.h, definition at line 343 of file lists-inlines.h.

operator++()

template <class T, class N = T, class U = T>
double_list_iterator< T, N, U > & micro_os_plus::utils::double_list_iterator< T, N, U >::operator++ ()
constexpr

Pre-increment operator.

Returns

Reference to the incremented iterator.

The pre-increment operator (operator++) advances the iterator to the next node in the list. It updates the internal node pointer to point to the node returned by the current node's next() method. This allows the iterator to traverse the list in the forward direction, following the linked structure.

Declaration at line 570 of file lists.h, definition at line 358 of file lists-inlines.h.

operator++()

template <class T, class N = T, class U = T>
double_list_iterator< T, N, U > micro_os_plus::utils::double_list_iterator< T, N, U >::operator++ (int)
constexpr

Post-increment operator.

Returns

Iterator before increment.

The post-increment operator (operator++(int)) advances the iterator to the next node in the list, but returns a copy of the iterator as it was before the increment. This allows iteration logic that requires access to the current element before moving to the next one, following the standard C++ iterator semantics for post-increment.

Declaration at line 578 of file lists.h, definition at line 374 of file lists-inlines.h.

operator--()

template <class T, class N = T, class U = T>
double_list_iterator< T, N, U > & micro_os_plus::utils::double_list_iterator< T, N, U >::operator-- ()
constexpr

Pre-decrement operator.

Returns

Reference to the decremented iterator.

The pre-decrement operator (operator--) moves the iterator to the previous node in the list. It updates the internal node pointer to point to the node returned by the current node's previous pointer. This enables backward traversal of the list, following the linked structure in reverse.

Declaration at line 586 of file lists.h, definition at line 391 of file lists-inlines.h.

operator--()

template <class T, class N = T, class U = T>
double_list_iterator< T, N, U > micro_os_plus::utils::double_list_iterator< T, N, U >::operator-- (int)
constexpr

Post-decrement operator.

Returns

Iterator before decrement.

The post-decrement operator (operator--(int)) moves the iterator to the previous node in the list, but returns a copy of the iterator as it was before the decrement. This enables iteration logic that requires access to the current element before moving backward, following the standard C++ iterator semantics for post-decrement.

Declaration at line 594 of file lists.h, definition at line 407 of file lists-inlines.h.

operator->()

template <class T, class N = T, class U = T>
double_list_iterator< T, N, U >::pointer micro_os_plus::utils::double_list_iterator< T, N, U >::operator-> () const
constexpr

Pointer access operator.

Returns

Pointer to the value pointed to by the iterator.

The pointer access operator (operator->) allows the iterator to provide direct access to the value pointed to by the iterator, mimicking the behavior of a raw pointer. Internally, it calls get_pointer(), which computes and returns a pointer to the underlying value or object associated with the current node in the list.

Declaration at line 554 of file lists.h, definition at line 325 of file lists-inlines.h.

operator==()

template <class T, class N = T, class U = T>
bool micro_os_plus::utils::double_list_iterator< T, N, U >::operator== (const double_list_iterator & other) const
constexpr

Equality comparison operator.

Parameters
otherIterator to compare with.
Returns

true if both iterators point to the same node, false otherwise.

The equality comparison operator (operator==) checks whether two iterators point to the same node in the list by comparing their internal node pointers. This allows for standard iterator comparisons, such as detecting the end of a range or verifying if two iterators refer to the same position.

Declaration at line 604 of file lists.h, definition at line 424 of file lists-inlines.h.


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


Generated via docusaurus-plugin-doxygen by Doxygen 1.13.2