tiborschneider / prefix-trie

Apache License 2.0
20 stars 4 forks source link

support search_covering #4

Closed stevenjoezhang closed 4 months ago

stevenjoezhang commented 4 months ago

Thank you for creating such a convenient and useful Rust library! I am doing research about BGP routing, and previously, I implemented an algorithm using the py-radix library in Python, but it had serious efficiency issues (the program needed to process millions of prefixes and ASN data and perform complex calculations), so I rewrote it in Rust. Most of the algorithms could find equivalent replacements in prefix-trie, which is great. However, a method called search_covering from the py-radix library does not have a corresponding implementation in prefix-trie, so I would like to add it. This method would return a vec of all nodes that cover a given prefix.

tiborschneider commented 4 months ago

Thanks for the PR. It looks good. However, I have a couple of suggestions:

In other words, let's add the following functions (and names that match with rust's naming convention of maps):

Do you have time to implement those changes? If not, I can also take care of them.

tiborschneider commented 4 months ago

I will close this PR now, as I implemented it myself in #5 with my comments above.

Small remark: There was a bug in your implementation that the root node would never be returned.

stevenjoezhang commented 4 months ago

Thanks, your implementation is more elegant! And I must admit that I am still a Rust newbie 😂