QMap: remove more docs referring to multiple values for the same key
Such semantics have been dropped from Qt 6. Change-Id: I12f3478833afafa34f9075faf9ed030d06cd86f9 Pick-to: 6.2 6.3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ee61ea399b
commit
f69005687c
@ -72,22 +72,6 @@ map.insert("plenty", 2000);
|
|||||||
//! [9]
|
//! [9]
|
||||||
|
|
||||||
|
|
||||||
//! [10]
|
|
||||||
QList<int> values = map.values("plenty");
|
|
||||||
for (int i = 0; i < values.size(); ++i)
|
|
||||||
cout << values.at(i) << Qt::endl;
|
|
||||||
//! [10]
|
|
||||||
|
|
||||||
|
|
||||||
//! [11]
|
|
||||||
QMap<QString, int>::iterator i = map.find("plenty");
|
|
||||||
while (i != map.end() && i.key() == "plenty") {
|
|
||||||
cout << i.value() << Qt::endl;
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
//! [11]
|
|
||||||
|
|
||||||
|
|
||||||
//! [12]
|
//! [12]
|
||||||
QMap<QString, int> map;
|
QMap<QString, int> map;
|
||||||
...
|
...
|
||||||
|
@ -87,24 +87,14 @@
|
|||||||
|
|
||||||
The items are traversed in ascending key order.
|
The items are traversed in ascending key order.
|
||||||
|
|
||||||
Normally, a QMap allows only one value per key. If you call
|
A QMap allows only one value per key. If you call
|
||||||
insert() with a key that already exists in the QMap, the
|
insert() with a key that already exists in the QMap, the
|
||||||
previous value will be erased. For example:
|
previous value will be erased. For example:
|
||||||
|
|
||||||
\snippet code/src_corelib_tools_qmap.cpp 9
|
\snippet code/src_corelib_tools_qmap.cpp 9
|
||||||
|
|
||||||
However, you can store multiple values per key by using
|
However, you can store multiple values per key by using
|
||||||
QMultiMap. If you want
|
QMultiMap.
|
||||||
to retrieve all the values for a single key, you can use
|
|
||||||
values(const Key &key), which returns a QList<T>:
|
|
||||||
|
|
||||||
\snippet code/src_corelib_tools_qmap.cpp 10
|
|
||||||
|
|
||||||
Another approach is to call
|
|
||||||
find() to get the STL-style iterator for the first item with a
|
|
||||||
key and iterate from there:
|
|
||||||
|
|
||||||
\snippet code/src_corelib_tools_qmap.cpp 11
|
|
||||||
|
|
||||||
If you only need to extract the values from a map (not the keys),
|
If you only need to extract the values from a map (not the keys),
|
||||||
you can also use \l{foreach}:
|
you can also use \l{foreach}:
|
||||||
@ -318,9 +308,7 @@
|
|||||||
the value associated with it.
|
the value associated with it.
|
||||||
|
|
||||||
If the item does not exist in the map, the function simply
|
If the item does not exist in the map, the function simply
|
||||||
returns a \l{default-constructed value}. If there are multiple
|
returns a \l{default-constructed value}.
|
||||||
items for \a key in the map, only the most recently inserted one
|
|
||||||
is removed and returned.
|
|
||||||
|
|
||||||
If you don't use the return value, remove() is more efficient.
|
If you don't use the return value, remove() is more efficient.
|
||||||
|
|
||||||
@ -370,9 +358,7 @@
|
|||||||
|
|
||||||
If the map contains no item with key \a key, the function inserts
|
If the map contains no item with key \a key, the function inserts
|
||||||
a \l{default-constructed value} into the map with key \a key, and
|
a \l{default-constructed value} into the map with key \a key, and
|
||||||
returns a reference to it. If the map contains multiple items
|
returns a reference to it.
|
||||||
with key \a key, this function returns a reference to the most
|
|
||||||
recently inserted value.
|
|
||||||
|
|
||||||
\sa insert(), value()
|
\sa insert(), value()
|
||||||
*/
|
*/
|
||||||
@ -772,9 +758,6 @@
|
|||||||
If a key is common to both maps, its value will be replaced with
|
If a key is common to both maps, its value will be replaced with
|
||||||
the value stored in \a map.
|
the value stored in \a map.
|
||||||
|
|
||||||
\note If \a map contains multiple entries with the same key then the
|
|
||||||
final value of the key is undefined.
|
|
||||||
|
|
||||||
\sa QMultiMap::insert()
|
\sa QMultiMap::insert()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user