c++ - 如何将多个QHash合并为一个QHash

标签 c++ qt hash

我有两个 QHash es,我想把它们合二为一 QHash .两个散列属于同一类型(即,都是 QHash<QString, qint32> )。我如何有效地(和/或类似 Qt)做到这一点?

类似于:

hash1 << hash2;

hash1.append( hash2 );

或类似的,会很棒。如果那不可能,我将循环遍历较小的散列并将其插入第一个。

最佳答案

我想您正在寻找 QHash::unite() .

如链接文档中所述:

Inserts all the items in the other hash into this hash. If a key is common to both hashes, the resulting hash will contain the key multiple times.

关于c++ - 如何将多个QHash合并为一个QHash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24375445/

相关文章:

c++ - 如何在 C++ 中定义新的数字系统

php - 密码哈希应该以二进制还是十六进制数存储?

c - 二进制序列检测器

c++ - 初始化结构指针的值

c++ - TCP 连接到服务器很慢?

c++ - 将 std::string 转换为 wchar_t* 的类型定义

c++ - Qt 造物主 : “XYZ does not name a type”

c++ - 在QT5中,如何在子菜单项的点击事件上打开新窗口?

LGPL 下的 Qt : How to distribute changes to Qt source code?

node.js - 在 Nodejs 中从 Cakephp 实现 Security::Hash