代码拉取完成,页面将自动刷新
//
// 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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。