开发者

Efficient data structure for searching numbers and strings

开发者 https://www.devze.com 2023-01-21 04:44 出处:网络
I have a scenario where in strings and numbers are combined into a single entity. I need to search based on the string or the number. How do I go about with the data structure for this?

I have a scenario where in strings and numbers are combined into a single entity. I need to search based on the string or the number. How do I go about with the data structure for this? I thought of coming up with a hashing for strings and search tree approach for numbers. Can you please comment on m开发者_运维技巧y choice and also suggest better structures if any?

Thanks!


Use two std::maps, one from std::string to a pointer and the other from number to a pointer. The pointers go to your "single entity". See how far you can scale this (millions of entries...) before trying to optimize further.

0

精彩评论

暂无评论...
验证码 换一张
取 消