-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Add Trie
data structure
#1871
Add Trie
data structure
#1871
Conversation
🦋 Changeset detectedLatest commit: fe31668 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A few questions:
|
Most of the main usecases of Tries have to do with strings, for example for full-text search, autocomplete (predictive text), spell checking. Some of these usecases take advantage of prefix search ( Prefix search is also the main feature that makes a Trie more suited than an hash table for certain usecases. That being said, I think that technically there should be no issue in making the key also a generic
Trie are better suited for autocomplete, text search, spell checking, and generally when working with string and prefixes:
|
Thanks, would such |
@mikearnaldi I completed the API implementation. I am now going to update and expand the docs and then the PR is ready. |
@fubhy @mikearnaldi I added all the documentation and completed the implementation. The PR is ready for a complete review and merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'll have a think about what we can do to make the codegen
step for the barrel files a bit ... less easily skippable.
EDIT:
@SandroMaglione I fixed the examples. Some were missing imports, others had subtle bugs. Please double check!
I'll also have a think about how we can make that more pleasant for contributors ;-)
@fubhy LGTM as well 👍 |
@SandroMaglione Please also check out 338e1a7 I would propose to simplify this to plain object literlas. That way we also don't have to initialize this internal node representation with a bunch of I think we should also patch this in The absolute performance gain is negligible but in relative terms it's a lot and that makes a difference imho. And since there's no DX downgrade by doing this (imho) we should do it. |
I think this should be part of another PR. I also opened another issue related to |
Oh for sure. That's what I meant :-) |
Type
Description
Added
Trie
data structure.A
Trie
can be used to to efficiently store and locate keys within a set.This PR adds a
Trie
module implemented as a Ternary Search Tree. A Ternary Search Tree is more space-efficient and allows to use an arbitrarystring
as key (instead of a limited alphabet).Questions
Trie
, the new module is technically a Ternary Search Trie (TST). Is the nameTrie
okay?TODO
has
insertMany
removeMany
map
forEach
reduce
isEmpty
filterMap
filter
compact
modify