fix
This commit is contained in:
parent
5ad5bdd29c
commit
feae2f1830
|
@ -168,17 +168,25 @@ class tail_vector {
|
|||
|
||||
// Returns true if TAIL[tpos..epos] is a prefix of key, where epos is the end position of the tail.
|
||||
inline bool prefix_match(std::string_view key, std::uint64_t tpos) const {
|
||||
assert(key.size() != 0);
|
||||
if (tpos == 0) {
|
||||
// suffix is empty, returns true always.
|
||||
return true;
|
||||
}
|
||||
if (key.size() == 0) {
|
||||
// When key is empty, returns true iff suffix is empty.
|
||||
return false;
|
||||
}
|
||||
|
||||
std::uint64_t kpos = 0;
|
||||
if (bin_mode()) {
|
||||
do {
|
||||
if (m_terms[tpos]) {
|
||||
return true;
|
||||
}
|
||||
if (key[kpos] != m_chars[tpos]) {
|
||||
return false;
|
||||
}
|
||||
kpos += 1;
|
||||
if (m_terms[tpos]) {
|
||||
return true;
|
||||
}
|
||||
tpos += 1;
|
||||
} while (kpos < key.size());
|
||||
return true;
|
||||
|
|
|
@ -167,7 +167,7 @@ TEST_CASE("Test " TRIE_NAME " (tiny)") {
|
|||
test_basic_operations(trie, keys, others);
|
||||
|
||||
{
|
||||
auto itr = trie.make_prefix_iterator("MacBook_Pro");
|
||||
auto itr = trie.make_prefix_iterator("MacBook_Pro_13inch");
|
||||
std::vector<std::string> expected = {"Mac", "MacBook", "MacBook_Pro"};
|
||||
for (const auto& exp : expected) {
|
||||
REQUIRE(itr.next());
|
||||
|
|
Loading…
Reference in a new issue