Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Longest common prefix behaviour seems invalid #43

Open
liona24 opened this issue Aug 27, 2024 · 0 comments
Open

Longest common prefix behaviour seems invalid #43

liona24 opened this issue Aug 27, 2024 · 0 comments

Comments

@liona24
Copy link

liona24 commented Aug 27, 2024

Hey,

currently the longest_common_prefix function behaves like this:

let mut trie = qp_trie::Trie::new();
let a = vec![1];
let b = vec![1, 2, 3];
trie.insert(a.as_slice(), 1111);
trie.insert(b.as_slice(), 2222);
assert_eq!(
    trie.longest_common_prefix([1u8, 2u8].as_slice()),
    &[1u8, 2u8]
);

But I would I expect it to return [1u8] since this is the only valid prefix with key in the map ([1, 2] is not a valid prefix as it has no value in the map).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant