template<typename Key, typename Val, typename Hash, typename KeyEqual>
class QHash< Key, Val, Hash, KeyEqual >::const_iterator
The QHash::const_iterator class provides an STL style const iterator for QHash. QHash features both STL style iterators and Java style iterators.
QHash::const_iterator allows you to iterate over a QHash. If you want to modify the QHash as you iterate over it use QHash::iterator instead.
After construction you must initialize the iterator using a method like QHash::constBegin(), QHash::constEnd(), or QHash::find() before you can start iterating. The following is an example which prints all of the (key, value) pairs in the container.
for (auto iter = map.constBegin(); iter != map.constEnd(); ++iter) {
cout << iter.key() <<
": " << iter.
value() << endl;
}
Unlike QMap which orders its items by key, QHash stores its items in an arbitrary order.
- See also
- QHash::iterator
template<typename Key , typename Val , typename Hash , typename KeyEqual >
const_iterator QHash< Key, Val, Hash, KeyEqual >::const_iterator::operator+ |
( |
size_type |
n | ) |
const |
|
inline |
Returns an iterator to the item at n positions forward from this iterator. If n is negative, the iterator goes backward.
This operation can be slow for large values of n.
- See also
- operator-()
template<typename Key , typename Val , typename Hash , typename KeyEqual >
const_iterator & QHash< Key, Val, Hash, KeyEqual >::const_iterator::operator++ |
( |
| ) |
|
|
inline |
The prefix ++ operator (++i
) advances the iterator to the next item in the hash and returns an iterator to the new current item.
Calling this method on QHash::end() leads to undefined behavior.
template<typename Key , typename Val , typename Hash , typename KeyEqual >
const_iterator QHash< Key, Val, Hash, KeyEqual >::const_iterator::operator- |
( |
size_type |
n | ) |
const |
|
inline |
Returns an iterator to the item at n positions backward from this iterator. If n is negative the iterator goes forward.
This operation can be slow for large values of n.
- See also
- operator+()