QKeyValueIterator 类

template <typename Key, typename T, typename Iterator> class QKeyValueIterator

迭代关联容器的键/值对。 更多...

头: #include <QKeyValueIterator>
CMake: find_package(Qt6 COMPONENTS Core REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 5.10

公共函数

  QKeyValueIterator (Iterator o )
  QKeyValueIterator ()
迭代器 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::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 )

详细描述

The QKeyValueIterator class provides an STL-style iterator for returning key/value pairs from associative containers like QHash and QMap . It supports the same API as the STL associative containers, i.e. getting a key/value pair when iterating through the container.

This will allow for better interoperability between QMap , QHash and friends and STL-style algorithms.

警告: Iterators on implicitly shared containers do not work exactly like STL-iterators. You should avoid copying a container while iterators are active on that container. For more information, read 隐式共享迭代器问题 .

成员函数文档编制

QKeyValueIterator:: QKeyValueIterator ( Iterator o )

Constructs a QKeyValueIterator on top of o .

QKeyValueIterator:: QKeyValueIterator ()

构造默认 QKeyValueIterator。

迭代器 QKeyValueIterator:: base () const

Returns the underlying iterator this QKeyValueIterator is based on.

std::pair < Key , T > QKeyValueIterator:: operator* () const

成对返回当前条目。

QKeyValueIterator < Key , T , Iterator > &QKeyValueIterator:: operator++ ()

The prefix ++ operator ( ++i ) advances the iterator to the next item in the container and returns the iterator.

注意: Advancing the iterator past its container's end() constitutes undefined behavior.

另请参阅 operator-- ().

QKeyValueIterator < Key , T , Iterator > QKeyValueIterator:: operator++ ( int )

这是重载函数。

The postfix ++ operator ( i++ ) advances the iterator to the next item in the container and returns the iterator's prior value.

注意: Advancing the iterator past its container's end() constitutes undefined behavior.

QKeyValueIterator < Key , T , Iterator > &QKeyValueIterator:: operator-- ()

The prefix -- operator ( --i ) backs the iterator up to the previous item in the container and returns the iterator.

注意: Backing up an iterator to before its container's begin() constitutes undefined behavior.

另请参阅 operator++ ().

QKeyValueIterator < Key , T , Iterator > QKeyValueIterator:: operator-- ( int )

这是重载函数。

The postfix -- operator ( i-- ) backs the iterator up to the previous item in the container and returns the iterator's prior value.

注意: Backing up an iterator to before its container's begin() constitutes undefined behavior.

[since 5.15] QKeyValueIterator::pointer QKeyValueIterator:: operator-> () const

Returns the current entry as a pointer-like object to the pair.

该函数在 Qt 5.15 引入。

另请参阅 operator* ().

相关非成员

bool operator!= ( QKeyValueIterator < Key , T , Iterator > lhs , QKeyValueIterator < Key , T , Iterator > rhs )

返回 true if rhs points to a different item than lhs otherwise returns false .

另请参阅 operator== ().

bool operator== ( QKeyValueIterator < Key , T , Iterator > lhs , QKeyValueIterator < Key , T , Iterator > rhs )

返回 true if rhs points to the same item as lhs otherwise returns false .

另请参阅 operator!= ().