diff --git a/test_hash.h b/test_hash.h new file mode 100644 index 000000000..692eb6489 --- /dev/null +++ b/test_hash.h @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2020 AIIT Ubiquitous Team +* XiUOS is licensed under Mulan PSL v2. +* You can use this software according to the terms and conditions of the Mulan PSL +v2. +* You may obtain a copy of Mulan PSL v2 at: +* http://license.coscl.org.cn/MulanPSL2 +* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +* See the Mulan PSL v2 for more details. +*/ +/************************************************* +File name: test_hash.h +Description: a application of test hash function +Date: 2023/10/02 +Author: Lu Xin +*************************************************/ + +#ifndef TEST_HASH_TEST_HASH_H +#define TEST_HASH_TEST_HASH_H + +//余数:也是指针数组的元素个数:也是链表的个数 +#define N 13 + +//这个定义的是 指针数组的 每个指针的大小,(64位系统)8个字节 +#define ADDR_SIZE 8 + +//hash表的链表的节点 +typedef struct node { + int data;//存数据 + struct node *next;//存指针 +}hashType; + +//创建hash表 +hashType **create_hash(); + +//插入数据 +int insert_hash_table(hashType **h, int data); + +//遍历 +int show_hash_table(struct node *head); + +//释放链表节点 +void free_hash_table(struct node *head); + +//查找数据 +int search_hash_table(hashType **h, int data); + +#endif //TEST_HASH_TEST_HASH_H +