The QMutableMapIterator constructor takes a QMap as argument. After construction, the iterator is located at the very beginning of the map (before the first item). Here's how to iterate over all the elements sequentially:

The next() function returns the next item in the map and advances the iterator. The key() and value() functions return the key and value of the last item that was jumped over.

Unlike STL-style iterators, Java-style iterators point between items rather than directly at items. The first call to next() advances the iterator to the position between the first and second item, and returns the first item; the second call to next() advances the iterator to the position between the second and third item; and so on.

The example removes all (key, value) pairs where the key and the value are the same.

Only one mutable iterator can be active on a given map at any time. Furthermore, no changes should be done directly to the map while the iterator is active (as opposed to through the iterator), since this could invalidate the iterator and lead to undefined behavior.