1 Star 0 Fork 0

操作系统 / map

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Map for c

Current Map Version 1.0 For C++, there is STL to use, and so we have map to use. But for c, We have to implement ourselves. So I implement a C map, I used rb_tree to implement this. The map sort by the key, and get the value in O(logn).

Usage

I grab rb_tree from linux kernel. Just import map.h, rbtree.h, rbtree.c in you project.

Example


//put the key and value into map
root_t tree = RB_ROOT; 
char *key = "hello";
char *word = "world";
put(&tree, key, word);

//get the value from key
map_t *data = get(&tree, "zhang");
if (data != NULL)
	printf("%s\n", data->val);

//Traversal
map_t *node;
for (node = map_first(&tree); node; node=map_next(&(node->node))) {
	printf("%s\n", node->val);
}

//Free map node
if (data) {
    rb_erase(&data->node, &tree);
	map_free(data);
}

Bug Reporting and Feature Requests

If you find a bug or have an enhancement request, simply file an Issue and send a message (via github messages) to the Committers to the project to let them know that you have filed an Issue.

Contact

tjbroadroad@163.com

空文件

简介

rbtree-map 展开 收起
C 等 2 种语言
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/QUIC/map.git
git@gitee.com:QUIC/map.git
QUIC
map
map
master

搜索帮助