Re: [Development] Is QMap Broken

2014-11-10 Thread Robert Steckroth
thanks all, mine. On Mon, Nov 10, 2014 at 5:34 AM, Alejandro Exojo wrote: > El Monday 10 November 2014, Robert Steckroth escribió: > > [SOLVED]: After perusing the qmap.h libraiy I found the reason why QMap > was > > keeping a sorted node list. > > Please, instead of opening bug reports, digging

Re: [Development] Is QMap Broken

2014-11-10 Thread Alejandro Exojo
El Monday 10 November 2014, Robert Steckroth escribió: > [SOLVED]: After perusing the qmap.h libraiy I found the reason why QMap was > keeping a sorted node list. Please, instead of opening bug reports, digging in the sources, and wasting everybody's time, you should read one of the very first li

Re: [Development] Is QMap Broken

2014-11-10 Thread Robert Knight
Hi Robert, QMap is doing exactly what it is supposed to do. If you want to preserve insertion order, you need a different data structure - like the one Mandeep linked to. If the list is not going to grow large, a simple vector will suffice. If you want a custom sort order, use STL's equivalent of

Re: [Development] Is QMap Broken

2014-11-09 Thread Robert Steckroth
[SOLVED]: After perusing the qmap.h libraiy I found the reason why QMap was keeping a sorted node list. There is a few of these calls to qMapLessThanKey which is doing variant comparison. template inline bool qMapLessThanKey(const Key &key1, const Key &key2) { return key1 < key2; } Any wa

Re: [Development] Is QMap Broken

2014-11-06 Thread Mandeep Sandhu
On Thu, Nov 6, 2014 at 6:24 AM, Robert Knight wrote: > > 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). > > Yes, that's the whole point of a QMap. If you don't

Re: [Development] Is QMap Broken

2014-11-06 Thread Robert Knight
> 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). Yes, that's the whole point of a QMap. If you don't care about the order of elements in a map, you should almost alw

Re: [Development] Is QMap Broken

2014-11-06 Thread Tomasz Siekierda
> On 06. 11. 14 09:13, André Somers wrote: >> Tomasz Siekierda schreef op 6-11-2014 09:10: >>> To store 2 items at a single position in list/ vector, you can use >>> QPair, like this: QLIst >() >> Better yet, just use a struct then. QPair in my experience results in >> badly readable code. Who will

Re: [Development] Is QMap Broken

2014-11-06 Thread Ayberk Özgür
I think QMap just follows std::map, which is why it's ordered and why the pairs have firsts and seconds just like std::pair. On 06. 11. 14 09:13, André Somers wrote: > Tomasz Siekierda schreef op 6-11-2014 09:10: >> To store 2 items at a single position in list/ vector, you can use >> QPair, like

Re: [Development] Is QMap Broken

2014-11-06 Thread André Somers
Tomasz Siekierda schreef op 6-11-2014 09:10: > To store 2 items at a single position in list/ vector, you can use > QPair, like this: QLIst >() Better yet, just use a struct then. QPair in my experience results in badly readable code. Who will ever remember down the line what was first, and what

Re: [Development] Is QMap Broken

2014-11-06 Thread Tomasz Siekierda
> On 06/11/2014 01:36, Robert Steckroth wrote: > > 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). Neither QMap nor QHash preserve the order of item insertion. If

Re: [Development] Is QMap Broken

2014-11-05 Thread Renaud Guezennec
"When iterating over a QHash , the items are arbitrarily ordered. With QMap, the items are always sorted by key." from: http://qt-project.org/doc/qt-5/qmap.html#details On 06/11/2014 01:36, Robert Steckroth wrote: Consider the following program, sho

[Development] Is QMap Broken

2014-11-05 Thread Robert Steckroth
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 #include #include #include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv);