API参考
载入中...
搜索中...
未找到
bidirectional linked list

linked list 更多...

bidirectional linked list 的协作图:

struct  BslListNode
struct  BslList

宏定义

#define BSL_LIST_FREE(pList, pFreeFunc)

类型定义

typedef struct BslListNode BslListNode
typedef struct BslList BslList
typedef int32_t(* BSL_LIST_PFUNC_CMP) (const void *, const void *)
typedef void(* BSL_LIST_PFUNC_FREE) (void *)
typedef void *(* BSL_LIST_PFUNC_DUP) (const void *)

枚举

enum  BslListPosition { BSL_LIST_POS_BEFORE , BSL_LIST_POS_AFTER , BSL_LIST_POS_BEGIN , BSL_LIST_POS_END }

函数

int32_t BSL_LIST_SetMaxElements (int32_t iMaxElements)
int32_t BSL_LIST_GetMaxElements (void)
int32_t BSL_LIST_AddElement (BslList *pList, void *pData, BslListPosition enPosition)
void BSL_LIST_DeleteAll (BslList *pList, BSL_LIST_PFUNC_FREE pfFreeFunc)
void BSL_LIST_DeleteCurrent (BslList *pList, BSL_LIST_PFUNC_FREE pfFreeFunc)
void BSL_LIST_DetachCurrent (BslList *pList)
void * BSL_LIST_Search (BslList *pList, const void *pSearchFor, BSL_LIST_PFUNC_CMP pSearcher, int32_t *pstErr)
void * BSL_LIST_GetIndexNode (uint32_t ulIndex, BslList *pList)
BslListBSL_LIST_Copy (BslList *pSrcList, BSL_LIST_PFUNC_DUP pFuncCpy, BSL_LIST_PFUNC_FREE pfFreeFunc)
BslListBSL_LIST_Sort (BslList *pList, BSL_LIST_PFUNC_CMP pfCmp)
BslListBSL_LIST_New (int32_t dataSize)
void * BSL_LIST_Curr (const BslList *pstList)
void * BSL_LIST_First (BslList *pstList)
void * BSL_LIST_Last (BslList *pstList)
void * BSL_LIST_Next (BslList *pstList)
void * BSL_LIST_Prev (BslList *pstList)
int32_t BSL_LIST_GetElmtIndex (const void *elmt, BslList *pstList)
BslListBSL_LIST_Concat (BslList *pDestList, const BslList *pSrcList)
void BSL_LIST_FreeWithoutData (BslList *pstList)
void BSL_LIST_RevList (BslList *pstList)
int32_t BSL_LIST_SetMaxQsortCount (uint32_t uiQsortSize)
uint32_t BSL_LIST_GetMaxQsortCount (void)
void BSL_LIST_DeleteAllAfterSort (BslList *pList)
BslListNodeBSL_LIST_FirstNode (const BslList *list)
void * BSL_LIST_GetData (const BslListNode *pstNode)
BslListNodeBSL_LIST_GetNextNode (const BslList *pstList, const BslListNode *pstListNode)
BslListNodeBSL_LIST_GetPrevNode (const BslListNode *pstListNode)
void BSL_LIST_DeleteNode (BslList *pstList, const BslListNode *pstListNode, BSL_LIST_PFUNC_FREE pfFreeFunc)
void BSL_LIST_DetachNode (BslList *pstList, BslListNode **pstListNode)

详细描述

linked list

宏定义说明

◆ BSL_LIST_FREE

#define BSL_LIST_FREE ( pList,
pFreeFunc )
值:
do { \
BSL_LIST_DeleteAll((pList), pFreeFunc); \
if (NULL != (pList)) { \
BSL_SAL_Free(pList); \
(pList) = NULL; \
} \
} while (0)

Delete all the nodes in the list and then frees the header

类型定义说明

◆ BSL_LIST_PFUNC_CMP

typedef int32_t(* BSL_LIST_PFUNC_CMP) (const void *, const void *)

