template<class T, class N = T, class U = T>
class micro_os_plus::utils::double_list_iterator< T, N, U >
A class template for a doubly linked list forward iterator.
- Template Parameters
-
T | Type of object returned by the iterator. |
N | Type of intrusive node. Must have the public members previous & next. |
U | Type 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.
template<class T, class N, class U>
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.
- Note
- 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.
Definition at line 285 of file lists-inlines.h.
template<class T, class N, class U>
Construct an iterator from a node pointer.
- Parameters
-
node | Pointer 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.
Definition at line 298 of file lists-inlines.h.
template<class T, class N, class U>
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.
Definition at line 455 of file lists-inlines.h.
template<class T, class N, class U>
Inequality comparison operator.
- Parameters
-
other | Iterator 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.
Definition at line 440 of file lists-inlines.h.
template<class T, class N, class U>
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.
Definition at line 343 of file lists-inlines.h.
template<class T, class N, class U>
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.
Definition at line 325 of file lists-inlines.h.
template<class T, class N, class U>
Equality comparison operator.
- Parameters
-
other | Iterator 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.
Definition at line 424 of file lists-inlines.h.