/[LeafOK_CVS]/lbbs/include/trie_dict.h
ViewVC logotype

Contents of /lbbs/include/trie_dict.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations)
Tue Nov 4 13:49:50 2025 UTC (4 months, 1 week ago) by sysadm
Branch: MAIN
Changes since 1.6: +7 -15 lines
Content type: text/x-chdr
Update file header information comments

1 /* SPDX-License-Identifier: GPL-3.0-or-later */
2 /*
3 * trie_dict
4 * - trie-tree based dict feature
5 *
6 * Copyright (C) 2004-2025 by Leaflet <leaflet@leafok.com>
7 */
8
9 #ifndef _TRIE_DICT_H_
10 #define _TRIE_DICT_H_
11
12 #include <stdint.h>
13
14 #define TRIE_CHILDREN 256
15 #define TRIE_MAX_KEY_LEN 1023
16 #define TRIE_NODE_PER_POOL 5000
17
18 struct trie_node_t
19 {
20 int64_t values[TRIE_CHILDREN];
21 int8_t flags[TRIE_CHILDREN];
22 struct trie_node_t *p_nodes[TRIE_CHILDREN];
23 };
24 typedef struct trie_node_t TRIE_NODE;
25
26 typedef void (*trie_dict_traverse_cb)(const char *, int64_t);
27
28 extern int trie_dict_init(const char *filename, int node_count_limit);
29 extern void trie_dict_cleanup(void);
30
31 extern int set_trie_dict_shm_readonly(void);
32 extern int detach_trie_dict_shm(void);
33
34 extern TRIE_NODE *trie_dict_create(void);
35 extern void trie_dict_destroy(TRIE_NODE *p_dict);
36
37 extern int trie_dict_set(TRIE_NODE *p_dict, const char *key, int64_t value);
38 extern int trie_dict_get(TRIE_NODE *p_dict, const char *key, int64_t *p_value);
39 extern int trie_dict_del(TRIE_NODE *p_dict, const char *key);
40
41 extern void trie_dict_traverse(TRIE_NODE *p_dict, trie_dict_traverse_cb cb);
42
43 extern int trie_dict_used_nodes(void);
44
45 #endif //_TRIE_DICT_H_

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1