我有简单的字符串到整数的映射。我应该如何使用哈希或其他有效算法通过 int 进行查找(请提供一些示例)?
struct string_int_map {
char *str;
int val;
};
struct string_int_map s_to_i_map[] {
{ "test1", 45 },
{ "test2", 95 },
{ "test3", 83 },
{ "test4", 67 },
};
Solr :
对数组进行排序,然后执行二分查找。感谢人们的帮助。
最佳答案
对数组进行排序并执行二分查找。感谢@Weather 提供引用。
关于c - C中int使用哈希查找表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46878048/