gpt4 book ai didi

c++ - QMap::insertMulti 还是 QMultiMap?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:15:07 31 4
gpt4 key购买 nike

我应该在 QMap::insertMulti 和 QMultiMap 之间使用什么来处理:

2 -> abc
2 -> 定义
3 -> ghi
3 -> jkl

输入 2 个解决方案有什么区别?

最佳答案

阅读 Container Classes :

QMap<Key, T>
This provides a dictionary (associative array) that maps keys of type Key to values of type T. Normally each key is associated with a single value. QMap stores its data in Key order; if order doesn't matter QHash is a faster alternative.

QMultiMap<Key, T>
This is a convenience subclass of QMap that provides a nice interface for multi-valued maps, i.e. maps where one key can be associated with multiple values.

看起来两者都能胜任。在本文档中还有 Algorithmic Complexity您可以在其中看到两个类具有相同复杂性的部分。

我会选择 QMultiMap 只是为了更好地记录我将使用同一个键保存多个值这一事实。

关于c++ - QMap::insertMulti 还是 QMultiMap?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4624791/

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