c++ - 如何列出雪松上的所有键(双数组特里)

标签 c++ c trie

我正在使用 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).

但是如何知道lento参数呢?

最佳答案

找到了,plenfromto:

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/

相关文章:

c++ - 相互包含的派生和专用模板类

c - 使用 CURL 测试时,我的 C 程序在接受连接时被卡住

c++ - 对 typedef 用法感到困惑

generics - Scala解构然后重建一个Iterable

c++ - 将 shared_ptr 传递给 OpenGL?

c++ - 访问基类的 protected 构造函数

c++ - 如何修复以前工作的注入(inject)模板友元函数?

c - 如何从 Windows 上的套接字端口获取 PID?

c - 加载函数 trie 段错误

dictionary - 如何在较小的空间内容纳较大的单词词典,同时对准确性的影响最小?