/** ****************************************************************************** * @file : table.h * @author : simon * @brief : Building a Hash Table -- buckets, load factors, open addressing * collision resolution, and hash functions * @attention : None * @date : 2023/8/24 ****************************************************************************** */ #ifndef CLOX_TABLE_H #define CLOX_TABLE_H #include "common.h" #include "value.h" typedef struct { ObjString *key; Value value; } Entry; typedef struct { int count; int capacity; Entry *entries; } Table; void initTable(Table *table); void freeTable(Table *table); bool tableGet(Table *table, ObjString *key, Value *value); bool tableSet(Table *table, ObjString *key, Value value); bool tableDelete(Table *table, ObjString *key); void tableAddAll(Table *from, Table *to); /// 查找字符串 /// \param table Table* /// \param chars const char* /// \param length int /// \param hash uint32_t /// \return ObjString* ObjString *tableFindString(Table *table, const char *chars, int length, uint32_t hash); #endif//CLOX_TABLE_H