使用数据结构代替 hash_map
我想创建一个包含三个宽字符数组的数组,其中一个是键。
“LPWCH,LPWCH,LPWCH”无法使用大于/小于符号,因为它认为它是一个标签
Hash_map 只允许我使用一对。 wKey 和与其关联的元素。是否有其他数据结构可以让我使用它?
该集合将由不同的线程几乎同时更新。这就是为什么我不想使用类或另一个结构来定义剩余的两个宽字符数组的原因。
I want to make an array containing three wide character arrays such that one of them is the key.
"LPWCH,LPWCH,LPWCH" was not able to use the greater than/lesser than symbols since it thinks it is a tag
Hash_map only lets me use a pair. wKey and the element associated with it. Is there another data structure that lets me use this?
This set will be updated by different threads almost simultaneously. And thats the reason why I don't want to use a class or another struct to define the remaining two wide character arrays.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
LPWCH
作为键,使用std::pair
作为元素。You can use
LPWCH
as a key andstd::pair<LPWCH, LPWCH>
as an element.使用任何 LP-typedef 都不好。您只会比较点,而不是字符串。
LPWCH
只不过是一个WCHAR*
,可以深入到void*
。当您比较两个指针时,您是在比较它们所指向的位置,而不是它们所指向的内容。您需要将另一个比较器附加到您的map/hash_map,或者使用实际的字符串数据类型(如
std::string
、CString
)Using any of LP-typedefs is not good. You would only be comparing the points, and not strings.
LPWCH
is nothing but aWCHAR*
which can be drilled down tovoid*
. When you compare two pointers, you are comparing where they are pointing, and not what they are pointing.You either need to have another comparer attached to your map/hash_map, or use actual string datatype (like
std::string
,CString
)