Clarify foreach's documentation on valued-containers
- Explain that values() is unnecessary and causes an extra copy. - Replace "are fastest" with "are faster". - Briefly explain the snippet. Change-Id: Iff1d3a0b6140fca1d78157aeeca3d538c4d78b84 Reviewed-by: Albert Astals Cid <albert.astals@canonical.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
e1804dcf3d
commit
be29c4053e
@ -578,9 +578,11 @@
|
||||
\snippet code/doc_src_containers.cpp 18
|
||||
|
||||
With QMap and QHash, \c foreach accesses the value component of
|
||||
the (key, value) pairs. If you want to iterate over both the keys
|
||||
and the values, you can use iterators (which are fastest), or you
|
||||
can write code like this:
|
||||
the (key, value) pairs automatically, so you should not call
|
||||
values() on the container (it would generate an unnecessary copy,
|
||||
see below). If you want to iterate over both the keys and the
|
||||
values, you can use iterators (which are faster), or you can
|
||||
obtain the keys, and use them to get the values too:
|
||||
|
||||
\snippet code/doc_src_containers.cpp 19
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user