le_singlyLinkedList.h File Reference
Go to the source code of this file.
Data Structures | |
struct | le_sls_Link_t |
struct | le_sls_List_t |
Macros | |
#define | LE_SLS_LIST_DECL_INIT {NULL} |
#define | LE_SLS_LIST_INIT (le_sls_List_t)LE_SLS_LIST_DECL_INIT |
#define | LE_SLS_LINK_INIT (le_sls_Link_t){NULL} |
#define | LE_SLS_FOREACH(listPtr, iteratorPtr, type, member) |
Typedefs | |
typedef bool(* | le_sls_LessThanFunc_t) (le_sls_Link_t *a, le_sls_Link_t *b) |
Detailed Description
Legato Singly Linked List API include file.
Copyright (C) Sierra Wireless Inc.
Macro Definition Documentation
◆ LE_SLS_FOREACH
#define LE_SLS_FOREACH | ( | listPtr, | |
iteratorPtr, | |||
type, | |||
member | |||
) |
&((iteratorPtr)->member); \(iteratorPtr) = CONTAINER_OF(le_sls_PeekNext((listPtr),&((iteratorPtr)->member)), \type, member))le_sls_Link_t * le_sls_PeekNext(const le_sls_List_t *listPtr, const le_sls_Link_t *currentLinkPtr)le_sls_Link_t * le_sls_Peek(const le_sls_List_t *listPtr)
Simple iteration through a singly linked list
◆ LE_SLS_LINK_INIT
#define LE_SLS_LINK_INIT (le_sls_Link_t){NULL} |
When a link is created it must be initialized by assigning this macro to the link before it can be used.
◆ LE_SLS_LIST_DECL_INIT
#define LE_SLS_LIST_DECL_INIT {NULL} |
When a list is created it must be initialized to this macro in the declaration, or have LE_SLS_LIST_INIT
assigned to it, before being used
◆ LE_SLS_LIST_INIT
#define LE_SLS_LIST_INIT (le_sls_List_t)LE_SLS_LIST_DECL_INIT |
When a list is created it must be initialized by assigning this macro to the list, or initializing to LE_SLS_LIST_DECL_INIT
in the declaration, before the list can be used.
Typedef Documentation
◆ le_sls_LessThanFunc_t
typedef bool(* le_sls_LessThanFunc_t) (le_sls_Link_t *a, le_sls_Link_t *b) |
This is a comparator function for sorting a list.
This must return true if a
goes before b
in the list.
Function Documentation
◆ le_sls_AddAfter()
void le_sls_AddAfter | ( | le_sls_List_t * | listPtr, |
le_sls_Link_t * | currentLinkPtr, | ||
le_sls_Link_t * | newLinkPtr | ||
) |
Adds a link after currentLinkPtr, or to the beginning of the list if currentLinkPtr is NULL. Ensure that currentLinkPtr is in the list (or NULL) otherwise the behaviour of this function is undefined.
- Parameters
-
[in] listPtr List to add to. [in] currentLinkPtr New link will be inserted after this link. [in] newLinkPtr New link to add.
◆ le_sls_IsEmpty()
LE_DECLARE_INLINE bool le_sls_IsEmpty | ( | const le_sls_List_t * | listPtr | ) |
Checks if a list is empty.
- Returns
- true if empty, false if not empty.
- Parameters
-
[in] listPtr The list.
◆ le_sls_IsHead()
LE_DECLARE_INLINE bool le_sls_IsHead | ( | const le_sls_List_t * | listPtr, |
const le_sls_Link_t * | linkPtr | ||
) |
Checks if a link is at the head of the list (next to be popped).
- Returns
- true if the link is at the head of the list.
- false if not.
- Parameters
-
[in] listPtr List to check. [in] linkPtr Check if this link is at the head of the list.
◆ le_sls_IsInList()
bool le_sls_IsInList | ( | const le_sls_List_t * | listPtr, |
const le_sls_Link_t * | linkPtr | ||
) |
Checks if a link is in the list.
- Returns
- true if the link is in the list.
- false if the link is not in the list.
- Parameters
-
[in] listPtr List to check. [in] linkPtr Check if this link is in the list.
◆ le_sls_IsListCorrupted()
bool le_sls_IsListCorrupted | ( | const le_sls_List_t * | listPtr | ) |
Checks if the list is corrupted.
- Returns
- true if the list is corrupted. false if the list is not corrupted.
- Parameters
-
[in] listPtr List to check.
◆ le_sls_IsTail()
LE_DECLARE_INLINE bool le_sls_IsTail | ( | const le_sls_List_t * | listPtr, |
const le_sls_Link_t * | linkPtr | ||
) |
Checks if a link is at the tail of the list (last to be popped).
- Returns
- true if the link is at the tail of the list.
- false if not.
- Parameters
-
[in] listPtr List to check. [in] linkPtr Check if this link is at the tail of the list.
◆ le_sls_NumLinks()
size_t le_sls_NumLinks | ( | const le_sls_List_t * | listPtr | ) |
Returns the number of links in a list.
- Returns
- Number of links.
- Parameters
-
[in] listPtr List to count.
◆ le_sls_Peek()
le_sls_Link_t* le_sls_Peek | ( | const le_sls_List_t * | listPtr | ) |
Returns the link at the head of the list without removing it from the list.
- Returns
- Pointer to the head link if successful. NULL if the list is empty.
- Parameters
-
[in] listPtr The list.
◆ le_sls_PeekNext()
le_sls_Link_t* le_sls_PeekNext | ( | const le_sls_List_t * | listPtr, |
const le_sls_Link_t * | currentLinkPtr | ||
) |
Returns the link next to currentLinkPtr (i.e., the link beside currentLinkPtr that's closer to the tail) without removing it from the list. Ensure currentLinkPtr is in the list otherwise the behaviour of this function is undefined.
- Returns
- Pointer to the next link if successful. NULL if there is no link next to the currentLinkPtr (currentLinkPtr is at the tail of the list).
- Parameters
-
[in] listPtr List containing currentLinkPtr. [in] currentLinkPtr Get the link that is relative to this link.
◆ le_sls_PeekTail()
le_sls_Link_t* le_sls_PeekTail | ( | const le_sls_List_t * | listPtr | ) |
Returns the link at the tail of the list without removing it from the list.
- Returns
- A pointer to the tail link if successful. NULL if the list is empty.
- Parameters
-
[in] listPtr The list.
◆ le_sls_Pop()
le_sls_Link_t* le_sls_Pop | ( | le_sls_List_t * | listPtr | ) |
Removes and returns the link at the head of the list.
- Returns
- Removed link. NULL if the link is not available because the list is empty.
- Parameters
-
[in] listPtr List to remove from.
◆ le_sls_Queue()
void le_sls_Queue | ( | le_sls_List_t * | listPtr, |
le_sls_Link_t * | newLinkPtr | ||
) |
Adds a link to the tail of the list.
- Parameters
-
[in] listPtr List to add to. [in] newLinkPtr New link to add.
◆ le_sls_RemoveAfter()
le_sls_Link_t* le_sls_RemoveAfter | ( | le_sls_List_t * | listPtr, |
le_sls_Link_t * | currentLinkPtr | ||
) |
Removes the link found after currentLinkPtr. The user must ensure that currentLinkPtr is in the list otherwise the behaviour of this function is undefined.
- Returns
- Pointer to the removed link. NULL if there are no more links in the list after currentLinkPtr.
- Parameters
-
[in] listPtr The list to remove from. [in] currentLinkPtr The link after this one will be removed from the list.
◆ le_sls_Sort()
void le_sls_Sort | ( | le_sls_List_t * | listPtr, |
le_sls_LessThanFunc_t | comparatorPtr | ||
) |
Sort a list in ascending order.
- Parameters
-
[in] listPtr List to sort [in] comparatorPtr Comparator function for sorting
◆ le_sls_Stack()
void le_sls_Stack | ( | le_sls_List_t * | listPtr, |
le_sls_Link_t * | newLinkPtr | ||
) |
Adds a link at the head of the list.
- Parameters
-
[in] listPtr List to add to. [in] newLinkPtr New link to add.