坚持一个线索到一个文件 - ç [英] Persisting a trie to a file - C
问题描述
我有一个特里
里面我是用做一些字符串处理。我有一个简单的编译器从一些数据产生特里
。一旦生成,我的特里
将无法在运行时更改。
I have a trie
which I am using to do some string processing. I have a simple compiler which generates trie
from some data. Once generated, my trie
won't change at run time.
我要寻找一种方法,我可以坚持在一个文件线索并有效地加载它。我看过 sqllite
来了解它们是如何坚持 B树
,但它们的文件格式看起来有点先进的,我也可以并不需要所有这些。
I am looking for an approach where I can persist the trie in a file and load it effectively. I have looked at sqllite
to understand how they are persisting b-tree
but their file format looks bit advanced and I may not need all of those.
这将会是有益的,如果有人能提供一些思路坚持和阅读特里
。我使用C语言进行编程。
It'd be helpful if someone can provide some ideas to persist and read the trie
. I am programming using C.
推荐答案
我做了一些研究,发现下面的小宝石在线:
I did a some research and found the following little gems online:
与序列化和反序列化的一个工作线索。它原本是为在Python写的使用(有一个相应的 triemodule.c
它绑到Python),但它是纯C;你可以挖掘它的想法或者你想使用它。
A working trie with serialization and deserialization. It was originally written for use in Python (there's a corresponding triemodule.c
for tying it to Python), but it's pure C; you could mine it for ideas or use it as you wish.
更新
它出现的链接不再工作。我会继续原稿最多,但这里是自由之路机链接:
It appears the links are no longer working. I'll keep the originals up, but here are the links in the wayback machine:
这篇关于坚持一个线索到一个文件 - ç的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!