QCollatorSortKey Class
QCollatorSortKey 类可用于加快字符串排序速度。更多内容...
| 头文件: | #include <QCollatorSortKey> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
- 所有成员的列表,包括继承的成员
- QCollatorSortKey 属于“字符串数据类”和“隐式共享类”。
注意:该类中的所有函数均为可重入函数。
QCollatorSortKey 比较
| 类别 | 可比较类型 |
|---|---|
| weak | QCollatorSortKey |
公共函数
| QCollatorSortKey() | |
| QCollatorSortKey(const QCollatorSortKey &other) | |
(since 6.8) | QCollatorSortKey(QCollatorSortKey &&other) |
| ~QCollatorSortKey() | |
| int | compare(const QCollatorSortKey &otherKey) const |
| void | swap(QCollatorSortKey &other) |
| QCollatorSortKey & | operator=(QCollatorSortKey &&other) |
| QCollatorSortKey & | operator=(const QCollatorSortKey &other) |
相关的非成员
(since 6.12) bool | operator!=(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs) |
(since 6.12) bool | operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs) |
(since 6.12) bool | operator<=(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs) |
(since 6.12) bool | operator==(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs) |
(since 6.12) bool | operator>(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs) |
(since 6.12) bool | operator>=(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs) |
详细说明
QCollatorSortKey 类总是由QCollator::sortKey() 创建,用于快速字符串排序,例如在对大量字符串进行排序时。
另请参阅 QCollator 、QCollator::sortKey() 和compare()。
成员函数文档
[delete] QCollatorSortKey::QCollatorSortKey()
默认构造一个QCollatorSortKey 实例。该函数已被删除。
QCollatorSortKey::QCollatorSortKey(const QCollatorSortKey &other)
创建other 排序键的副本。
[constexpr noexcept default, since 6.8] QCollatorSortKey::QCollatorSortKey(QCollatorSortKey &&other)
从 `other` 创建一个新的 `QCollatorSortKey` 对象。
注意: 被移动的对象 other 将处于部分初始化状态,在此状态下,唯一有效的操作是销毁和赋值。
该函数于 Qt 6.8 中引入。
[noexcept] QCollatorSortKey::~QCollatorSortKey()
删除排序键。
[noexcept] int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
将该键与otherKey 进行比较,后者必须是由与该键相同的QCollator 的 sortKey() 方法生成的。比较操作将按照该QCollator 的排序规则进行。
如果该键在排序时位于otherKey 之前,则返回负值;如果两个键相等,则返回 0;如果该键在排序时位于otherKey 之后,则返回正值。
另请参阅 operator==()、operator!=()、operator<()、operator<=()、operator>() 以及operator>=()。
[noexcept] void QCollatorSortKey::swap(QCollatorSortKey &other)
将此排序键与other 互换。此操作速度极快,且绝不会失败。
[noexcept] QCollatorSortKey &QCollatorSortKey::operator=(QCollatorSortKey &&other)
将other 通过移动赋值操作赋值给此QCollatorSortKey 实例。
注意: 被移动的源对象 other 将处于一种部分构成的状态,在此状态下,唯一有效的操作是销毁和赋值。
QCollatorSortKey &QCollatorSortKey::operator=(const QCollatorSortKey &other)
将other 分配给此排序键。
相关的非成员
[noexcept, since 6.12] bool operator!=(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
[noexcept, since 6.12] bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
[noexcept, since 6.12] bool operator<=(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
[noexcept, since 6.12] bool operator==(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
[noexcept, since 6.12] bool operator>(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
[noexcept, since 6.12] bool operator>=(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
这两个键必须是由同一个QCollator 的sortKey()方法生成的。根据生成它们的QCollator ,比较lhs 和rhs 。
这些函数在 Qt 6.12 中引入。
另请参阅 QCollatorSortKey::compare()。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.