我正在使用 this用于存储大量字符串的库。如何从此库中获取所有 key ?
只有一种方法可以获取所有值,dump
函数 line 228
:
union { int i; value_type x; } b;
size_t num = 0, from = 0, p = 0;
char key[256] = {0};
for (b.i = begin (from, p); b.i != CEDAR_NO_PATH; b.i = next (from, p)) {
// b.x is the value
// which variable that contains `len` and `to`
// that I should pass to suffix function?
suffix(key, len, to);
}
文档上说要检索 key ,我们必须调用suffix
函数:
void suffix (char* key, const size_t len, size_t to)
Recover a substring key of length = len in a trie that reaches node to. key must be allocated with enough memory by a user (to store a terminal character, len + 1 bytes are needed).
但是如何知道len
和to
参数呢?
最佳答案
找到了,p
是len
,from
是to
:
char key[256] = {0};
for (b.i = begin(from, p); b.i != CEDAR_NO_PATH; b.i = next(from, p)) {
// b.x is the value
suffix(key, p, from); // key now should hold the key
}
关于c++ - 如何列出雪松上的所有键(双数组特里),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28553119/