#ifndef TSL_HASH_MAP_H #define TSL_HASH_MAP_H #include "../value.h" #include /* TODO: Optimize small hash map by using the members of the struct instead of allocating on heap */ typedef struct { void *buckets_data; /* value=TslHashMapNode */ size_t buckets_size; size_t buckets_capacity; } TslHashMap; void tsl_hash_map_init(TslHashMap *self); int tsl_hash_map_insert(TslHashMap *self, const TslValue *key, TslValue *value); /* Get a reference to the value by key @key, or NULL if it doesn't exist. The returned pointer is only valid until until reallocation after after insert inserting a new value into the hash map. */ TslValue* tsl_hash_map_get(TslHashMap *self, const TslValue *key); /* Get a reference to the value by key @key, or insert a new value for the key (a TslValue). Returns NULL on failure. The returned pointer is only valid until until reallocation after after insert inserting a new value into the hash map. */ TslValue* tsl_hash_map_get_or_create(TslHashMap *self, const TslValue *key); #endif /* TSL_HASH_MAP_H */