utils-lists 4.0.0
µOS++ C++ intrusive lists utilities
|
A class template for a list of nodes which store the links inside themselves as intrusive nodes. More...
#include <micro-os-plus/utils/lists.h>
Public Types | |
using | difference_type = ptrdiff_t |
Type of pointer difference. | |
using | is_statically_allocated |
Type of reference to the iterator internal pointer. | |
using | iterator = intrusive_list_iterator<T, N, MP, U> |
Type of iterator over the values. | |
using | iterator_pointer = N* |
Type of reference to the iterator internal pointer. | |
using | links_type = L |
Type of the list links node object where the pointers to the list head and tail are stored. | |
using | pointer = value_type* |
Type of pointer to object "pointed to" by the iterator. | |
using | reference = value_type& |
Type of reference to object "pointed to" by the iterator. | |
using | value_type = U |
Type of value "pointed to" by the iterator. | |
Public Member Functions | |
constexpr | intrusive_list () |
Construct an intrusive double linked list. | |
constexpr | ~intrusive_list () |
Destruct the list. | |
iterator | begin () const |
Iterator begin. | |
void | clear (void) |
Clear the list. | |
constexpr bool | empty (void) const |
Check if the list is empty. | |
iterator | end () const |
Iterator begin. | |
constexpr pointer | head (void) const |
Get the list head. | |
void | initialize_once (void) |
Initialize the list only at first run. | |
void | link_head (reference node) |
Add a node to the head of the list. | |
void | link_tail (reference node) |
Add a node to the tail of the list. | |
constexpr const links_type * | links_pointer () const |
Get the address of the node storing the list links. | |
constexpr pointer | tail (void) const |
Get the list tail. | |
bool | uninitialized (void) const |
Check if the list is uninitialised (only statically allocated can be). | |
pointer | unlink_head (void) |
Unlink the first element from the list. | |
pointer | unlink_tail (void) |
Unlink the last element from the list. | |
Protected Member Functions | |
pointer | get_pointer (iterator_pointer node) const |
Get the address of the node. | |
Protected Attributes | |
links_type | links_ |
The list top node used to point to head and tail nodes. | |
A class template for a list of nodes which store the links inside themselves as intrusive nodes.
T | Type of object that includes the intrusive node. |
N | Type of intrusive node with the next & previous links. |
MP | Name of the intrusive node member in object T. |
L | Type of the links node (one of double_list_links or static_double_list_links ). |
U | Type stored in the list, derived from T. |
A pair of head/tail pointers, maintaining a list of intrusive nodes.
Intrusive nodes do not need separate allocations for the links, but store them in the linked objects, in the MP member. The main thing this class does is to compute the address of the object by subtracting the offset from the address of the member storing the pointers.
For statically allocated lists, set L=static_double_list_links.
using micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::difference_type = ptrdiff_t |
using micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::is_statically_allocated |
using micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::iterator = intrusive_list_iterator<T, N, MP, U> |
using micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::iterator_pointer = N* |
using micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::links_type = L |
using micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::pointer = value_type* |
using micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::reference = value_type& |
using micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::value_type = U |
|
constexpr |
|
constexpr |
|
inline |
|
inherited |
|
constexpr |
|
inline |
|
inlineprotected |
|
constexprinherited |
void micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::initialize_once | ( | void | ) |
Initialize the list only at first run.
If the statically allocated list is still in the initial uninitialised state (with both pointers null), initialise the list to the empty state, with both pointers pointing to itself.
For non-statically initialised lists, this method is ineffective.
void micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::link_head | ( | reference | node | ) |
void micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::link_tail | ( | reference | node | ) |
|
inlineconstexprinherited |
|
constexprinherited |
|
inherited |
Check if the list is uninitialised (only statically allocated can be).
true | The list was not initialised. |
false | The list was initialised. |
An uninitialized node is a node with any of the pointers set to nullptr
.
Only statically allocated nodes in the initial state are uninitialized.
intrusive_list< T, N, MP, L, U >::pointer micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::unlink_head | ( | void | ) |
intrusive_list< T, N, MP, L, U >::pointer micro_os_plus::utils::intrusive_list< T, N, MP, L, U >::unlink_tail | ( | void | ) |
|
protectedinherited |
The list top node used to point to head and tail nodes.
The node next pointer points to the list head, and the previous pointer points to the list tail.
To simplify processing, the list always has these pointers set, with an empty list node pointing to itself.