On Tuesday 10 February 2015 11:37:28 Smith Martin wrote: > >For those guys, no amount of documentation will save them from writing > >bad code, so I don't think we should concern ourselves much with this case. > > > >I'm happy with the documentation if an educated developer reads it, and > >is able to make the correct decision on which container class to use. > > You're sort of nullifying the concept of recommending best practices at all. > > We won't be asking the developers to include basic CS concepts when > documenting a new class, if that's a worry. In this case, I asked for > clarification of some points, so I could add a recommendation to QMap > myself. > > I use QMap all the time, and almost certainly in situations where a vector > would be better. Why? Because it's dead simple and I need to get it running > now. I suppose we get used to doing the same thing the same way and don't > always pay attention to these details when a deadline is fast approaching. > It helps to be reminded of best practice tips from time to time when > checking a class I use out of habit.
I think using a QMap is fine in most case. You can sometimes get better performances with a QVector or QHash in some cases. However, using QVector in place of a QMap tends to lead to code that might be more complicated to write and understand. Also using a QVector when QMap would have been better might lead to O(n^2) complexity which is even worse. So I'd be careful recommending to use QVector over QMap. Regarding the documentation: The complexity of QList, QVector, QMap and QHash is already explain in the documentation. http://doc.qt.io/qt-5/containers.html . There are implementation details about QList which are not documented but probably should because they make the difference. About the best practice, there could perhaps be a wiki page with them. Just like the Qt coding style do not belong in the documentation. -- Olivier Woboq - Qt services and support - http://woboq.com - http://code.woboq.org _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development