介绍
Qt提供的一个单值的数学集合的快速查找容器,使用方式与QList相同,但其内元素不会有重复。详细说明见 官方文档
注意,此容器实现方式是基于哈希表,而不是红黑树,若使用自定义类必须提供对应的hash函数:
QSet‘s value data type must be an assignable data type. You cannot, for example, store a QWidget as a value; instead, store a QWidget *. In addition, the type must provide
operator==(), and there must also be a global qHash() function that returns a hash value for an argument of the key’s type. See the QHash documentation

本文介绍了Qt中的QSet容器,它是一个不允许重复元素的快速查找集合,基于哈希表实现。使用自定义类型时,需要提供对应的hash函数和重载'=='操作符。文中给出了简单的使用示例,并提及Qt内置类如QString已实现相关需求。
最低0.47元/天 解锁文章
5582

被折叠的 条评论
为什么被折叠?