This is a pointer to the list comparison function used in BSL_LIST_Search function. It takes two pointers and compares them based on a criteria. If the two are equal a zero is returned. If the first should preceed the second, a negative is returned. Else a positive value is returned.

◆ BSL_LIST_PFUNC_DUP

typedef void *(* BSL_LIST_PFUNC_DUP) (const void *)

This is a pointer to the Copy function. The copy function takes a pointer to data structure to be freed and must return void.

◆ BSL_LIST_PFUNC_FREE

typedef void(* BSL_LIST_PFUNC_FREE) (void *)

This is a pointer to the free function. The free function takes a pointer to data structure to be freed and must return void.

枚举类型说明

◆ BslListPosition

the enum for specifying whether to add the element before/after the current element. It is used in BSL_LIST_AddElement() @datastruct BSL_LIST_POS_BEFORE Indication to to add the element before the current element. @datastruct BSL_LIST_POS_AFTER Indication to to add the element after the current element. @datastruct BSL_LIST_POS_BEGIN Indication to to add the element at the beginning of the list. @datastruct BSL_LIST_POS_END Indication to to add the element at the end of the list.

枚举值
BSL_LIST_POS_BEFORE 

Indication to to add the element before the current element

BSL_LIST_POS_AFTER 

Indication to to add the element after the current element

BSL_LIST_POS_BEGIN 

Indication to to add the element at the beginning of the list

BSL_LIST_POS_END 

Indication to to add the element at the end of the list

函数说明

◆ BSL_LIST_AddElement()

int32_t BSL_LIST_AddElement ( BslList * pList,
void * pData,
BslListPosition enPosition )

This function creates a new node before, after or at the begining or end of the current node. If the list was already NULL, the node will be added as the only node.The current pointer is changed to point to the newly added node in the list. If the current pointer is NULL then this operation fails.

参数
pList[IN] The list
pData[IN] The element to be added
enPosition[IN] Whether the element is to be added before or after the list
返回值
Theerror code.
BSL_SUCCESSIf successful.

◆ BSL_LIST_Concat()

BslList * BSL_LIST_Concat ( BslList * pDestList,
const BslList * pSrcList )

This function is used to concatenate list 2 to list 1.

参数
pDestList[IN] The list to which the 2nd list is to be concatenated to.
pSrcList[IN] The list which is to be concatenated.
返回值
BslList*The concatenated list. [BslList*]

◆ BSL_LIST_Copy()

BslList * BSL_LIST_Copy ( BslList * pSrcList,
BSL_LIST_PFUNC_DUP pFuncCpy,
BSL_LIST_PFUNC_FREE pfFreeFunc )

This function dups a list by copying the list by creating a copy of list and returns the destinaton list pointer.

参数
pSrcList[IN] The list
pFuncCpy[IN] The dup function for the data in the node
pfFreeFunc[IN] The pointer to the free function for the data in the node of data
返回值
BslList*The duplicated List pointer [BslList*]
BslList*If dup failed or memory allocation fails.[NULL]

◆ BSL_LIST_Curr()

void * BSL_LIST_Curr ( const BslList * pstList)

This function returns the data of the current element in the list.

参数
pstList[IN] Input list
返回值
void*Data at the current element in the list [void*]
void*If the current element does not exist in the list [NULL]
void*If memory allocation fails. [NULL]

◆ BSL_LIST_DeleteAll()

void BSL_LIST_DeleteAll ( BslList * pList,
BSL_LIST_PFUNC_FREE pfFreeFunc )

This function deletes all the nodes of the list but does not delete the list header.

参数
pList[IN] The list
pfFreeFunc[IN] The freefunction to free the data pointer in each node

◆ BSL_LIST_DeleteAllAfterSort()

void BSL_LIST_DeleteAllAfterSort ( BslList * pList)

Delete all the nodes in the list. But it does not delete the data pointers inside the list nodes. It is used only after sort to delete the input list to the sort function.

参数
pList[IN] The list.

◆ BSL_LIST_DeleteCurrent()

