HALFRED  0.4.0
hal_linklist.h
Go to the documentation of this file.
1 
10 #ifndef HAL_LINKLIST_H_
11 #define HAL_LINKLIST_H_
12 
13 
14 #include "hal_defs.h"
15 #include <stddef.h>
16 
17 
27 struct LLSTItemDesc {
28  struct LLSTItemDesc* next;
29  const void* data;
30 };
31 
32 typedef struct LLSTItemDesc LLSTItemDesc;
33 
34 typedef struct LLSTItemDesc* LLSTItem;
35 
36 
37 typedef struct {
38  size_t size;
39  LLSTItem items;
40  LLSTItem first;
41  LLSTItem last;
43 
44 #define LLST_DECLARE(name, size, attributes) \
45  static LLSTItemDesc name##_items[size]; \
46  attributes LLSTListDesc name = { size, name##_items , NULL, NULL}
47 
48 
59 HALRESULT LLST_Init(LLSTList list, LLSTItem items, size_t size);
60 
68 HALRESULT LLST_Deinit(LLSTList list);
69 
82 HALRESULT LLST_AddItem(LLSTList list, const void* data, LLSTItem* new_item);
83 
90 const void* LLST_UnlinkFirstItem(LLSTList list);
91 
98 const void* LLST_UnlinkLastItem(LLSTList list);
99 
107 const void* LLST_UnlinkItem(LLSTList list, LLSTItem item);
108 
115 LLSTItem LLST_GetFirstItem(LLSTList list);
116 
123 LLSTItem LLST_GetNextItem(LLSTItem item);
124 
131 LLSTItem LLST_GetLastItem(LLSTList list);
132 
140 LLSTItem LLST_GetItemByIndex(LLSTList list, size_t index);
141 
149 LLSTItem LLST_GetItemByData(LLSTList list, const void* data);
150 
157 const void* LLST_GetItemData(LLSTItem item);
158 
167 HALRESULT LLST_SetItemData(LLSTItem item, const void* data);
168 
171 #endif /* HAL_LINKLIST_H_ */
HALRESULT
Definition: hal_defs.h:16
Definition: hal_linklist.h:37
Definition: hal_linklist.h:27
Various HAL definitions.