doubly_list_links Class
A class for the core of a doubly linked list (pointers to neighbours). More...
Declaration
Included Headers
Base class
| class | doubly_list_links_base |
|
A base class for a doubly linked list node. More... | |
Public Member Typedefs Index
| using | is_statically_allocated = std::false_type |
|
Type indicating that the links node is not statically allocated. More... | |
Public Constructors Index
| constexpr | doubly_list_links () noexcept |
|
Construct a list node (initialise the pointers). More... | |
| doubly_list_links (const doubly_list_links &)=delete | |
|
Deleted copy constructor. More... | |
| doubly_list_links (doubly_list_links &&)=delete | |
|
Deleted move constructor. More... | |
Public Destructor Index
| constexpr | ~doubly_list_links () |
|
Destruct the node. More... | |
Public Operators Index
| doubly_list_links & | operator= (const doubly_list_links &)=delete |
|
Deleted copy assignment operator. More... | |
| doubly_list_links & | operator= (doubly_list_links &&)=delete |
|
Deleted move assignment operator. More... | |
Public Member Functions Index
| constexpr void | initialise (void) noexcept |
|
Initialise the node links. More... | |
| bool | initialise_once (void) noexcept |
|
Initialise the node links only if not already initialised. More... | |
| bool | initialised (void) const noexcept |
|
Check if the node is initialised. More... | |
| void | link_next (doubly_list_links_base *node) noexcept |
|
Link the new node as next. More... | |
| void | link_previous (doubly_list_links_base *node) noexcept |
|
Link the new node as previous. More... | |
| constexpr bool | linked (void) const noexcept |
|
Check if the node is linked to a doubly linked list. More... | |
| constexpr doubly_list_links_base * | next (void) const noexcept |
|
Get the link to the next node. More... | |
| constexpr doubly_list_links_base * | previous (void) const noexcept |
|
Get the link to the previous node. More... | |
| void | unlink (void) noexcept |
|
Remove this node from the list. More... | |
Protected Member Attributes Index
| doubly_list_links_base * | next_ |
|
Pointer to the next node. More... | |
| doubly_list_links_base * | previous_ |
|
Pointer to the previous node. More... | |
Description
A class for the core of a doubly linked list (pointers to neighbours).
The doubly_list_links class provides the fundamental structure for a doubly linked list node, inheriting the pair of pointers to the next and previous elements and the associated access methods from doubly_list_links_base. The constructor initialises the pointers to form an empty list, where both pointers refer to the node itself.
This class is intended for use as the core linking mechanism within doubly linked lists, supporting efficient insertion and removal operations.
Definition at line 280 of file doubly-list-links.h.
Public Member Typedefs
is_statically_allocated
|
Type indicating that the links node is not statically allocated.
Definition at line 287 of file doubly-list-links.h.
Public Constructors
doubly_list_links()
| constexpr noexcept |
Construct a list node (initialise the pointers).
The constructor for doubly_list_links is used for regular (non-static) list link nodes. It explicitly initialises the node by calling initialise(), which sets both the previous_ and next_ pointers to point to this node itself, marking it as unlinked and ready for use in a list. This ensures that dynamically allocated or automatic list nodes always start in a known, safe state, regardless of their memory contents prior to construction.
For statically allocated nodes, the constructor is intentionally left empty to allow BSS zero-initialisation. For dynamically allocated nodes, explicit initialisation is required to avoid undefined pointer values.
- The rule of five
The copy constructor, move constructor, copy assignment operator, and move assignment operator are explicitly deleted to prevent accidental copying or moving of doubly_list_links objects. This ensures the integrity of the list structure, as duplicating or moving nodes could result in invalid or inconsistent links within the list.
Declaration at line 292 of file doubly-list-links.h, definition at line 283 of file doubly-list-links-inlines.h.
Reference micro_os_plus::utils::doubly_list_links_base::initialise.
Referenced by doubly_list_links, doubly_list_links, operator= and operator=.
doubly_list_links()
| 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.
Definition at line 304 of file doubly-list-links.h.
Reference doubly_list_links.
doubly_list_links()
| 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.
Definition at line 313 of file doubly-list-links.h.
Reference doubly_list_links.
Public Destructor
~doubly_list_links()
| constexpr |
Destruct the node.
Destroys the node. No special cleanup is required as the class does not manage resources.
Declaration at line 345 of file doubly-list-links.h, definition at line 295 of file doubly-list-links-inlines.h.
Public Operators
operator=()
| 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.
Definition at line 324 of file doubly-list-links.h.
Reference doubly_list_links.
operator=()
| 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.
Definition at line 335 of file doubly-list-links.h.
Reference doubly_list_links.
Public Member Functions
initialise()
| constexpr noexcept |
Initialise the node links.
- Parameters
None.
- Returns
Nothing.
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.
After unlinking a node from a list, it must be returned to this state to prevent accidental access through stale links.
Declaration at line 174 of file doubly-list-links.h, definition at line 120 of file doubly-list-links-inlines.h.
References micro_os_plus::utils::doubly_list_links_base::next_ and micro_os_plus::utils::doubly_list_links_base::previous_.
Referenced by doubly_list_links, micro_os_plus::utils::doubly_list_links_base::initialise_once and micro_os_plus::utils::doubly_list_links_base::unlink.
initialise_once()
| noexcept |
Initialise the node links only if not already initialised.
- Parameters
None.
- Returns
true if the node was initialised, false otherwise.
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.
This method must be manually called for a statically allocated list before inserting elements or performing any other operations.
Declaration at line 185 of file doubly-list-links.h, definition at line 81 of file doubly-list-links.cpp.
References micro_os_plus::utils::doubly_list_links_base::initialise and micro_os_plus::utils::doubly_list_links_base::initialised.
initialised()
| nodiscard noexcept |
Check if the node is initialised.
- Parameters
None.
- Return Values
-
true The links are initialised.
false The links are not initialised.
An uninitialised node is a node with its pointers set to nullptr. Only statically allocated nodes in their initial state are considered uninitialised. Regular (dynamically or automatically allocated) nodes are always initialised during construction, so this method will only return false for statically allocated nodes that have not yet been initialised.
Declaration at line 163 of file doubly-list-links.h, definition at line 56 of file doubly-list-links.cpp.
References micro_os_plus::utils::doubly_list_links_base::next_ and micro_os_plus::utils::doubly_list_links_base::previous_.
Referenced by micro_os_plus::utils::doubly_list_links_base::initialise_once.
link_next()
| noexcept |
Link the new node as next.
- Parameters
-
[in] node Pointer to the node to be linked as next.
- Returns
Nothing.
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 doubly-linked list.
Declaration at line 195 of file doubly-list-links.h, definition at line 101 of file doubly-list-links.cpp.
References micro_os_plus::utils::doubly_list_links_base::doubly_list_links_base and micro_os_plus::utils::doubly_list_links_base::next_.
link_previous()
| noexcept |
Link the new node as previous.
- Parameters
-
[in] node Pointer to the node to be linked as previous.
- Returns
Nothing.
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 doubly-linked list.
Declaration at line 205 of file doubly-list-links.h, definition at line 129 of file doubly-list-links.cpp.
References micro_os_plus::utils::doubly_list_links_base::doubly_list_links_base and micro_os_plus::utils::doubly_list_links_base::previous_.
linked()
| nodiscard constexpr noexcept |
Check if the node is linked to a doubly linked list.
- Parameters
None.
- Return Values
-
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.
Declaration at line 227 of file doubly-list-links.h, definition at line 177 of file doubly-list-links-inlines.h.
References micro_os_plus::utils::doubly_list_links_base::next_ and micro_os_plus::utils::doubly_list_links_base::previous_.
next()
| nodiscard constexpr noexcept |
Get the link to the next node.
- Parameters
None.
- Returns
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.
The returned pointer is of type doubly_list_links_base* and may need to be cast to the appropriate derived type by the caller.
Declaration at line 237 of file doubly-list-links.h, definition at line 147 of file doubly-list-links-inlines.h.
Reference micro_os_plus::utils::doubly_list_links_base::next_.
previous()
| nodiscard constexpr noexcept |
Get the link to the previous node.
- Parameters
None.
- Returns
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.
The returned pointer is of type doubly_list_links_base* and may need to be cast to the appropriate derived type by the caller.
Declaration at line 247 of file doubly-list-links.h, definition at line 164 of file doubly-list-links-inlines.h.
Reference micro_os_plus::utils::doubly_list_links_base::previous_.
unlink()
| noexcept |
Remove this node from the list.
- Parameters
None.
- Returns
Nothing.
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.
Declaration at line 216 of file doubly-list-links.h, definition at line 155 of file doubly-list-links.cpp.
References micro_os_plus::utils::doubly_list_links_base::initialise, micro_os_plus::utils::doubly_list_links_base::next_ and micro_os_plus::utils::doubly_list_links_base::previous_.
Protected Member Attributes
next_
| protected |
Pointer to the next node.
Definition at line 258 of file doubly-list-links.h.
Referenced by micro_os_plus::utils::doubly_list_links_base::initialise, micro_os_plus::utils::doubly_list_links_base::initialised, micro_os_plus::utils::doubly_list_links_base::link_next, micro_os_plus::utils::doubly_list_links_base::linked, micro_os_plus::utils::doubly_list_links_base::next, micro_os_plus::utils::static_doubly_list_links::reset and micro_os_plus::utils::doubly_list_links_base::unlink.
previous_
| protected |
Pointer to the previous node.
Definition at line 253 of file doubly-list-links.h.
Referenced by micro_os_plus::utils::doubly_list_links_base::initialise, micro_os_plus::utils::doubly_list_links_base::initialised, micro_os_plus::utils::doubly_list_links_base::link_previous, micro_os_plus::utils::doubly_list_links_base::linked, micro_os_plus::utils::doubly_list_links_base::previous, micro_os_plus::utils::static_doubly_list_links::reset and micro_os_plus::utils::doubly_list_links_base::unlink.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.