On Monday 09 February 2015 09:32:56 Marc Mutz wrote: > > Something like this should work just as well on QVector, right? If you > > are doing multiple inserts, perhaps you should keep the inserts outside > > the main vector while you make them, and only at the end do a single > > std::merge. > > Boom. Enter quadratic behaviour. > > There is Loki::AssociativeVector, but things like the above is why no-one > is using it. You only gain if you don't contantly maintain the is_sorted > invariant.
To make my statement more precise: As soon as you provide insert_sorted, the same people who now use QSet + toList + sort() will invariably use it in a loop. Using a plain vector *is* fine. One just need to get over the fact that this is not Python and one has to use std algorithms and function objects. It's not the syntax that's a problem. It's the semantics that need to be understood. In this case, *both* algorithmic complexity *and* the cost of non- locality of reference (which is why QMap is so bad). -- Marc Mutz <[email protected]> | Senior Software Engineer KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090 KDAB - Qt Experts - Platform-Independent Software Solutions _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
