API参考
载入中...
搜索中...
未找到
bsl_hash.h
1/*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
20
21#ifndef BSL_HASH_H
22#define BSL_HASH_H
23
24#include "hitls_build.h"
25#ifdef HITLS_BSL_HASH
26
27#include <stdlib.h>
28#include <stdbool.h>
29#include <stdint.h>
30#include "bsl_hash_list.h"
31#include "list_base.h"
32#ifdef __cplusplus
33extern "C" {
34#endif
35
40typedef struct BSL_HASH_Info BSL_HASH_Hash;
41
46typedef struct BSL_HASH_TagNode *BSL_HASH_Iterator;
47
53typedef uint32_t (*BSL_HASH_CodeCalcFunc)(uintptr_t key);
54
64typedef bool (*BSL_HASH_MatchFunc)(uintptr_t key1, uintptr_t key2);
65
82typedef int32_t (*BSL_HASH_UpdateNodeFunc)(BSL_HASH_Hash *hash, BSL_HASH_Iterator node,
83 uintptr_t value, uint32_t valueSize);
84
100uint32_t BSL_HASH_CodeCalc(void *key, uint32_t keySize);
101
115uint32_t BSL_HASH_CodeCalcInt(uintptr_t key);
116
131uint32_t BSL_HASH_CodeCalcStr(uintptr_t key);
132
147bool BSL_HASH_MatchInt(uintptr_t key1, uintptr_t key2);
148
164bool BSL_HASH_MatchStr(uintptr_t key1, uintptr_t key2);
165
196BSL_HASH_Hash *BSL_HASH_Create(uint32_t bktSize, BSL_HASH_CodeCalcFunc hashFunc, BSL_HASH_MatchFunc matchFunc,
197 ListDupFreeFuncPair *keyFunc, ListDupFreeFuncPair *valueFunc);
198
199
219int32_t BSL_HASH_Insert(BSL_HASH_Hash *hash, uintptr_t key, uint32_t keySize, uintptr_t value, uint32_t valueSize);
220
242int32_t BSL_HASH_Put(BSL_HASH_Hash *hash, uintptr_t key, uint32_t keySize, uintptr_t value, uint32_t valueSize,
243 BSL_HASH_UpdateNodeFunc updateNodeFunc);
244
257int32_t BSL_HASH_At(const BSL_HASH_Hash *hash, uintptr_t key, uintptr_t *value);
258
270BSL_HASH_Iterator BSL_HASH_Find(const BSL_HASH_Hash *hash, uintptr_t key);
271
284bool BSL_HASH_Empty(const BSL_HASH_Hash *hash);
285
295uint32_t BSL_HASH_Size(const BSL_HASH_Hash *hash);
296
310BSL_HASH_Iterator BSL_HASH_Erase(BSL_HASH_Hash *hash, uintptr_t key);
311
322void BSL_HASH_Clear(BSL_HASH_Hash *hash);
323
334void BSL_HASH_Destroy(BSL_HASH_Hash *hash);
335
345BSL_HASH_Iterator BSL_HASH_IterBegin(const BSL_HASH_Hash *hash);
346
357BSL_HASH_Iterator BSL_HASH_IterEnd(const BSL_HASH_Hash *hash);
358
369BSL_HASH_Iterator BSL_HASH_IterNext(const BSL_HASH_Hash *hash, BSL_HASH_Iterator it);
370
386uintptr_t BSL_HASH_HashIterKey(const BSL_HASH_Hash *hash, BSL_HASH_Iterator it);
387
403uintptr_t BSL_HASH_IterValue(const BSL_HASH_Hash *hash, BSL_HASH_Iterator it);
404
405struct BSL_HASH_Info {
406 ListDupFreeFuncPair keyFunc;
407 ListDupFreeFuncPair valueFunc;
408 BSL_HASH_MatchFunc matchFunc;
409 BSL_HASH_CodeCalcFunc hashFunc;
410 uint32_t initialSize;
411 uint32_t nextLevelSize;
412 uint32_t nextSplit;
413 uint32_t bucketSize;
414 uint32_t hashCount;
415 RawList *listArray;
416};
417
418#ifdef __cplusplus
419}
420#endif
421
422#endif /* HITLS_BSL_HASH */
423
424#endif // BSL_HASH_H