hi again, I want to have short input on which iterators to use. Qt provides both, STL- and JAVA-style iterators. Here an example: java-style: QStringListIterator it(route); QPointF p; p.setX(it.next().toDouble()*8); p.setY(it.next().toDouble()*8); moveTo( p ); while (it.hasNext()) { p.setX(it.next().toDouble()); p.setY(it.next().toDouble()); p*=8; lineTo( p ); }
same code with STL-style: QStringListI::const_iterator it = route.constBegin(); QPointF p; p.setX((*it++).toDouble()*8); p.setY((*it++).toDouble()*8); moveTo( p ); while ( it != route.constEnd() ) { p.setX((*it++).toDouble()); p.setY((*it++).toDouble()); p*=8; lineTo( p ); } which one should we use? There is now speed-impact of one over the other. Just a matter of taste. When iterating the whole list, I personally prefer the foreach macro, like: foreach (QVariant component, m_model->components()) { if (component.canConvert(QVariant::Map)) { addItem( new ComponentItem( component.toMap(), m_theme ) ); } } Is it okay? Or should we use another method, to iterate over every item in a list. (alternatives are: for-loops in combination with List::size() or iterators) I know, we have talked about that, earlier, but IMHO, we didn't agree on anything, yet. At least, I'm not aware of it. We should specify these things in the wiki.. and I'm willing to go through the code and change everything according to our agreements. This doesn't have to be done, right now, I just want to produce new code according to our agreements. My votes for the record: java-style iterators and foreach-macro, when possible bye then julian
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________ Ktechlab-devel mailing list Ktechlab-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ktechlab-devel