feat(hash table): implemented is empty function

This commit is contained in:
Mineplay 2025-05-01 16:20:44 -05:00
parent 29b62b1df4
commit 448f37521d
3 changed files with 7 additions and 0 deletions

View file

@ -50,4 +50,6 @@ FledastyError fledasty_hash_table_insert(FledastyHashTable *current_hash_table,
void *fledasty_hash_table_get(FledastyHashTable *current_hash_table, void *key);
FledastyError fledasty_hash_table_remove(FledastyHashTable *current_hash_table, void *key);
static inline bool fledasty_hash_table_is_empty(FledastyHashTable *current_hash_table) { return current_hash_table->size == 0; }
#endif

View file

@ -135,6 +135,7 @@ FledastyError fledasty_hash_table_remove(FledastyHashTable *current_hash_table,
hallocy_free(value->value);
fledasty_dynamic_array_remove_at_index(&current_hash_table->Table[index], list_index);
current_hash_table->size -= 1;
return FLEDASTY_ERROR_NONE;
}

View file

@ -206,6 +206,10 @@ int main() {
printf("Hash table get: %d\n", *hash_table_value);
}
if (fledasty_hash_table_is_empty(&test_hash_table)) {
printf("Hash table is empty\n");
}
fledasty_hash_table_destroy(&test_hash_table);
printf("Done\n");
return 0;