Skip to content

Repository files navigation

CMakeCodeQLCodeFactorcodecovFOSSA Status

Linked List

API Documentation


Insert an item

voidlinked_list_Insert ( LinkedListRef**list, void*item );

Insert a new Item to the LinkedList

  • paramlist - Reference to the LinkedList
  • paramitem - Reference to the item to be added

Remove an item

void*linked_list_Remove ( LinkedListRef**list, void*item );

Remove an item from the LinkedList

  • paramlist - Reference to the LinkedList
  • paramitem - Reference to the item to be removed
  • returnsvoid* - 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.

Iterate all items

voidlinked_list_Iterate ( LinkedListRef**list, IterateMethodcallbackMethod, void*userData );

Iterate all items in the LinkedList

  • paramlist - Reference to the LinkedList
  • paramcallbackMethod - A callback function which is called for each item
  • paramuserData - A pointer which is sent to the callback method.

Search for an item

void*linked_list_Search ( LinkedListRef**list, SearchMethodtestMethod, void*userData );

Search for an item in the LinkedList

  • paramlist - Reference to the LinkedList
  • paramtestMethod - A callback function which is called for each item as a comparison test.
  • paramuserData - A pointer which is sent to the callback method.
  • returnsvoid* Reference to the item found as a result of the search, NULL if item not found.

Drop a Linked List

voidlinked_list_Drop ( LinkedListRef**list, FreeMethodfreeCallback );

Free the complete Linked List and the data it contains.

  • paramlist - Reference to the LinkedList.
  • paramfreeCallback - Callback Method called for each item removed from linked list.
  • @warning Developer should free the memory of that item in this callback.

Type Definitions

LinkedListRef Structure

struct__linked_list_item_ref {
void*data;
struct__linked_list_item_ref*next;
};
typedefstruct__linked_list_item_refLinkedListRef;

SearchMethod Callback

typedefbool (*SearchMethod) (void*listItem, void*userData);

Callback Method template for search operation in a LinkedList

  • paramlistItem - A test item
  • paramuserData - A pointer as given to linked_list_Search
  • returnsboolean - true if comparison successful, false otherwise

Iterate Method Callback

typedefvoid (*IterateMethod)(intindex, void*listItem, void*userData);

Callback Method for each item in the iteration of the linked list

  • paramindex - item index
  • paramlistItem - An item from the linked list
  • paramuserData - A pointer as given to linked_list_Iterate

Free Method Callback

typedefvoid (*FreeMethod)(void*listItem);

Callback Method for each item in the iteration of the linked list

  • paramlistItem - Pointer to the item to be freed.

License

FOSSA Status

About

A data agnostic singly linked list in C.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages