![]() |
CopperSpice API
2.0.0
|
The QMutableMultiHashIterator class provides a Java style non-const iterator for QMultiHash. More...
Public Methods | |
QMutableMultiHashIterator (QMultiHash< Key, Val, Hash, KeyEqual > &hash) | |
~QMutableMultiHashIterator () = default | |
bool | findNext (const Val &value) |
bool | findPrevious (const Val &value) |
bool | hasNext () const |
bool | hasPrevious () const |
const Key & | key () const |
Item | next () |
QMutableMultiHashIterator & | operator= (QMultiHash< Key, Val, Hash, KeyEqual > &hash) |
Item | peekNext () const |
Item | peekPrevious () const |
Item | previous () |
void | remove () |
void | setValue (const Val &value) |
void | toBack () |
void | toFront () |
Val & | value () |
const Val & | value () const |
The QMutableMultiHashIterator class provides a Java style non-const iterator for QMultiHash. QMultiHash has both Java style iterators and STL style iterators.
QMultiHashIterator allows you to iterate over a QMultiHash. If you want to modify the hash as you iterate over it, use QMutableMultiHashIterator instead.
After construction the iterator is located at the very beginning of the hash, before the first item. The following code shows how to iterate over all the elements sequentially.
The next() method returns the next item in the hash and advances the iterator. The key() and value() methods return the key and value of the last item which 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.
Here is how to iterate over the elements in reverse order:
If you want to find all occurrences of a particular value use findNext() or findPrevious():
If you want to remove items as you iterate over the hash, use remove(). If you want to modify the value of an item, use setValue().
The example above removes all (key, value) pairs where the key and the value are the same.
|
inline |
Constructs an iterator for traversing hash. The iterator is set to the beginning of the list before the first item.
|
default |
Destroys the iterator.
|
inline |
Searches for value starting from the current iterator position and moving forward. Returns true if a (key, value) pair with the specified value is found, otherwise it returns false. If value is found the iterator is positioned just after the matching item, otherwise the iterator is positioned at the end of the container.
|
inline |
Searches for value starting from the current iterator position and moving backward. Returns true if a (key, value) pair with the specified value is found, otherwise it returns false. If value was found the iterator is positioned just before the matching item. Otherwise the iterator is positioned at the beginning of the container.
|
inline |
Returns true if there is at least one item after the iterator, otherwise returns false.
|
inline |
Returns true if there is at least one item before the iterator, otherwise returns false.
|
inline |
Returns a reference for the key of the last item that was jumped over using one of the traversal methods next(), previous(), findNext(), findPrevious().
|
inline |
Returns the next item and advances the iterator by one position. Call key() on the return value to obtain the key or call value() to obtain the value.
Calling this method on an iterator located at the end of the container causes undefined behavior.
|
inline |
|
inline |
Returns the next item without moving the iterator. Call key() on the return value to obtain the key or call value() to obtain the value.
Calling this method on an iterator located at the end of the container causes undefined behavior.
|
inline |
Returns the previous item without moving the iterator. Call key() on the return value to obtain the key or call value() to obtain the value.
Calling this method on an iterator located at the beginning of the container causes undefined behavior.
|
inline |
Returns the previous item and moves the iterator back by one position. Call key() on the return value to obtain the key or call value() to obtain the value.
Calling this method on an iterator located at the beginning of the container causes undefined behavior.
|
inline |
Removes the last item that was jumped over using one of the traversal methods. The traversal methods are next(), previous(), findNext(), and findPrevious().
|
inline |
|
inline |
Moves the iterator to the end of the container after the last item.
|
inline |
|
inline |
Returns a non-const reference to the value of the last item that was jumped over using one of the traversal methods.
|
inline |
Returns a reference for the value of the last item that was jumped over using one of the traversal methods next(), previous(), findNext(), findPrevious().