2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

97 Zeilen
2.0 KiB

  1. #ifndef IZ_LIST_H
  2. #define IZ_LIST_H
  3. #include "../../common/IZ_common.h"
  4. #include "SDL_stdinc.h"
  5. /**
  6. * A node in a linked list.
  7. */
  8. typedef struct IZ_ListNode {
  9. /**
  10. * The value of the node.
  11. */
  12. void* value;
  13. /**
  14. * The next node in the list.
  15. */
  16. struct IZ_ListNode* next;
  17. } IZ_ListNode;
  18. /**
  19. * A singly-linked list.
  20. */
  21. typedef struct {
  22. /**
  23. * The first node in the list.
  24. */
  25. IZ_ListNode* root;
  26. /**
  27. * The number of nodes in the list.
  28. */
  29. u64 length;
  30. /**
  31. * The iterator for traversing the list.
  32. */
  33. IZ_ListNode** iterator;
  34. /**
  35. * The custom data for use in matching for the find predicate.
  36. */
  37. void* find_predicate_userdata;
  38. } IZ_List;
  39. /**
  40. * Predicate for finding a node in a list.
  41. */
  42. typedef bool IZ_ListFindPredicate(IZ_ListNode**, u64, IZ_List*);
  43. /**
  44. * Comparator callback for sorting a list. Returns a positive value if a > b, a negative value if a < b, and 0 if a == b.
  45. */
  46. typedef i64 IZ_ListSortComparatorPredicate(IZ_ListNode**, IZ_ListNode**, u64, IZ_List*);
  47. /**
  48. * Initializes a list.
  49. */
  50. void IZ_ListInitialize(IZ_List*);
  51. /**
  52. * Performs cleanup on a list.
  53. */
  54. void IZ_ListTeardown(IZ_List*);
  55. /**
  56. * Appends a node to the end of the list.
  57. * @return Pointer to the newly created node.
  58. */
  59. IZ_ListNode** IZ_ListAppendNode(IZ_List*, void*);
  60. /**
  61. * Inserts a node at the specified index in the list.
  62. * @return Pointer to the newly created node.
  63. */
  64. IZ_ListNode** IZ_ListInsertNodeAtIndex(IZ_List*, void*, u64);
  65. /**
  66. * Deletes the first node in the list that matches the filter.
  67. */
  68. void IZ_ListDeleteFirstNode(IZ_List*, IZ_ListFindPredicate);
  69. /**
  70. * Finds the first node in the list that matches the filter.
  71. * @return Pointer to the node that matches the filter.
  72. */
  73. IZ_ListNode** IZ_ListFindFirstNode(IZ_List*, IZ_ListFindPredicate);
  74. /**
  75. * Creates a new list that contains the nodes that match the filter.
  76. */
  77. void IZ_ListFilter(IZ_List*, IZ_ListFindPredicate, IZ_List* out1);
  78. /**
  79. * Creates a new list that contains the sorted nodes from the original list.
  80. */
  81. void IZ_ListSort(IZ_List*, IZ_ListSortComparatorPredicate, IZ_List* out1);
  82. #endif