QKeyValueIterator 類

template <typename Key, typename T, typename Iterator, typename Traits = QtPrivate::QDefaultKeyValues<Key, T, 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 )
迭代器 base () const
std::pair<Key, T> operator* () const
QKeyValueIterator<Key, T, Iterator, Traits> & operator++ ()
QKeyValueIterator<Key, T, Iterator, Traits> operator++ (int)
QKeyValueIterator<Key, T, Iterator, Traits> & operator-- ()
QKeyValueIterator<Key, T, Iterator, Traits> operator-- (int)
QKeyValueIterator<Key, T, Iterator, Traits>::pointer operator-> () const
bool operator!= (QKeyValueIterator<Key, T, Iterator, Traits> lhs , QKeyValueIterator<Key, T, Iterator, Traits> rhs )
bool operator== (QKeyValueIterator<Key, T, Iterator, Traits> lhs , QKeyValueIterator<Key, T, Iterator, Traits> 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 ()

構造默認 QKeyValueIterator。

[explicit constexpr noexcept(...)] QKeyValueIterator:: QKeyValueIterator ( Iterator o )

Constructs a QKeyValueIterator on top of o .

注意: This function is noexcept when std::is_nothrow_move_constructible<Iterator>::value is true .

Iterator QKeyValueIterator:: base () const

Returns the underlying iterator this QKeyValueIterator is based on.

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

成對返迴當前條目。

QKeyValueIterator < Key , T , Iterator , Traits > &QKeyValueIterator:: 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 , Traits > QKeyValueIterator:: operator++ ( int )

The postfix ++ 運算符 ( 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 , Traits > &QKeyValueIterator:: operator-- ()

The prefix c{–} 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 , Traits > QKeyValueIterator:: operator-- ( int )

The postfix c{–} 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.

這是重載函數。

QKeyValueIterator < Key , T , Iterator , Traits > ::pointer QKeyValueIterator:: operator-> () const

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

另請參閱 operator* ().

相關非成員

[noexcept] bool operator!= ( QKeyValueIterator < Key , T , Iterator , Traits > lhs , QKeyValueIterator < Key , T , Iterator , Traits > rhs )

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

另請參閱 operator== ().

[noexcept] bool operator== ( QKeyValueIterator < Key , T , Iterator , Traits > lhs , QKeyValueIterator < Key , T , Iterator , Traits > rhs )

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

另請參閱 operator!= ().