Docs

You are here:
LinkList module

Classes

struct  LLSTItemDesc
 
struct  LLSTListDesc
 

Macros

#define LLST_DECLARE(name, size, attributes)
 

Typedefs

typedef struct LLSTItemDesc LLSTItemDesc
 
typedef struct LLSTItemDescLLSTItem
 
typedef struct LLSTListDescLLSTList
 

Functions

HALRESULT LLST_Init (LLSTList list, LLSTItem items, size_t size)
 
HALRESULT LLST_Deinit (LLSTList list)
 
HALRESULT LLST_AddItem (LLSTList list, const void *data, LLSTItem *new_item)
 
const void * LLST_UnlinkFirstItem (LLSTList list)
 
const void * LLST_UnlinkLastItem (LLSTList list)
 
const void * LLST_UnlinkItem (LLSTList list, LLSTItem item)
 
LLSTItem LLST_GetFirstItem (LLSTList list)
 
LLSTItem LLST_GetNextItem (LLSTItem item)
 
LLSTItem LLST_GetLastItem (LLSTList list)
 
LLSTItem LLST_GetItemByIndex (LLSTList list, size_t index)
 
LLSTItem LLST_GetItemByData (LLSTList list, const void *data)
 
const void * LLST_GetItemData (LLSTItem item)
 
HALRESULT LLST_SetItemData (LLSTItem item, const void *data)
 

Detailed Description

Introduction.

The LinkList module provides the functionality of a single-link list of items.

Macro Definition Documentation

#define LLST_DECLARE (   name,
  size,
  attributes 
)
Value:
static LLSTItemDesc name##_items[size]; \
attributes LLSTListDesc name = { size, name##_items , NULL, NULL};
Definition: hal_linklist.h:22
Definition: hal_linklist.h:32

Function Documentation

HALRESULT LLST_AddItem ( LLSTList  list,
const void *  data,
LLSTItem new_item 
)

Adds new item to the list.

Parameters
listlink list
dataitem data
new_itempointer to a variable where the new item will be stored
Return values
HALRESULT_OKif new element was added successfully
HALRESULT_LINKLIST_FULLif the list is full and new element cannot be added
HALRESULT_INVALID_LINKLIST_DATAif the provided data is NULL
HALRESULT_INVALID_LINKLISTif the list is invalid
HALRESULT_EMPTY_LINKLISTif the list pool size is zero
HALRESULT LLST_Deinit ( LLSTList  list)

Deinitializes link list.

Parameters
listlink list
Return values
HALRESULT_OKif list was deinitialized successfully
HALRESULT_INVALID_LINKLISTif provided link list is invalid
LLSTItem LLST_GetFirstItem ( LLSTList  list)

Retrieves first element on the list.

Parameters
listlink list
Returns
first element on the list or NULL if the list holds no elements
LLSTItem LLST_GetItemByData ( LLSTList  list,
const void *  data 
)

Retrieves item associated with the given data.

Parameters
listlink list
dataitem data
Returns
item associated with the given data or NULL if there is no such element
LLSTItem LLST_GetItemByIndex ( LLSTList  list,
size_t  index 
)

Retrieves item under given index.

Parameters
listlink list
indexindex (0-based)
Returns
item under given index or NULL if there is no element under given index
const void* LLST_GetItemData ( LLSTItem  item)

Retrieves data associated with a given element.

Parameters
itemelement
Returns
data associated with the given element
LLSTItem LLST_GetLastItem ( LLSTList  list)

Retrieves last element on the list.

Parameters
listlink list
Returns
last element on the list or NULL if the list holds no elements
LLSTItem LLST_GetNextItem ( LLSTItem  item)

Retrieves next element on the list, relative to the given one.

Parameters
itemelement on the list
Returns
next element on the list or NULL if the given element is last on the list
HALRESULT LLST_Init ( LLSTList  list,
LLSTItem  items,
size_t  size 
)

Initializes link list.

Parameters
listlink list
itemspointer to a pool of items
sizenumber of elements in the pool of items
Return values
HALRESULT_OKif list was initialized successfully
HALRESULT_EMPTY_LINKLISTwhen the provided pool size is zero
HALRESULT_INVALID_LINKLISTwhen the provided pool or list is invalid
HALRESULT LLST_SetItemData ( LLSTItem  item,
const void *  data 
)

Sets data for the given item.

Parameters
itemlink list item
datanew data pointer
Return values
HALRESULT_OKif the item data was set successfully
HALRESULT_INVALID_LINKLIST_ITEMif item was invalid
const void* LLST_UnlinkFirstItem ( LLSTList  list)

Removes first item from the list.

Parameters
listlink list
Returns
data associated with the removed element
const void* LLST_UnlinkItem ( LLSTList  list,
LLSTItem  item 
)

Removes a given element from the list.

Parameters
listlink list
item
Returns
data associated with the removed element
const void* LLST_UnlinkLastItem ( LLSTList  list)

Removes last item from the list.

Parameters
listlink list
Returns
data associated with the removed element
Go to Top