[Development] Is QMap Broken
Robert Steckroth
robertsteckroth at gmail.com
Thu Nov 6 01:36:28 CET 2014
Consider the following program, shouldn't the end() iterator place each key
at the end of the newly created QMap. Instead, the keys and subsequent
iterations are sorted (somehow).
#include <QCoreApplication>
#include <QMap>
#include <QString>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QMap <QString, QString> m;
m.insertMulti(m.end(), "2", "22");
m.insertMulti(m.end(), "1", "11");
m.insertMulti(m.end(), "3", "33");
QMap<QString, QString>::iterator i = m.begin();
for ( i = m.begin(); i != m.end(); ++i ) {
qDebug() << ">" << i.key();
}
qDebug() << ":" << m.keys();
return a.exec();
}
/* OUTPUT:
*
* > "1"
* > "2"
* > "3"
* : ("1", "2", "3")
*
*/
--
<surgemcgee>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20141105/b02acdca/attachment.html>
More information about the Development
mailing list