nRF5 SDK v15.0.0
Modules | Data Structures | Macros | Typedefs | Functions

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

Modules

 Sorted list configuration
 

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_tnrf_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
_nameInstance name.
_compare_funcPointer to a compare function.
#define NRF_SORTLIST_INST_NAME (   _name)
Value:
STRINGIFY(_name) : NULL

Macro for conditionally including instance name.

Parameters
_nameInstance 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_item0Item 0.
p_item1Item 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_listList instance.
p_itemItem.
nrf_sortlist_item_t const* nrf_sortlist_next ( nrf_sortlist_item_t const *  p_item)

Function for iterating over the list.

Parameters
p_itemItem 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_listList 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_listList 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_listList instance.
p_itemItem.
Return values
trueItem was found and removed.
falseItem not found in the list.

Documentation feedback | Developer Zone | Subscribe | Updated