Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.9
-
None
Description
A multi-insert should add elements to the container in the order of which the elements are inserted.
Instead, they're added in the opposite order (maybe it always goes for the leftmost node?). In other words, this code:
#include <QtCore> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QMultiMap<int, int> map; map.insert(0, 0); map.insert(0, 1); for (auto &i : map) qDebug() << i;; }
prints 1, 0.
This means that adding a map to another map in iteration order would "reverse" its run of contiguous keys, making the two maps compare unidentical:
#include <QtCore> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QMultiMap<int, int> map; map.insert(0, 0); map.insert(0, 1); QMultiMap<int, int> map2; for (auto i = map.constBegin(), e = map.constEnd(); i != e; ++i) map2.insert(i.key(), i.value()); Q_ASSERT(map == map2); }
Attachments
Issue Links
- relates to
-
QTBUG-60395 QHash, QMultiHash operator== is broken
-
- Closed
-