f3-basic-hash-tabel #21

Merged
Mineplay merged 12 commits from f3-basic-hash-tabel into main 2025-05-02 06:24:05 -05:00
3 changed files with 12 additions and 0 deletions
Showing only changes of commit 0dfa753a56 - Show all commits

View file

@ -43,6 +43,8 @@ FledastyError fledasty_queue_push(FledastyQueue *current_queue, void *value);
void *fledasty_queue_peek(const FledastyQueue *current_queue); void *fledasty_queue_peek(const FledastyQueue *current_queue);
void *fledasty_queue_pop(FledastyQueue *current_queue); void *fledasty_queue_pop(FledastyQueue *current_queue);
FledastyError fledasty_queue_clear(FledastyQueue *current_queue);
static inline bool fledasty_queue_is_empty(const FledastyQueue *current_queue) { return current_queue->size == 0; } static inline bool fledasty_queue_is_empty(const FledastyQueue *current_queue) { return current_queue->size == 0; }
#endif #endif

View file

@ -125,3 +125,12 @@ void *fledasty_queue_pop(FledastyQueue *current_queue) {
return value_address; return value_address;
} }
FledastyError fledasty_queue_clear(FledastyQueue *current_queue) {
if (current_queue == NULL) {
return FLEDASTY_ERROR_INVALID_POINTER;
}
current_queue->size = 0;
return FLEDASTY_ERROR_NONE;
}

View file

@ -45,6 +45,7 @@ int main() {
printf("Queue popped: %d\n", *popped_data); printf("Queue popped: %d\n", *popped_data);
} }
fledasty_queue_clear(&test_queue);
if (fledasty_queue_is_empty(&test_queue)) { if (fledasty_queue_is_empty(&test_queue)) {
printf("Queue is empty\n"); printf("Queue is empty\n");
} }