gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:28:53 24 4
gpt4 key购买 nike

我有两个 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com