2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

99 lines
1.9 KiB

  1. #ifndef IZ_LIST_H
  2. #define IZ_LIST_H
  3. #include "../../common/IZ_common.h"
  4. #include "../../stdinc/IZ_stdlib.h"
  5. struct IZ_List;
  6. /**
  7. * A node in a linked list.
  8. */
  9. typedef struct IZ_ListNode {
  10. /**
  11. * The list that the node belongs to.
  12. */
  13. struct IZ_List* list;
  14. /**
  15. * The previous node in the list.
  16. */
  17. struct IZ_ListNode* previous;
  18. /**
  19. * The value of the node.
  20. */
  21. void* value;
  22. /**
  23. * The next node in the list.
  24. */
  25. struct IZ_ListNode* next;
  26. } IZ_ListNode;
  27. /**
  28. * A doubly-linked list.
  29. */
  30. typedef struct IZ_List {
  31. /**
  32. * The first node in the list.
  33. */
  34. IZ_ListNode* root;
  35. /**
  36. * The number of nodes in the list.
  37. */
  38. u64 length;
  39. /**
  40. * The iterator for traversing the list.
  41. */
  42. IZ_ListNode** iterator;
  43. } IZ_List;
  44. typedef bool IZ_ListFindPredicate(IZ_ListNode**, u64, IZ_List*);
  45. #ifdef IZ_DEBUG
  46. void IZ_ListPrintNodeValues(IZ_List*);
  47. #endif
  48. /**
  49. * Initializes a list.
  50. */
  51. void IZ_ListInitialize(IZ_List*);
  52. /**
  53. * Performs cleanup on a list.
  54. */
  55. void IZ_ListTeardown(IZ_List*);
  56. /**
  57. * Appends a node to the end of the list.
  58. * @return Pointer to the newly created node.
  59. */
  60. void IZ_ListAppendNode(IZ_List*, void*, IZ_ListNode**);
  61. /**
  62. * Deletes the first node in the list that matches the filter.
  63. */
  64. void IZ_ListDeleteNode(IZ_ListNode*);
  65. /**
  66. * Finds the first node in the list that matches the filter.
  67. * @return Pointer to the node that matches the filter.
  68. * @see IZ_ListFindPredicate
  69. * @see IZ_ListFindAllNodes
  70. */
  71. void IZ_ListFindFirstNode(IZ_List*, IZ_ListFindPredicate, IZ_ListNode**);
  72. /**
  73. * Finds all nodes in the list that match the filter.
  74. * @return New list containing nodes that match the filter.
  75. * @see IZ_ListFindPredicate
  76. * @see IZ_ListFindFirstNode
  77. */
  78. void IZ_ListFindAllNodes(IZ_List*, IZ_ListFindPredicate, IZ_List*);
  79. /**
  80. * Inserts a node at the specified index.
  81. * @return Pointer to the newly created node.
  82. */
  83. void IZ_ListInsertNodeAtIndex(IZ_List*, void*, u64, IZ_ListNode**);
  84. #endif