Skip to content

Commit 1f09d9a

Browse files
zhangguofuGary.Zhang
andauthored
新增一个通用字典模块,支持任意数据类型的键值对存取,为嵌入式系统专门优化 (#1981)
* upload for dict module * fix compile option redefinition issue --------- Co-authored-by: Gary.Zhang <gary.zhang@cygia.com>
1 parent e6953a0 commit 1f09d9a

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

tools/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ menu "tools packages"
22

33
source "$PKGS_DIR/packages/tools/vector/Kconfig"
44
source "$PKGS_DIR/packages/tools/sorch/Kconfig"
5+
source "$PKGS_DIR/packages/tools/dict/Kconfig"
56
source "$PKGS_DIR/packages/tools/CmBacktrace/Kconfig"
67
source "$PKGS_DIR/packages/tools/MCoreDump/Kconfig"
78
source "$PKGS_DIR/packages/tools/EasyFlash/Kconfig"

tools/dict/Kconfig

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Kconfig for package dict
2+
menuconfig PKG_USING_DICT
3+
bool "dict: a general-purpose dictionary module"
4+
default n
5+
6+
if PKG_USING_DICT
7+
config PKG_DICT_PATH
8+
string
9+
default "/packages/tools/dict"
10+
11+
config DICT_DEFAULT_CAPACITY
12+
int "Default initial capacity"
13+
default 32
14+
range 8 65536
15+
help
16+
Set the default bucket array capacity when creating a dictionary
17+
without specifying a configuration. Recommended values: 16/32/64.
18+
Higher values reduce resize operations but consume more memory.
19+
20+
21+
config DICT_LOAD_FACTOR_X100
22+
int "Load factor (x100)"
23+
default 75
24+
range 50 95
25+
help
26+
Set the resize threshold as a percentage of capacity.
27+
When element count >= capacity * (load_factor/100), the dictionary
28+
automatically expands to prevent excessive hash collisions.
29+
30+
Common values:
31+
- 50: Lower memory usage, more resize operations
32+
- 75: Balanced (default)
33+
- 90: Higher memory usage, fewer resize operations
34+
35+
choice
36+
prompt "Version"
37+
default PKG_USING_DICT_LATEST_VERSION
38+
help
39+
Select the package version
40+
41+
config PKG_USING_DICT_LATEST_VERSION
42+
bool "latest"
43+
44+
endchoice
45+
46+
config PKG_DICT_VER
47+
string
48+
default "latest" if PKG_USING_DICT_LATEST_VERSION
49+
50+
endif
51+
52+

tools/dict/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "dict",
3+
"description": "dict is a general-purpose dictionary module",
4+
"description_zh": "dict 是一个为 RT-Thread 设计的通用字典模块,支持任意数据类型的键值对存取",
5+
"enable": "PKG_USING_DICT",
6+
"keywords": [
7+
"dict", "dictionary", "key-value pairs"
8+
],
9+
"category": "tools",
10+
"author": {
11+
"name": "zhangguofu",
12+
"email": "cleancode@163.com",
13+
"github": "Gary.Zhang"
14+
},
15+
"license": "MIT",
16+
"repository": "https://github.com/zhangguofu/dict",
17+
"icon": "unknown",
18+
"homepage": "https://github.com/zhangguofu/dict#readme",
19+
"doc": "unknown",
20+
"site": [
21+
{
22+
"version": "latest",
23+
"URL": "https://github.com/zhangguofu/dict.git",
24+
"filename": "dict.zip",
25+
"VER_SHA": "main"
26+
}
27+
]
28+
}

tools/sorch/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ if PKG_USING_SORCH
2424
default "latest" if PKG_USING_SORCH_LATEST_VERSION
2525

2626
endif
27+
28+

0 commit comments

Comments
 (0)