
On 2025-09-10 07:42, Pavel Vazharov via Boost-users wrote:
HI there,
Is there a generic radix trie container in boost which can be used for longest prefix match? I mean, I couldn't find one in the boost containers libraries but maybe some library uses such a container internally and it's generic enough to be used with types other than strings?
It started when I needed to do longest prefix match for long distance numbers. I came up with the following based upon Aho Corasick algorithm: https://github.com/rburkholder/trade-frame/blob/master/lib/OUCommon/KeyWordM... It could probably be made to be even more generic by replacing the char with a templated token for comparison operations. A use case can be seen in, where the value to lookup is an enum: enum class EMode { view_training, view_validate , train_then_validate, train_then_save, train_save_validate , load_then_validate , train_then_run_live, load_then_run_live , unknown } eMode; ou::KeyWordMatch<config::Choices::EMode> kwmMode( config::Choices::EMode::unknown, 10 ); kwmMode.AddPattern( "view_training_data", config::Choices::EMode::view_training ); kwmMode.AddPattern( "view_validate_data", config::Choices::EMode::view_validate ); kwmMode.AddPattern( "train/validate", config::Choices::EMode::train_then_validate ); choices.eMode = kwmMode.FindMatch( sMode ); above are excerpts from: https://github.com/rburkholder/trade-frame/blob/master/SP500/Config.hpp https://github.com/rburkholder/trade-frame/blob/master/SP500/Config.cpp