Skip to main content

The double_list Class Template Reference

A class template for a doubly linked list of nodes. More...

Fully Qualified Name

micro_os_plus::utils::double_list< T, L >

Included Headers

Derived Classes

class

A class template for a list of nodes which store the links inside themselves as intrusive nodes. More...

Member Typedefs

using
is_statically_allocated = typename links_type::is_statically_allocated

Type indicating that the links node is statically allocated. More...

using

Type of iterator over the values. More...

using

Type of reference to the iterator internal pointer. More...

using

Type of the links node object where the pointers to the list head and tail are stored. More...

using

Type of pointer to object pointed to by the iterator. More...

using

Type of reference to object pointed to by the iterator. More...

using

Type of value pointed to by the iterator. More...

Protected Member Attributes

The list top node used to point to head and tail nodes. More...

Member Functions

 

Construct a doubly linked list. More...

constexpr

Destruct the list. More...

begin () const

Iterator begin. More...

void
clear (void)

Clear the list. More...

bool
empty (void) const

Check if the list is empty. More...

end () const

Iterator end. More...

head (void) const

Get the list head. More...

void

Initialize the list only at first run. More...

void
link_head (reference node)

Add a node to the head of the list. More...

void
link_tail (reference node)

Add a node to the tail of the list. More...

const links_type *
links_pointer () const

Get the address of the node storing the list links. More...

tail (void) const

Get the list tail. More...

bool
uninitialized (void) const

Check if the list is uninitialised (only statically allocated lists can be uninitialised). More...

Description

The class template declaration is:

template < class T, class L = double_list_links >
class micro_os_plus::utils::double_list< T, L >;
Template Parameters
TType of the elements linked into the list, derived from class double_list_links_base.
LType of the links node (one of double_list_links or static_double_list_links).

A doubly linked list is a pair of head/tail pointers, allowing to iterate over the nodes.

info

Currently only forward iterators are provided, but there is no problem to add reverse iterators, if needed.

The list elements (of type T) should be derived from the double_list_links_base class, (usually from double_list_links) extended with the payload, that may be either the actual content or a pointer to the content.

The iterators return pointers to the list elements, i.e. to the beginning of the objects of type T.

info

The class does not use inheritance, but composition for the links node, to avoid inheriting unwanted methods from it.

Definition at line 501 of file lists.h.

Member Typedefs

is_statically_allocated

template <class T, class L>
using micro_os_plus::utils::double_list< T, L >::is_statically_allocated = typename links_type::is_statically_allocated

Type indicating that the links node is statically allocated.

Definition at line 543 of file lists.h.

iterator

template <class T, class L>
using micro_os_plus::utils::double_list< T, L >::iterator = double_list_iterator<value_type>

Type of iterator over the values.

Definition at line 533 of file lists.h.

iterator_pointer

template <class T, class L>
using micro_os_plus::utils::double_list< T, L >::iterator_pointer = value_type*

Type of reference to the iterator internal pointer.

Definition at line 538 of file lists.h.

links_type

template <class T, class L>
using micro_os_plus::utils::double_list< T, L >::links_type = L

Type of the links node object where the pointers to the list head and tail are stored.

Definition at line 513 of file lists.h.

pointer

template <class T, class L>
using micro_os_plus::utils::double_list< T, L >::pointer = value_type*

Type of pointer to object pointed to by the iterator.

Definition at line 523 of file lists.h.

reference

template <class T, class L>
using micro_os_plus::utils::double_list< T, L >::reference = value_type&

Type of reference to object pointed to by the iterator.

Definition at line 528 of file lists.h.

value_type

template <class T, class L>
using micro_os_plus::utils::double_list< T, L >::value_type = T

Type of value pointed to by the iterator.

Definition at line 518 of file lists.h.

Protected Member Attributes

links_

template <class T, class L>
links_type micro_os_plus::utils::double_list< T, L >::links_
protected

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.

Definition at line 688 of file lists.h.

Constructors

double_list()

template <class T, class L>
micro_os_plus::utils::double_list< T, L >::double_list ()

Construct a doubly linked list.

For non-statically allocated lists, the initial list status is empty.

Statically allocated remain uninitialised.

Definition at line 549 of file lists.h.

Destructor

~double_list()

template <class T, class L>
micro_os_plus::utils::double_list< T, L >::~double_list ()
constexpr

Destruct the list.

Normally at this point there must be no nodes in the list. However, for statically allocated lists, this might not be always true.

info

In debug mode, the code warns if the list is not empty when destroyed.

Definition at line 572 of file lists.h.

Member Functions

begin()

template <class T, class L>
double_list< T, L >::iterator micro_os_plus::utils::double_list< T, L >::begin () const

Iterator begin.

Returns

An iterator positioned at the first element.

Definition at line 653 of file lists.h.

clear()

template <class T, class L>
void micro_os_plus::utils::double_list< T, L >::clear (void)

Clear the list.

Parameters

None.

Returns

Nothing.

Initialise the mandatory node with links to itself.

Definition at line 614 of file lists.h.

empty()

template <class T, class L>
bool micro_os_plus::utils::double_list< T, L >::empty (void) const

Check if the list is empty.

Parameters

None.

Return Values
trueThe list has no nodes.
falseThe list has at least one node.

Definition at line 604 of file lists.h.

end()

template <class T, class L>
double_list< T, L >::iterator micro_os_plus::utils::double_list< T, L >::end () const

Iterator end.

Returns

An iterator positioned after the last element.

Definition at line 660 of file lists.h.

head()

template <class T, class L>
double_list< T, L >::pointer micro_os_plus::utils::double_list< T, L >::head (void) const
constexpr

Get the list head.

Parameters

None.

Returns

Pointer to the head node.

Definition at line 623 of file lists.h.

initialize_once()

template <class T, class L>
void micro_os_plus::utils::double_list< T, L >::initialize_once (void)

Initialize the list only at first run.

Parameters

None.

Returns

Nothing.

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.

info

Must be manually called for statically allocated list before inserting elements, or any other operations.

Definition at line 594 of file lists.h.

link_head()

template <class T, class L>
void micro_os_plus::utils::double_list< T, L >::link_head (reference node)

Add a node to the head of the list.

Definition at line 644 of file lists.h.

link_tail()

template <class T, class L>
void micro_os_plus::utils::double_list< T, L >::link_tail (reference node)

Add a node to the tail of the list.

Definition at line 638 of file lists.h.

links_pointer()

template <class T, class L>
const links_type * micro_os_plus::utils::double_list< T, L >::links_pointer () const
inlineconstexpr

Get the address of the node storing the list links.

Returns

A pointer to the list head object.

Definition at line 669 of file lists.h.

tail()

template <class T, class L>
double_list< T, L >::pointer micro_os_plus::utils::double_list< T, L >::tail (void) const
constexpr

Get the list tail.

Parameters

None.

Returns

Pointer to the tail node.

Definition at line 632 of file lists.h.

uninitialized()

template <class T, class L>
bool micro_os_plus::utils::double_list< T, L >::uninitialized (void) const

Check if the list is uninitialised (only statically allocated lists can be uninitialised).

Parameters

None.

Return Values
trueThe list was not initialised.
falseThe 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.

Definition at line 584 of file lists.h.


Generated via docusaurus-plugin-doxygen by Doxygen 1.13.2