5 #ifndef _LINKED_LIST_H_
6 #define _LINKED_LIST_H_
14 typedef struct _LinkedList {
20 int32_t (*push_front) (
struct _LinkedList*, Item);
24 int32_t (*push_back) (
struct _LinkedList*, Item);
28 int32_t (*insert) (
struct _LinkedList*, Item, int32_t);
32 int32_t (*pop_front) (
struct _LinkedList*);
36 int32_t (*pop_back) (
struct _LinkedList*);
40 int32_t (*
delete) (
struct _LinkedList*, int32_t);
44 int32_t (*set_front) (
struct _LinkedList*, Item);
48 int32_t (*set_back) (
struct _LinkedList*, Item);
52 int32_t (*set_at) (
struct _LinkedList*, Item, int32_t);
56 int32_t (*get_front) (
struct _LinkedList*, Item*);
60 int32_t (*get_back) (
struct _LinkedList*, Item*);
64 int32_t (*get_at) (
struct _LinkedList*, Item*, int32_t);
68 int32_t (*size) (
struct _LinkedList*);
72 int32_t (*reverse) (
struct _LinkedList*);
76 int32_t (*iterate) (
struct _LinkedList*, bool, Item*);
80 int32_t (*reverse_iterate) (
struct _LinkedList*, bool, Item*);
84 int32_t (*replace) (
struct _LinkedList*, Item);
88 int32_t (*set_destroy) (
struct _LinkedList*, void (*) (Item));
int32_t LinkedListPopFront(LinkedList *self)
Pop an item from the head of the list.
int32_t LinkedListPushFront(LinkedList *self, Item item)
Push an item to the head of the list.
int32_t LinkedListInit(LinkedList **ppObj)
The constructor for LinkedList.
int32_t LinkedListInsert(LinkedList *self, Item item, int32_t iIdx)
Insert an item to the designated index of the list.
LinkedListData * pData
The container private information.
int32_t LinkedListPopBack(LinkedList *self)
Pop an item from the tail of the list.
int32_t LinkedListSetBack(LinkedList *self, Item item)
Replace an item at the tail of the list.
int32_t LinkedListPushBack(LinkedList *self, Item item)
Push an item to the tail of the list.
struct _LinkedListData LinkedListData
LinkedListData is the data type for the container private information.
int32_t LinkedListSetFront(LinkedList *self, Item item)
Replace an item at the head of the list.
int32_t LinkedListGetAt(LinkedList *self, Item *pItem, int32_t iIdx)
Get an item from the designated index of the list.
int32_t LinkedListSize(LinkedList *self)
Return the number of stored items.
int32_t LinkedListReplace(LinkedList *self, Item item)
Immediately replace the item at a specific iteration.
The implementation for doubly linked list.
int32_t LinkedListSetAt(LinkedList *self, Item item, int32_t iIdx)
Replace an item at the designated index of the list.
int32_t LinkedListDelete(LinkedList *self, int32_t iIdx)
Remove an item from the designated index of the list.
int32_t LinkedListGetFront(LinkedList *self, Item *pItem)
Get an item from the head of the list.
int32_t LinkedListReverseIterate(LinkedList *self, bool bReset, Item *pItem)
Reversely iterate through the list till the head end.
int32_t LinkedListReverse(LinkedList *self)
Reverse the list.
void LinkedListDeinit(LinkedList **ppObj)
The destructor for LinkedList.
int32_t LinkedListGetBack(LinkedList *self, Item *pItem)
Get an item from the tail of the list.
int32_t LinkedListSetDestroy(LinkedList *self, void(*pFunc)(Item))
Set the custom item resource clean method.
int32_t LinkedListIterate(LinkedList *self, bool bReset, Item *pItem)
Iterate through the list till the tail end.