Sorted list

nRF5 SDK v14.1.0

Module for storing items in the ordered list. More...

Data Structures

struct nrf_sortlist_item_s
A structure for item in the sorted list. More...
struct nrf_sortlist_cb_t
Sorted list instance control block. More...
struct nrf_sortlist_t
Structure for sorted list instance. More...

Macros

#define NRF_SORTLIST_INST_NAME (_name)
Macro for conditionally including instance name. More...
#define NRF_SORTLIST_DEF (_name, _compare_func)
Macro for defining a sorted list instance. More...

Typedefs

typedef struct nrf_sortlist_item_s nrf_sortlist_item_t
Forward declaration of sorted list item.
typedef bool(* nrf_sortlist_compare_func_t )( nrf_sortlist_item_t *p_item0, nrf_sortlist_item_t *p_item1)
Prototype of a function which compares two elements. More...

Functions

void nrf_sortlist_add ( nrf_sortlist_t const *p_list, nrf_sortlist_item_t *p_item)
Function for adding an element into a list. More...
nrf_sortlist_item_t * nrf_sortlist_pop ( nrf_sortlist_t const *p_list)
Function for removing an item from the list head. More...
nrf_sortlist_item_t const * nrf_sortlist_peek ( nrf_sortlist_t const *p_list)
Function for getting (without removing) an item from the list head. More...
nrf_sortlist_item_t const * nrf_sortlist_next ( nrf_sortlist_item_t const *p_item)
Function for iterating over the list. More...
bool nrf_sortlist_remove ( nrf_sortlist_t const *p_list, nrf_sortlist_item_t *p_item)
Function for removing an item from the queue. More...

Detailed Description

Module for storing items in the ordered list.

Macro Definition Documentation

#define NRF_SORTLIST_DEF ( _name,
_compare_func
)
Value:
static nrf_sortlist_cb_t CONCAT_2 (_name,_sortlist_cb) = { \
.p_head = NULL \
}; \
static const nrf_sortlist_t _name = { \
.p_name = NRF_SORTLIST_INST_NAME (_name), \
.p_cb = & CONCAT_2 (_name,_sortlist_cb), \
.compare_func = _compare_func, \
}

Macro for defining a sorted list instance.

Parameters
_name Instance name.
_compare_func Pointer to a compare function.
#define NRF_SORTLIST_INST_NAME ( _name )
Value:
STRINGIFY(_name) : NULL

Macro for conditionally including instance name.

Parameters
_name Instance name.

Typedef Documentation

typedef bool(* nrf_sortlist_compare_func_t)( nrf_sortlist_item_t *p_item0, nrf_sortlist_item_t *p_item1)

Prototype of a function which compares two elements.

Parameters
p_item0 Item 0.
p_item1 Item 1.
Returns
True if Item 0 should be higher than Item 1 and false otherwise.

Function Documentation

void nrf_sortlist_add ( nrf_sortlist_t const * p_list ,
nrf_sortlist_item_t * p_item
)

Function for adding an element into a list.

New item will be placed in the queue based on the compare function.

Parameters
p_list List instance.
p_item Item.
nrf_sortlist_item_t const* nrf_sortlist_next ( nrf_sortlist_item_t const * p_item )

Function for iterating over the list.

Parameters
p_item Item in the list.
Returns
Pointer to the next item in the list.
nrf_sortlist_item_t const* nrf_sortlist_peek ( nrf_sortlist_t const * p_list )

Function for getting (without removing) an item from the list head.

Parameters
p_list List instance.
Returns
Pointer to the item which is on the list head.
nrf_sortlist_item_t * nrf_sortlist_pop ( nrf_sortlist_t const * p_list )

Function for removing an item from the list head.

Parameters
p_list List instance.
Returns
Pointer to the item which was on the list head.
bool nrf_sortlist_remove ( nrf_sortlist_t const * p_list ,
nrf_sortlist_item_t * p_item
)

Function for removing an item from the queue.

Parameters
p_list List instance.
p_item Item.
Return values
true Item was found and removed.
false Item not found in the list.