[英]Are there faster hash functions for unordered_map/set in C++?
[英]C++: Extend already created C struct with custom hash and equal functions to be usable in unordered_map
我有两个项目,一个写在 C 中,另一个写在 C++ 中。 我需要在我的 C++ 程序中的 unordered_map 中使用 C 结构。 如何通过 hash 扩展结构并比较 function 以便我不必总是将这些函数传递给 unordered_map?
在结构外部定义==
运算符(这是允许的)并在 C++ 文件中为您的结构专门std::hash
。 请参阅 cppreference 中的示例: https://en.cppreference.com/w/cpp/utility/hash
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.