list.h 771 B

123456789101112131415161718192021222324
  1. #pragma once
  2. #include <stdlib.h>
  3. #include <inttypes.h>
  4. typedef struct ListNode {
  5. void* data;
  6. struct ListNode* next;
  7. } ListNode;
  8. ListNode* list_init_head(void* data);
  9. ListNode* list_add(
  10. ListNode* head,
  11. void* data); /* adds element with specified data to the end of the list and returns new head node. */
  12. ListNode* list_find(
  13. ListNode* head,
  14. void* data); /* returns pointer of element with specified data in list. */
  15. ListNode* list_element_at(
  16. ListNode* head,
  17. uint16_t index); /* returns pointer of element with specified index in list. */
  18. ListNode* list_remove(
  19. ListNode* head,
  20. ListNode* ep); /* removes element from the list and returns new head node. */
  21. void list_free(ListNode* head); /* deletes all elements of the list. */