| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /**
- ******************************************************************************
- * @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);
- void tableRemoveWhite(Table *table);
- void markTable(Table *table);
- #endif//CLOX_TABLE_H
|