refactor(hash table): added const to some function parameters

This commit is contained in:
Mineplay 2025-05-23 17:35:50 -05:00
parent fe84e39ac7
commit 892388c218
3 changed files with 4 additions and 4 deletions

View file

@ -40,10 +40,10 @@ typedef struct {
size_t key_byte_size, value_byte_size;
FledastyDynamicArray *Table;
size_t (*hash_function)(void *key);
size_t (*hash_function)(const void *key);
} FledastyHashTable;
FledastyError fledasty_hash_table_initialize(FledastyHashTable *new_hash_table, size_t key_byte_size, size_t value_byte_size, size_t (*hash_function)(void *key));
FledastyError fledasty_hash_table_initialize(FledastyHashTable *new_hash_table, const size_t key_byte_size, const size_t value_byte_size, size_t (*hash_function)(const void *key));
FledastyError fledasty_hash_table_destroy(FledastyHashTable *current_hash_table);
FledastyError fledasty_hash_table_insert(FledastyHashTable *current_hash_table, void *key, void *value);

View file

@ -28,7 +28,7 @@
static const int FLEDASTY_HASH_TABLE_SIZE_THRESHOLD = 75;
FledastyError fledasty_hash_table_initialize(FledastyHashTable *new_hash_table, size_t key_byte_size, size_t value_byte_size, size_t (*hash_function)(void *key)) {
FledastyError fledasty_hash_table_initialize(FledastyHashTable *new_hash_table, const size_t key_byte_size, const size_t value_byte_size, size_t (*hash_function)(const void *key)) {
if (new_hash_table == NULL || hash_function == NULL) {
return FLEDASTY_ERROR_INVALID_POINTER;
}

View file

@ -29,7 +29,7 @@
#include <Fledasty/Core/HashTable.h>
#include <Fledasty/Strings/UTF8String.h>
static inline size_t integer_hash_function(void *key) { return *(size_t*)key; }
static inline size_t integer_hash_function(const void *key) { return *(size_t*)key; }
int main() {
FledastyQueue test_queue;