From 984f89388559d98063b276b33be1e047dae2210f Mon Sep 17 00:00:00 2001 From: Mineplay Date: Thu, 1 May 2025 03:27:08 -0500 Subject: [PATCH] feat(doubly linked list): implemented is empty function --- Include/Fledasty/Core/DoublyLinkedList.h | 2 ++ Tests/Main.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Include/Fledasty/Core/DoublyLinkedList.h b/Include/Fledasty/Core/DoublyLinkedList.h index b080996..96f96ea 100644 --- a/Include/Fledasty/Core/DoublyLinkedList.h +++ b/Include/Fledasty/Core/DoublyLinkedList.h @@ -48,4 +48,6 @@ FledastyError fledasty_doubly_linked_list_insert_at_index(FledastyDoublyLinkedLi FledastyError fledasty_doubly_linked_list_insert_before_value(FledastyDoublyLinkedList *current_doubly_linked_list, void *before_value, void *value); FledastyError fledasty_doubly_linked_list_insert_after_value(FledastyDoublyLinkedList *current_doubly_linked_list, void *after_value, void *value); +static inline bool fledasty_doubly_linked_list_is_empty(const FledastyDoublyLinkedList *current_doubly_linked_list) { return current_doubly_linked_list->size == 0; } + #endif \ No newline at end of file diff --git a/Tests/Main.c b/Tests/Main.c index 091ce51..e75e1dd 100644 --- a/Tests/Main.c +++ b/Tests/Main.c @@ -166,6 +166,10 @@ int main() { test_doubly_linked_list_node = test_doubly_linked_list_node->previous; } + if (fledasty_doubly_linked_list_is_empty(&test_doubly_linked_list)) { + printf("Linked list is empty\n"); + } + fledasty_doubly_list_destroy(&test_doubly_linked_list); printf("Done\n"); return 0;