2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

82 lignes
1.6 KiB

  1. #include "IZ_list.h"
  2. bool IZ_ListFindFilterAlwaysTrue(IZ_ListNode* _node, u64 _index) {
  3. return true;
  4. }
  5. void IZ_ListInitialize(IZ_List* list) {
  6. list->root = NULL;
  7. list->length = 0;
  8. }
  9. void IZ_ListTeardown(IZ_List* list) {
  10. while (list->root) {
  11. _IZ_ListDeleteFirstNode(list, IZ_ListFindFilterAlwaysTrue);
  12. }
  13. }
  14. IZ_ListNode* IZ_ListAppendNode(IZ_List* list, void* node_value) {
  15. IZ_ListNode* new_node = SDL_malloc(sizeof(IZ_ListNode));
  16. new_node->value = node_value;
  17. if (!(list->root)) {
  18. list->root = new_node;
  19. } else {
  20. IZ_ListNode *last_node = list->root;
  21. while (last_node->next) {
  22. last_node = last_node->next;
  23. }
  24. last_node->next = new_node;
  25. }
  26. new_node->next = NULL;
  27. list->length += 1;
  28. return new_node;
  29. }
  30. void _IZ_ListDeleteFirstNode(IZ_List* list, IZ_ListFindFilter filter) {
  31. if (!(list && list->root)) {
  32. return;
  33. }
  34. IZ_ListNode* iterator = list->root;
  35. IZ_ListNode* previous_node = NULL;
  36. u64 index = 0;
  37. do {
  38. if (!filter(iterator, index)) {
  39. previous_node = iterator;
  40. iterator = iterator->next;
  41. index += 1;
  42. continue;
  43. }
  44. if (previous_node) {
  45. previous_node->next = iterator->next;
  46. } else {
  47. list->root = iterator->next;
  48. }
  49. SDL_free(iterator);
  50. iterator = NULL;
  51. list->length -= 1;
  52. return;
  53. } while (iterator);
  54. }
  55. IZ_ListNode* _IZ_ListFindFirstNode(IZ_List* list, IZ_ListFindFilter filter) {
  56. if (!(list && list->root)) {
  57. return NULL;
  58. }
  59. IZ_ListNode* iterator = list->root;
  60. u64 index = 0;
  61. do {
  62. if (!filter(iterator, index)) {
  63. iterator = iterator->next;
  64. index += 1;
  65. continue;
  66. }
  67. return iterator;
  68. } while (iterator);
  69. return NULL;
  70. }