[Qt-interest] QMultiHash operator== not working as expected
Christian
christian.doering at uni-muenster.de
Fri Oct 2 10:52:39 CEST 2009
Hi,
well im not mixing value and key. I have keys that are mapped to
multiple values and therefore i used MultiHash. The insert method of
QmultiHash does not replace. It creates a new entry (as stated in the
documentation). You can see that because the size of both hashes is 2.
So i think my problem still remains.
Best Regards
Christian
-----Ursprüngliche Nachricht-----
Von: Carlos Manuel Duclos Vergara [mailto:carlos.duclos at nokia.com]
Gesendet: Freitag, 2. Oktober 2009 10:32
An: qt-interest at trolltech.com
Cc: Christian
Betreff: Re: [Qt-interest] QMultiHash operator== not working as expected
Hi,
[...]
>
> If i look into documentation for the operator the following is stated:
> "Two hashes are considered equal if they contain the same (key, value)
> pairs." So in my opinion both comparisons in my code should return
true
> but that is not the case. Is this behaviour intended? If so, what
> structure can i use instead?
>
The output is correct, the problem is you are mixing keys and values.
The
first parameter of insert is the key, not the value.
If you do:
hash1.insert("a", 1);
hash1.insert("a", 2);
hash2.insert("a", 2);
hash2.insert("a", 1);
Then you are replacing the corresponding value in the hash since both
have the
same key.
Regards
--
Carlos Manuel Duclos Vergara
Senior Software Engineer, QA/Team Lead
Nokia, Qt Software
More information about the Qt-interest-old
mailing list