void linked_list_Insert ( LinkedListRef** list, void* item );
Insert a new Item to the LinkedList
void* linked_list_Remove ( LinkedListRef** list, void* item );
Remove an item from the LinkedList
- param list - Reference to the LinkedList
- param item - Reference to the item to be removed
- returns void* - Reference to the recently removed item, NULL if item is not found
- @warning Freeing the allocated memory of the returned pointer is the developer's responsibility.
void linked_list_Iterate ( LinkedListRef** list, IterateMethod callbackMethod, void* userData );
Iterate all items in the LinkedList
- param list - Reference to the LinkedList
- param callbackMethod - A callback function which is called for each item
- param userData - A pointer which is sent to the callback method.
void* linked_list_Search ( LinkedListRef** list, SearchMethod testMethod, void* userData );
Search for an item in the LinkedList
- param list - Reference to the LinkedList
- param testMethod - A callback function which is called for each item as a comparison test.
- param userData - A pointer which is sent to the callback method.
- returns void* Reference to the item found as a result of the search, NULL if item not found.
void linked_list_Drop ( LinkedListRef** list, FreeMethod freeCallback );
Free the complete Linked List and the data it contains.
- param list - Reference to the LinkedList.
- param freeCallback - Callback Method called for each item removed from linked list.
- @warning Developer should free the memory of that item in this callback.
struct __linked_list_item_ref {
void* data;
struct __linked_list_item_ref* next;
};
typedef struct __linked_list_item_ref LinkedListRef;
typedef bool (*SearchMethod) (void* listItem, void* userData);
Callback Method template for search operation in a LinkedList
- param listItem - A test item
- param userData - A pointer as given to
linked_list_Search
- returns boolean - true if comparison successful, false otherwise
typedef void (*IterateMethod)(int index, void* listItem, void* userData);
Callback Method for each item in the iteration of the linked list
- param index - item index
- param listItem - An item from the linked list
- param userData - A pointer as given to
linked_list_Iterate
typedef void (*FreeMethod)(void* listItem);
Callback Method for each item in the iteration of the linked list
- param listItem - Pointer to the item to be freed.