How to iterate on all values () in a QMultiHash
source link: https://www.codesd.com/item/how-to-iterate-on-all-values-in-a-qmultihash.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to iterate on all values () in a QMultiHash
I need to iterate over a QMultiHash
and examine the list of values that correspond to each key. I need to use a mutable iterator so I can delete items from the hash if they meet certain criteria. The documentation does not explain how to access all of the values, just the first one. Additionally, the API only offers a value()
method. How do I get all of the values for a particular key?
This is what I'm trying to do:
QMutableHashIterator<Key, Value*> iter( _myMultiHash );
while( iter.hasNext() )
{
QList<Value*> list = iter.values(); // there is no values() method, only value()
foreach( Value *val, list )
{
// call iter.remove() if one of the values meets the criteria
}
}
May be better use recent documentation: http://doc.qt.io/qt-4.8/qmultihash.html
In particular:
QMultiHash<QString, int>::iterator i = hash1.find("plenty");
while (i != hash1.end() && i.key() == "plenty") {
std::cout << i.value() << std::endl;
++i;
}
Related Articles
how to iterate through all the Employees objects contained in this TreeMap and print it on the screen?
How to iterate on each value stored in a & lt; Long>?
How do I replace all value fields in an XML file with a particular key value using Sed or any other Unix tool?
How to iterate through attribute values All Model Display (Name =)
New function: how to iterate through all form elements before returning true or false
How to iterate through all nonempty lines without using the break or continue statement?
How to iterate in all files in the IntelliJ plugin project?
How do I retrieve all values in a column in mongodb in an ArrayList?
Combinatorics in Scala: How to iterate / enumerate all possibilities to merge several sequences / lists (riffle shuffle permutations)
ansible: how to iterate on all the recorded results?
How to iterate over all subsets of a set of numbers totaling about 0
How to check if all values in an array are equal
How do I select all values from a table with jQuery?
How to iterate through all the parent nodes of the treeview control in c ++?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK