37 lines
678 B
C
37 lines
678 B
C
|
#pragma once
|
||
|
#ifndef HW_LIB_HASH_TABLE_H
|
||
|
#define HW_LIB_HASH_TABLE_H
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
#define HT_PRIME_1 151
|
||
|
#define HT_PRIME_2 163
|
||
|
#define HT_INITIAL_BASE_SIZE 53
|
||
|
|
||
|
|
||
|
typedef struct Hash_Item
|
||
|
{
|
||
|
char* key;
|
||
|
char* value;
|
||
|
} Hash_Item_t;
|
||
|
|
||
|
typedef struct Hash_Table
|
||
|
{
|
||
|
int base_size;
|
||
|
int size;
|
||
|
int count;
|
||
|
Hash_Item_t** items;
|
||
|
} Hash_Table_t;
|
||
|
|
||
|
Hash_Table_t* ht_new();
|
||
|
void ht_del_hash_table(Hash_Table_t* ht);
|
||
|
void ht_insert(Hash_Table_t* ht, const char* key, const char* value);
|
||
|
char* ht_search(Hash_Table_t* ht, const char* key);
|
||
|
void ht_delete(Hash_Table_t* h, const char* key);
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
#endif //HW_LIB_HASH_TABLE_H
|