utils-lists 4.0.2
The µOS++ Intrusive Lists
Loading...
Searching...
No Matches
Intrusive Doubly Linked Lists

Intrusive doubly linked lists classes. More...

Classes

class  micro_os_plus::utils::intrusive_list< T, N, MP, L, U >
 A class template for a list of nodes which store the links inside themselves as intrusive nodes. More...
 
class  micro_os_plus::utils::intrusive_list_iterator< T, N, MP, U >
 A class template for the intrusive list iterator. More...
 

Detailed Description

Intrusive doubly linked lists classes.

Intrusive lists are doubly linked lists that store the two pointers required for linking directly within each object that is part of the list. This approach eliminates the need for separate node wrappers, resulting in improved performance and reduced memory usage.

The intrusive lists can be defined by instantiating the micro_os_plus::utils::intrusive_list class template, which provides a flexible and efficient way to manage collections of objects.

Example

The following example demonstrates how to define and use an intrusive list:

namespace os = micro_os_plus;
class child
{
public:
child (const char* name);
// ...
protected:
const char* name_;
public:
// Intrusive node used to link this child to the registry list.
// Must be public.
os::utils::double_list_links registry_links_;
};
using static_children_list = os::utils::intrusive_list<
child, // type of nodes in the list
decltype (child::registry_links_), // type of the `registry_links_` member
&child::registry_links_, // name of member
static_double_list_links>; // type of the head links node
// The list head is statically allocated.
static_children_list kids_registry;
Main C++ header file with the declarations for the µOS++ lists classes.
The primary namespace for the µOS++ framework.