chokkan/dastrie — Issue #1: An infinite loop
Author: chokkan
Created: 2012-02-03 07:24:12+00:00
State: open

Posted by a user. This is how to reproduce it:

typedef dastrie::builder builder_type;
typedef dastrie::trie trie_type;
typedef builder_type::record_type record_type;

// Records sorted by dictionary order of keys.
record_type records[] = {
{"12", 12}, {"123", 123},
};

builder_type builder;
try {
// Build a double-array trie from the records.

builder.build(records, records + sizeof(records)/sizeof(records[0]));

} catch (const builder_type::exception& e) {
// Abort if something went wrong...
std::cerr << "ERROR: " << e.what() << std::endl;

}

trie_type trie;
trie.assign(builder.doublearray(), builder.tail(), builder.table());

trie_type::prefix_cursor pfx = trie.prefix("123876");
while (pfx.next()) {
std::cout
<< pfx.query.substr(0, pfx.length) << " "
<< pfx.value << std::endl;
}