This is a discussion on Re: [KDE4] foreach - KDE ; --===============0508317292== Content-Type: multipart/signed; boundary="nextPart1314687.49VRUDYgRC"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1314687.49VRUDYgRC Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Friday 05 August 2005 16:44, Gary Cramblitt wrote: > It appears that pre-increment is still preferred over post-increment?, i.= e. Yes, but that's ...
--===============0508317292==
Content-Type: multipart/signed;
boundary="nextPart1314687.49VRUDYgRC";
protocol="application/pgp-signature";
micalg=pgp-sha1
Content-Transfer-Encoding: 7bit
--nextPart1314687.49VRUDYgRC
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
On Friday 05 August 2005 16:44, Gary Cramblitt wrote:
> It appears that pre-increment is still preferred over post-increment?, i.=
e.
Yes, but that's because it's a C++ language issue. pre-increment avoids=20
creation of a temporary iterator object which is usually unnecessary.
> but is this better?
>
> QHash::iterator it =3D m_pooledFilterMgrs.begi=
n();
> QHash::iterator itEnd =3D
> m_pooledFilterMgrs.end(); while (it !=3D itEnd) {
> // do something
> ++it;
> }
It is better for any container that doesn't cache the value of end(), only=
=20
problem is that I forget which ones actually can cache it. So it's general=
ly=20
safer to use it if you're worried about performance.
> and of course const_iterator is preferred if you're not going to modify t=
he
> container.
Also don't forget to use constEnd() and constBegin() instead of end() and=20
begin(), since it is more efficient for some containers.
Regards,
- Michael Pyne
--nextPart1314687.49VRUDYgRC
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBC8+4hqjQYp5Omm0oRAggzAKDQn0sVbVJbp2NhsWuMt0 d8f2tqAwCgg5af
sscnxMEryj2jSTTuI4Jhsy8=
=Ixty
-----END PGP SIGNATURE-----
--nextPart1314687.49VRUDYgRC--
--===============0508317292==
Content-Type: text/plain; charset="iso-8859-1"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
=
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscrib=
e <<
--===============0508317292==--