void BSL_LIST_DeleteCurrent ( BslList * pList,
BSL_LIST_PFUNC_FREE pfFreeFunc )

This function deletes the current element of list.

参数
pList[IN] The list
pfFreeFunc[IN] The pointer to the free function of data

◆ BSL_LIST_DeleteNode()

void BSL_LIST_DeleteNode ( BslList * pstList,
const BslListNode * pstListNode,
BSL_LIST_PFUNC_FREE pfFreeFunc )

This function deletes the matching input node from the input list.

参数
pstList[IN] The list.
pstListNode[IN] The current reference node.
pfFreeFunc[IN] The pointer to the free function of data.

◆ BSL_LIST_DetachCurrent()

void BSL_LIST_DetachCurrent ( BslList * pList)

This function detaches the current element from the list, the current node will be freed, but the data contained in the current node will not be freed.Also the pList->first, pList->curr and pList->last will be appropriately updated. If the current node is the last node, then pList->curr will point to its previous node after detachment, else it will point to its next node.

参数
pList[IN] The list

◆ BSL_LIST_DetachNode()

void BSL_LIST_DetachNode ( BslList * pstList,
BslListNode ** pstListNode )

This function detaches the matching input node from the input list. The node will be freed but, the data contained in the node will not be freed, and also the pList->first, pList->curr, and pList->last will be appropriately updated. If the matching node is the last node, then pList->curr will point to its previous node after detachment, else it will point to its next node.

参数
pstList[IN] The list.
pstListNode[in/out] when it is input parameter, it is the list node to be detached.

◆ BSL_LIST_First()

void * BSL_LIST_First ( BslList * pstList)

This function returns the data at the first element of the list.

参数
pstList[IN] the list
返回值
void*Data at the first element of the list [void*]
void*If the first element does not exist [NULL]

◆ BSL_LIST_FirstNode()

BslListNode * BSL_LIST_FirstNode ( const BslList * list)

This function returns the first element of the list.

参数
list[IN] The list.
返回值
BslListNode*first element of the list [BslListNode*]
BslListNode*If the first element does not exist [NULL]

◆ BSL_LIST_FreeWithoutData()

void BSL_LIST_FreeWithoutData ( BslList * pstList)

This function is used to free the Asn list.

参数
pstList[IN] list Pointer to the Asn list which has to be freed
返回值
voidThis function does not return any value.

◆ BSL_LIST_GetData()

void * BSL_LIST_GetData ( const BslListNode * pstNode)

This function returns the data of the passed list node.

参数
pstNode[IN] The node.
返回值
void*Data of the passed list node. [void*]
void*If the data is not present in the list node. [NULL]

◆ BSL_LIST_GetElmtIndex()

int32_t BSL_LIST_GetElmtIndex ( const void * elmt,
BslList * pstList )

This function returns the index (starting a 0 for the first element) of the given element in the given list. Returns -1, if the element is not in the list. Assumes that the list node contains a single pointer.

参数
elmt[IN] The element whose index is to be retrieved
pstList[IN] The list to which the element belongs to
返回值
int32_tThe index of the specified element in the given list [int32_t]
int32_tIf the element is not found in the list [-1]

◆ BSL_LIST_GetIndexNode()

void * BSL_LIST_GetIndexNode ( uint32_t ulIndex,
BslList * pList )

This function returns the node at the given index in the list, starting at 0.

参数
pList[IN] The list
ulIndex[IN] The index in the list
返回值
Void*The element which was found [Void*]
Void*If none found [NULL]

◆ BSL_LIST_GetMaxElements()

int32_t BSL_LIST_GetMaxElements ( void )

This function returns the max allowed elements in BSL_LIST.

返回值
int32_tMax configured elements in BSL_LIST

◆ BSL_LIST_GetMaxQsortCount()

uint32_t BSL_LIST_GetMaxQsortCount ( void )

This function returns the MAX qsort Size

返回值
uint32_tReturns the max qsort Size.

◆ BSL_LIST_GetNextNode()

BslListNode * BSL_LIST_GetNextNode ( const BslList * pstList,
const BslListNode * pstListNode )

