feat(linked list): implemented is empty function
This commit is contained in:
parent
d89747a2ed
commit
34246c10d7
2 changed files with 8 additions and 1 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#define FLEDASTY_LINKED_LIST
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../Utils/Error.h"
|
||||
|
||||
|
|
@ -43,4 +44,6 @@ FledastyError fledasty_linked_list_destroy(FledastyLinkedList *current_linked_li
|
|||
|
||||
FledastyError fledasty_linked_list_append(FledastyLinkedList *current_linked_list, void *value);
|
||||
|
||||
static inline bool fledasty_linked_list_is_empty(FledastyLinkedList *current_linked_list) { return current_linked_list->size == 0; }
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -111,11 +111,15 @@ int main() {
|
|||
}
|
||||
|
||||
FledastyLinkedListNode *test_linked_list_node = test_linked_list.start;
|
||||
for (int i = 0; i < test_linked_list.size; i++) {
|
||||
for (int i = 0; i < test_linked_list.size; i += 1) {
|
||||
printf("Linked list get: %d\n", *(int*)test_linked_list_node->value);
|
||||
test_linked_list_node = test_linked_list_node->next;
|
||||
}
|
||||
|
||||
if (fledasty_linked_list_is_empty(&test_linked_list)) {
|
||||
printf("Linked list is empty\n");
|
||||
}
|
||||
|
||||
fledasty_linked_list_destroy(&test_linked_list);
|
||||
printf("Done\n");
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue