[Development] [Qt-interest] QMultiHash

Danny Koppel D.Koppel at skf-rif.nl
Thu Mar 7 10:38:55 CET 2013


I don't know if I understand you correctly but the QMultiHash class has the function replace which does what you describe.
It replaces the value of an existing key or creates a new one if the key doesn't exist yet.
About point 2: the documentation describes it as follows: "When iterating over a QMap<qthelp://org.qt-project.qtcore.501/qtcore/qmap.html>, the items are always sorted by key. With QHash, the items are arbitrarily ordered.".

Kind regards,

Van: development-bounces+d.koppel=skf-rif.nl at qt-project.org [mailto:development-bounces+d.koppel=skf-rif.nl at qt-project.org] Namens pengliang(??)
Verzonden: donderdag 7 maart 2013 10:25
Aan: development at qt-project.org
Onderwerp: [Development] [Qt-interest] QMultiHash

Hi All

I need to find some key and change their values.
I found If I use QmutableHashIterator<Qstring,int>it , its

findNext<qmutablehashiterator.html#findNext> ( const T & value )

Its parameter is a value, not a key.
So I need to :
If(it.key() == ikey)

I must to check every item? Who have a better method?

2. Qhash:
Some books said Qhash is unorderred?
But I test it.
I insert some string, and loop the hash by QhashIterator, I found the string is orderred.
And I test it Qhash<int,Qstring>, and print key, and found they still orderred.
Why books said it is unorderred?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130307/46d8dd8a/attachment.html>

More information about the Development mailing list