Ai
1 Star 4 Fork 4

觉皇/HashMap

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
HashMap.h 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
觉皇 提交于 2019-12-05 15:04 +08:00 . first
//
// Created by AnKun on 2019/12/3.
//
#ifndef MYHASHMAP_HASHMAP_H
#define MYHASHMAP_HASHMAP_H
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "malloc.h"
#include "List.h"
#define hmalloc mem_malloc
#define hfree mem_free
#define hmemcpy mem_memcpy
#define hmemset mem_memset
#define hrealloc mem_realloc
#define KEY_MAX_LEN 16 // key的最大长度
#define VAL_MAX_LEN 32 // value的最大长度
#pragma pack(4)
typedef struct list_head HashTable;
typedef struct
{
HashTable *items; // 键值对条目,如果有冲突键值对则挂在链表后
uint32_t used; // 使用量
uint32_t size; // 总大小
} HashMap;
typedef struct
{
uint8_t key[KEY_MAX_LEN];
uint8_t value[VAL_MAX_LEN];
struct list_head node;
} Entry;
HashMap *HashMap_Create(uint32_t size);
void HashMap_Destroy(HashMap *hashMap);
bool HashMap_Put(HashMap *hashMap, const void *key, const void *value);
void *HashMap_Get(const HashMap *const hashMap, const void *key);
void HashMap_Clear(HashMap *hashMap);
void HashMap_Remove(HashMap *hashMap, const void *key);
bool HashMap_Exists(const HashMap *const hashMap, const void *key);
void HashMap_GetKeys(const HashMap *const hashMap, uint8_t **keys, uint32_t *count);
#pragma pack()
#endif //MYHASHMAP_HASHMAP_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/jhembed/HashMap.git
git@gitee.com:jhembed/HashMap.git
jhembed
HashMap
HashMap
master

搜索帮助