8

How to iterate on all values ​​() in a QMultiHash

 2 years ago
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.
neoserver,ios ssh client

How to iterate on all values ​​() in a QMultiHash

advertisements

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?

Thanks for taking the time to look at my question. I am using a Tree map to add data into my system private static Map employeeMap = new TreeMap(); I have then created employee objects like so theEmployee = new Employee(randomIDno,fName, sName, gende

How to iterate on each value stored in a & lt; Long>?

I have a function whose parameter is List<Long> l. In the function there is a if statement for which I have to iterate over each value stored in the List<Long> l. I'm trying to do this: public void myFunction(final List<Long> l) { final

How do I replace all value fields in an XML file with a particular key value using Sed or any other Unix tool?

How can I replace all value fields in an XML file having perticular key value using sed or any other command from Unix? Example, I have file.xml with me and I want to change the value to 256m which has key= "-Xmx" <entry key="-Xmx"

How to iterate through attribute values ​​All Model Display (Name =)

I found that code of @RichTebb is great and it returns the Model attribute DisplayName. But how to iterate through the all Model Display(Name=) attribute values then? Thanks for ANY clue! @RichTebb code public static class HelperReflectionExtensions

New function: how to iterate through all form elements before returning true or false

I have a new function that I will be calling when the submit button is pressed for the form. I'm trying to use this validation, not a plug-in, for experience. How would I iterate through all the forms, determine if they're all valid, before exiting o

How to iterate through all nonempty lines without using the break or continue statement?

I want to get data from Excel file. I'm using while loop, iterator and hasNext() method to go by all rows. My problem: sometimes after rows with data there are empty rows (propably with cell type string and value "" or null), which I don't want

How to iterate in all files in the IntelliJ plugin project?

I'm trying to create an IntelliJ plugin that iterates over all files in the project folder and parses all the .java files and then makes some changes in them. The problem is that after reading the documentation I don't have a clear idea how to iterat

How do I retrieve all values ​​in a column in mongodb in an ArrayList?

This is the values of my data stored in mongo db. How am I able to retrieve all the data of "HomeTown" and store it all into a list? My list would contain AA, AA, BB, BB, etc... I want to use that array list to create a for loop of each Hometown

Combinatorics in Scala: How to iterate / enumerate all possibilities to merge several sequences / lists (riffle shuffle permutations)

Updated question: In my original question I did not know how to refer to the following problem. To clarify my question, I added the following illustration from Wikipedia: It turns out that the problem is also named after this analogy: Riffle shuffle

ansible: how to iterate on all the recorded results?

Given the following playbook: --- - name: Check if log directory exists - Step 1 stat: path="{{ wl_base }}/{{ item.0.name }}/{{ wl_dom }}/servers/{{ item.1 }}/logs" get_md5=no register: log_dir with_subelements: - wl_instances - servers - name:

How to iterate over all subsets of a set of numbers totaling about 0

Now, I haven't applied myself to functional programming for, oh, nearly 20 years, when we didn't get much further than writing factorials and fibs, so I'm really appealing to the community for some help in finding a solution. My problem is this: "Giv

How to check if all values ​​in an array are equal

This question already has an answer here: Using linq or otherwise, how do check if all list items have the same value and return it, or return an "otherValue" if they don't? 9 answers The following checks if all values in a string array are equa

How do I select all values ​​from a table with jQuery?

$(document).ready(function() alert($("td").val()); }); But the alert is empty. How do I select the values in my table with jQuery? Thank you. edit: I was asked what for: I have a website that I need the database data from for a javascript functi

How to iterate through all the parent nodes of the treeview control in c ++?

I am new to C++. Is there any way to iterate through all parent nodes starting from the tree ? Ex : ParentNode1->Child1 ->Child2 ParentNode2->Child1 ->Child2 I want to iterate from ParentNode1 to ParentNode2. Kindly suggest.Use the following f

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK