feat(hash table): implemented is empty function
This commit is contained in:
parent
29b62b1df4
commit
448f37521d
3 changed files with 7 additions and 0 deletions
|
|
@ -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
|
||||
|
|
@ -135,6 +135,7 @@ FledastyError fledasty_hash_table_remove(FledastyHashTable *current_hash_table,
|
|||
hallocy_free(value->value);
|
||||
|
||||
fledasty_dynamic_array_remove_at_index(¤t_hash_table->Table[index], list_index);
|
||||
current_hash_table->size -= 1;
|
||||
return FLEDASTY_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue