![]() |
utils-lists 4.0.2
The µOS++ Intrusive Lists
|
A base class for a doubly linked list node. More...
#include <micro-os-plus/utils/lists.h>
Public Member Functions | |
constexpr | double_list_links_base () |
Construct an uninitialised list node. | |
double_list_links_base (const double_list_links_base &)=delete | |
Deleted copy constructor. | |
double_list_links_base (double_list_links_base &&)=delete | |
Deleted move constructor. | |
constexpr | ~double_list_links_base () |
Destruct the node. | |
constexpr void | initialize (void) |
Initialise the node links. | |
void | initialize_once (void) |
Initialise the node links only if not already initialised. | |
void | link_next (double_list_links_base *node) |
Link the new node as next. | |
void | link_previous (double_list_links_base *node) |
Link the new node as previous. | |
bool | linked (void) const |
Check if the node is linked to a doubly linked list. | |
constexpr double_list_links_base * | next (void) const |
Get the link to the next node. | |
double_list_links_base & | operator= (const double_list_links_base &)=delete |
Deleted copy assignment operator. | |
double_list_links_base & | operator= (double_list_links_base &&)=delete |
Deleted move assignment operator. | |
constexpr double_list_links_base * | previous (void) const |
Get the link to the previous node. | |
bool | uninitialized (void) const |
Check if the node is uninitialised. | |
void | unlink (void) |
Remove this node from the list. | |
Protected Attributes | |
double_list_links_base * | next_ |
Pointer to the next node. | |
double_list_links_base * | previous_ |
Pointer to the previous node. | |
A base class for a doubly linked list node.
This class provides a pair of uninitialised pointers to the next and previous elements in a doubly linked list, along with a set of simple (some inlined) methods to access and manipulate these pointers.
|
constexpr |
Construct an uninitialised list node.
This must be an empty constructor that does not modify the member pointers, leaving them unchanged. For statically initialised lists, this means both pointers remain as nullptr
, representing an uninitialised state. For regular (dynamically initialised) lists, the derived class constructor will handle the initialisation of the pointers.
previous_
was not initialized in constructornext_
was not initialized in constructor These warnings are expected and can be safely ignored in this context.Definition at line 75 of file lists-inlines.h.
|
delete |
Deleted copy constructor.
Copying of list node objects is explicitly disallowed to prevent accidental duplication, which could compromise the integrity of the list structure.
|
delete |
Deleted move constructor.
Moving of list node objects is explicitly disallowed to avoid invalid or inconsistent links within the list that could result from moving nodes.
|
constexpr |
Destruct the node.
This must be an empty destructor that does not modify or reset the member pointers, leaving them unchanged. For both statically and dynamically allocated lists, the destructor does not perform any cleanup or pointer manipulation, as the list management is handled elsewhere.
Definition at line 93 of file lists-inlines.h.
|
constexpr |
Initialise the node links.
Sets both the previous_
and next_
pointers to point to this node itself, marking the node as unlinked. This state is used to indicate that the node is not currently part of any list.
This method is called during initialisation and after a node is unlinked from a list, ensuring the node is in a safe, standalone state and cannot be traversed as part of a list.
Definition at line 113 of file lists-inlines.h.
void micro_os_plus::utils::double_list_links_base::initialize_once | ( | void | ) |
Initialise the node links only if not already initialised.
If the statically allocated list is still in the initial uninitialised state (with both pointers nullptr
), this method initialises the list to the empty state, with both pointers pointing to itself.
For non-statically initialised lists, this method is ineffective, since the node is always initialised at construct time.
void micro_os_plus::utils::double_list_links_base::link_next | ( | double_list_links_base * | node | ) |
Link the new node as next.
[in] | node | Pointer to the node to be linked as next. |
Insert the new node between the next pointer and the node pointed by it. This operation is used by lists to link new nodes to the list head. The new node's previous_
pointer is set to the current node, and its next_
pointer is set to the current node's next_
. The neighbouring nodes are updated to point to the new node, maintaining the integrity of the double-linked list.
void micro_os_plus::utils::double_list_links_base::link_previous | ( | double_list_links_base * | node | ) |
Link the new node as previous.
[in] | node | Pointer to the node to be linked as previous. |
Insert the new node between the previous pointer and the node pointed by it. Used by lists to link new nodes to the list tail. The new node's next_
pointer is set to the current node, and its previous_
pointer is set to the current node's previous_
. The neighbouring nodes are updated to point to the new node, maintaining the integrity of the double-linked list.
bool micro_os_plus::utils::double_list_links_base::linked | ( | void | ) | const |
Check if the node is linked to a doubly linked list.
true | The node is linked with both pointers. |
false | The node is not linked. |
To be linked, both pointers must point to different nodes than itself (double list requirement). If either next_
or previous_
points to this
, the node is considered unlinked (empty state). This method checks the node's linkage status for safe list operations.
|
constexpr |
Get the link to the next node.
Pointer | to the next node. |
Returns a pointer to the next node in the list. If this node is the last in the list, the returned pointer may refer back to the list's sentinel node (for example, the links node in the list container) or to itself if the list is empty.
double_list_links_base*
and may need to be cast to the appropriate derived type by the caller. Definition at line 137 of file lists-inlines.h.
|
delete |
Deleted copy assignment operator.
Copy assignment is explicitly disallowed to prevent accidental overwriting of list node objects, which could lead to corruption of the list structure.
|
delete |
Deleted move assignment operator.
Move assignment is explicitly disallowed to avoid invalid or inconsistent links within the list that could result from moving nodes.
|
constexpr |
Get the link to the previous node.
Pointer | to the previous node. |
Returns a pointer to the previous node in the list. If this node is the first in the list, the returned pointer may refer back to the list's sentinel node (such as the links node in the list container) or to itself if the list is empty.
double_list_links_base*
and may need to be cast to the appropriate derived type by the caller. Definition at line 154 of file lists-inlines.h.
bool micro_os_plus::utils::double_list_links_base::uninitialized | ( | void | ) | const |
Check if the node is uninitialised.
true | The links are not initialised. |
false | The links are initialised. |
An uninitialized node is a node with its pointers set to nullptr
. Only statically allocated nodes in their initial state are considered uninitialized. Regular (dynamically or automatically allocated) nodes are always initialized during construction, so this method will only return true
for statically allocated nodes that have not yet been initialized.
void micro_os_plus::utils::double_list_links_base::unlink | ( | void | ) |
Remove this node from the list.
Update both neighbours to point to each other, effectively removing the node from the list. The node is then returned to the initial state (empty), with both pointers pointing to itself. This operation is safe to call even if the node is already unlinked.
|
protected |
|
protected |