Add the hashtable based on uthash.h to docs

This commit is contained in:
krahets
2023-04-18 21:19:57 +08:00
parent dbc4906582
commit 661603d467
5 changed files with 13 additions and 10 deletions

View File

@@ -30,12 +30,13 @@ void constant(int n) {
}
/* 哈希表 */
typedef struct hashTable {
struct hashTable {
int key;
int val;
// 借助 LetCode 上常用的哈希表
UT_hash_handle hh;
} hashTable;
UT_hash_handle hh; // 基于 uthash.h 实现
};
typedef struct hashTable hashTable;
/* 线性阶 */
void linear(int n) {
@@ -56,7 +57,6 @@ void linear(int n) {
// 长度为 n 的哈希表占用 O(n) 空间
hashTable *h = NULL;
for (int i = 0; i < n; i++) {
hashTable *tmp = malloc(sizeof(hashTable));
tmp->key = i;