QKeyValueIterator Class
template <typename Key, typename T, typename Iterator> class QKeyValueIterator关联容器中键/值对的迭代器。更多
头文件: | #include <QKeyValueIterator> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
公共函数
QKeyValueIterator() | |
QKeyValueIterator(Iterator o) | |
Iterator | base() const |
std::pair<Key, T> | operator*() const |
QKeyValueIterator<Key, T, Iterator> & | operator++() |
QKeyValueIterator<Key, T, Iterator> | operator++(int) |
QKeyValueIterator<Key, T, Iterator> & | operator--() |
QKeyValueIterator<Key, T, Iterator> | operator--(int) |
QKeyValueIterator<Key, T, Iterator>::pointer | operator->() const |
相关非成员
bool | operator!=(QKeyValueIterator<Key, T, Iterator> lhs, QKeyValueIterator<Key, T, Iterator> rhs) |
bool | operator==(QKeyValueIterator<Key, T, Iterator> lhs, QKeyValueIterator<Key, T, Iterator> rhs) |
详细描述
QKeyValueIterator 类提供了一个 STL 风格的迭代器,用于从关联容器(如QHash 和QMap )返回键/值对。它支持与 STL 关联容器相同的 API,即在遍历容器时获取键/值对。
这将使QMap 、QHash 和朋友们与 STL 风格算法之间有更好的互操作性。
警告: 隐式共享容器上的迭代器的工作方式与 STL-迭代器并不完全相同。当容器上的迭代器处于活动状态时,应避免复制该容器。更多信息,请阅读隐式共享迭代器问题。
成员函数文档
QKeyValueIterator::QKeyValueIterator()
构造默认 QKeyValueIterator。
[explicit constexpr noexcept(...)]
QKeyValueIterator::QKeyValueIterator(Iterator o)
在o 的基础上构造一个 QKeyValueIterator。
注: 当std::is_nothrow_move_constructible<Iterator>::value
为true
时,此函数为 noexcept。
Iterator QKeyValueIterator::base() const
返回QKeyValueIterator 基于的底层迭代器。
std::pair<Key, T> QKeyValueIterator::operator*() const
将当前条目作为一对返回。
QKeyValueIterator<Key, T, Iterator> &QKeyValueIterator::operator++()
前缀++
操作符 (++i
) 将迭代器前进到容器中的下一项,并返回迭代器。
注意: 将迭代器前进到其容器的 end() 之后是未定义的行为。
另请参阅 operator--() 。
QKeyValueIterator<Key, T, Iterator> QKeyValueIterator::operator++(int)
这是一个重载函数。
后缀++
运算符 (i++
) 将迭代器前进到容器中的下一项,并返回迭代器的前一个值。
注意: 将迭代器前进到其容器的 end() 之后会导致未定义的行为。
QKeyValueIterator<Key, T, Iterator> &QKeyValueIterator::operator--()
前缀 c{-} 操作符 (--i
) 将迭代器后退到容器中的前一项,并返回迭代器。
注意: 将迭代器后退到容器的 begin() 之前会导致未定义的行为。
另请参阅 operator++().
QKeyValueIterator<Key, T, Iterator> QKeyValueIterator::operator--(int)
这是一个重载函数。
后缀 c{-} 操作符 (i--
) 将迭代器后退到容器中的前一项,并返回迭代器的前一个值。
注意: 将迭代器后退到容器的 begin() 之前会导致未定义的行为。
QKeyValueIterator<Key, T, Iterator>::pointer QKeyValueIterator::operator->() const
以指针形式返回当前条目。
另请参阅 operator*()。
相关非成员
[noexcept]
bool operator!=(QKeyValueIterator<Key, T, Iterator> lhs, QKeyValueIterator<Key, T, Iterator> rhs)
如果rhs 指向与lhs 不同的项目,则返回true
,否则返回false
。
另请参阅 operator==() 。
[noexcept]
bool operator==(QKeyValueIterator<Key, T, Iterator> lhs, QKeyValueIterator<Key, T, Iterator> rhs)
如果rhs 指向与lhs 相同的项目,则返回true
,否则返回false
。
另请参阅 operator!=() 。
© 2025 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.