This function advances the current reference pointer by one and returns the new current node. If the current reference pointer is off the list, the new current node will be the first node of the list (unless the list is NULL).

参数
pstList[IN] The list.
pstListNode[IN] The list node.
返回值
BslListNode*Pointer to next element in the list. [void*]
BslListNode*If the next element does not exist. [NULL]

◆ BSL_LIST_GetPrevNode()

BslListNode * BSL_LIST_GetPrevNode ( const BslListNode * pstListNode)

This function backs up the current reference pointer by one and returns the new current node.

参数
pstListNode[IN] The list node.
返回值
BslListNode*Pointer to the previous element in the list
BslListNode*If the previous element does not exist[NULL]

◆ BSL_LIST_Last()

void * BSL_LIST_Last ( BslList * pstList)

This function returns the data at the last element of the list.

参数
pstList[IN] The list
返回值
void*Data at the last element of the list [void*]
void*If the last element does not exist [NULL]

◆ BSL_LIST_New()

BslList * BSL_LIST_New ( int32_t dataSize)

This function is used to create a new list.

参数
dataSize[IN] Size of the data inside the list node
返回值
BslList*An NULL list [BslList*]

◆ BSL_LIST_Next()

void * BSL_LIST_Next ( BslList * pstList)

This function advances the current pointer by one and returns the data address of the new current node. If the current pointer is off the list, the new current node will be the first node of the list (unless the list is NULL).

参数
pstList[IN] The list
返回值
void*Pointer to the next element in the list [void*]
void*If the next element does not exist [NULL]

◆ BSL_LIST_Prev()

void * BSL_LIST_Prev ( BslList * pstList)

backs up the current pointer by one and returns the data address of the new current node. If the current pointer is off the list, the new current node will be the last node of the list (unless the list is NULL).

参数
pstList[IN] The list
返回值
void*Pointer to the previous element in the list [void*]
void*If the previous element does not exist[NULL]

◆ BSL_LIST_RevList()

void BSL_LIST_RevList ( BslList * pstList)

This function is used to reverse the linked list.

参数
pstList[IN] Pointer to the list which has to be reversed
返回值
voidThis function does not return any value.

◆ BSL_LIST_Search()

void * BSL_LIST_Search ( BslList * pList,
const void * pSearchFor,
BSL_LIST_PFUNC_CMP pSearcher,
int32_t * pstErr )

This function searches a list based on the comparator function supplied (3rd param). The second param is given to the comparator as its second param and each data item on the list is given as its first param while searching. The comparator must return 0 to indicate a match.

参数
pList[IN] The list
pSearchFor[IN] The element to be searched
pSearcher[IN] The pointer to the comparison function of data
返回值
Void*The element which was found [Void*]
Void*If none found [NULL]

◆ BSL_LIST_SetMaxElements()

int32_t BSL_LIST_SetMaxElements ( int32_t iMaxElements)

This function sets the max element in BSL_LIST.Default value is 10000000 (10 Million).

参数
iMaxElements[IN] Max allowed element in BSL_LIST. It should be in range[0xffff, 0xfffffff]
返回值
BSL_INVALID_ARGIf input falls outside the range.
BSL_SUCCESSIf successful.

◆ BSL_LIST_SetMaxQsortCount()

int32_t BSL_LIST_SetMaxQsortCount ( uint32_t uiQsortSize)

This function set the max qsort Size.Default value is 100000

参数
uiQsortSize[IN] Max Buff Size. it should in range of [10000, 67108864] Default value is 100000
返回值
int32_tBSL_SUCCESS on success BSL_INVALID_ARG on Failure.

◆ BSL_LIST_Sort()

BslList * BSL_LIST_Sort ( BslList * pList,
BSL_LIST_PFUNC_CMP pfCmp )

This function sorts the list using the comparison function provided.

参数
pList[IN] The list
pfCmp[IN] The comparison function
返回值
BslList*If unsuccessful [NULL]
BslList*If successful [The destination sorted list]