From your requirement, it seems that you really do not need a map data structure, but it can be installed or something very simple.
I think a structure like this std :: map might help you. Boost :: anyone will be able to store anything, but the caveat is that you need to know that the type of the value should read it.
The key is a string, and therefore it is also a regular expression expression. With this structure, you will need two algorithms:
std::map<std::string, boost::any> _map; if (_map.find(key) != _map.end) { // exact match } else { // Have to do sequential regex (use boost::regex) matching }
Since evaluating regular expressions at runtime can be expensive, you can use std :: vector> so that for regular expression patterns you save the compiled regular expression in one of the fields.
Perhaps it would be useful to give more information about what you want to achieve, as this can help solve the correct data structure and search algorithm.
Ketan
source share