T
Tom Anderson
Hi all,
I want to store some things, each filed under a string key. I then want to
look those things up with other strings, finding the thing whose key is
the longest available prefix of the lookup string.
So, if i store:
/products -> foo
/products/fruit -> bar
Then lookups go like:
/products/furniture/chairs -> foo
/products/fruit/bananas -> bar
Am i right in thinking that there's nothing in the standard library that
does this? I'm writing something that uses the NavigableMap methods on
TreeMap to do it, but it's a bit grim, and not guaranteed to be as
efficient as it could be.
Am i further right in thinking that there's nothing in Apache's Commons
Collections or Google's Guava Collections that does this?
Is there any reasonable open-source library that does?
If i write this myself, is there a data structure better than a Patricia
tree for it?
Cheers,
tom
I want to store some things, each filed under a string key. I then want to
look those things up with other strings, finding the thing whose key is
the longest available prefix of the lookup string.
So, if i store:
/products -> foo
/products/fruit -> bar
Then lookups go like:
/products/furniture/chairs -> foo
/products/fruit/bananas -> bar
Am i right in thinking that there's nothing in the standard library that
does this? I'm writing something that uses the NavigableMap methods on
TreeMap to do it, but it's a bit grim, and not guaranteed to be as
efficient as it could be.
Am i further right in thinking that there's nothing in Apache's Commons
Collections or Google's Guava Collections that does this?
Is there any reasonable open-source library that does?
If i write this myself, is there a data structure better than a Patricia
tree for it?
Cheers,
tom