Linklist module Module that handles linklists
Link List - How to
This module provides an easy and powerful interface for manipulating linked lists.
Data definition
Using this data structure as an example:
typedef struct __orxFOO_t
{
orxU32 u32Data; Data
} orxFOO;
Data without link
Creating a bank to allocate memory storage:
#define orxBANK_KU32_FLAG_NONE
struct __orxBANK_t orxBANK
orxDLLAPI orxBANK *orxFASTCALL orxBank_Create(orxU32 _u32Count, orxU32 _u32Size, orxU32 _u32Flags, orxMEMORY_TYPE _eMemType)
You can then instantiate it this way:
pstNode->u32Data = 205;
orxDLLAPI void *orxFASTCALL orxBank_Allocate(orxBANK *_pstBank)
Having this basic behavior, you can add list linking to it.
Linked list item definition
To do so, you need to include in your structure an orxLINKLIST_NODE member as FIRST MEMBER:
typedef struct __orxFOO_t
{
orxU32 u32Data;
} orxFOO;
Use of link list
Your data structure can now be linked in lists:
orxDLLAPI orxSTATUS orxFASTCALL orxLinkList_AddEnd(orxLINKLIST *_pstList, orxLINKLIST_NODE *_pstNode)
- Note
- As the first member of your data structure is a linked list node, you can cast your structure to orxLINKLIST_NODE and reciprocally.
◆ orxLinkList_AddAfter()
Adds a node after another one
- Parameters
-
[in] | _pstRefNode | Reference node (add after this one) |
[in] | _pstNode | Node to add |
- Returns
- orxSTATUS_SUCCESS / orxSTATUS_FAILURE
◆ orxLinkList_AddBefore()
Adds a node before another one
- Parameters
-
[in] | _pstRefNode | Reference node (add before this one) |
[in] | _pstNode | Node to add |
- Returns
- orxSTATUS_SUCCESS / orxSTATUS_FAILURE
◆ orxLinkList_AddEnd()
Adds a node at the end of a list
- Parameters
-
[in] | _pstList | Concerned list |
[in] | _pstNode | Node to add |
- Returns
- orxSTATUS_SUCCESS / orxSTATUS_FAILURE
◆ orxLinkList_AddStart()
Adds a node at the start of a list
- Parameters
-
[in] | _pstList | Concerned list |
[in] | _pstNode | Node to add |
- Returns
- orxSTATUS_SUCCESS / orxSTATUS_FAILURE
◆ orxLinkList_Clean()
Cleans a linklist
- Parameters
-
[in] | _pstList | Concerned list |
- Returns
- orxSTATUS_SUCCESS / orxSTATUS_FAILURE
◆ orxLinkList_GetCount()
orxINLINE orxU32 orxLinkList_GetCount |
( |
const orxLINKLIST * | _pstList | ) |
|
|
static |
Gets a list count
- Parameters
-
[in] | _pstList | Concerned list |
- Returns
- Number of nodes in list
Definition at line 228 of file orxLinkList.h.
◆ orxLinkList_GetFirst()
◆ orxLinkList_GetLast()
◆ orxLinkList_GetList()
◆ orxLinkList_GetNext()
◆ orxLinkList_GetPrevious()
◆ orxLinkList_Remove()
Removes a node from its list
- Parameters
-
[in] | _pstNode | Concerned node |
- Returns
- orxSTATUS_SUCCESS / orxSTATUS_FAILURE