[Development] [Qt-interest] QMultiHash

André Somers andre at familiesomers.nl
Thu Mar 7 11:12:05 CET 2013


Op 7-3-2013 10:24, pengliang(??) schreef:
>
> Hi All
>
> QMultiHash<Qstring,int>hh;
>
> I need to find some key and change their values.
>
> I found If I use QmutableHashIterator<Qstring,int>it , its
>
> bool
>
> 	
>
> *findNext <qmutablehashiterator.html#findNext>*( const T &/value/)
>
> Its parameter is a value, not a key.
>
> So I need to :
>
> While(it.hasNext())
>
> {
>
> It.next();
>
> If(it.key() == ikey)
>
> {
>
> It.setValue(ivalue);
> }
>
> }
>
> I must to check every item? Who have a better method?
>
> 2. Qhash:
>
> Some books said Qhash is unorderred?
>
> But I test it.
>
> Qhash<Qstring,int>hh;
>
> 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?
>
Well, it is not unordered, and I doubt that that is what the book 
actually said. However, the order is undefined. Qt just makes no 
guarantee whatsoever about the order of the items. Not even that it is 
the same for the same types used between different compilers,between 
debug and release builds, between different platforms, between Qt 
versions or even between runs.

So, even if it looks ordered to you now or it perhaps really is 
perfectly ordered, there is no way for you to know that it will stay 
that way.

André

-- 
You like Qt?
I am looking for collegues to join me at i-Optics!

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


More information about the Development mailing list